|
@@ -0,0 +1,612 @@
|
|
|
+package com.qmth.teachcloud.report.business.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+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.SysUser;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
|
+import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
+import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
+import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.excel.BasicCourseChangeDto;
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.excel.SysOrgChangeDto;
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.excel.SysUserChangeDto;
|
|
|
+import com.qmth.teachcloud.report.business.entity.TAExamCourse;
|
|
|
+import com.qmth.teachcloud.report.business.entity.TAExamTotal;
|
|
|
+import com.qmth.teachcloud.report.business.service.*;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: 课程单元操作服务实现类
|
|
|
+ * @Author: CaoZixuan
|
|
|
+ * @Date: 2022-02-25
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CourseUnitOperateServiceImpl implements CourseUnitOperateService {
|
|
|
+ @Resource
|
|
|
+ private BasicCourseService basicCourseService;
|
|
|
+ @Resource
|
|
|
+ private SysOrgService sysOrgService;
|
|
|
+ @Resource
|
|
|
+ private SysUserService sysUserService;
|
|
|
+ @Resource
|
|
|
+ private TBCommonLevelConfigService tbCommonLevelConfigService;
|
|
|
+ @Resource
|
|
|
+ private TBCommonRankLevelConfigService tbCommonRankLevelConfigService;
|
|
|
+ @Resource
|
|
|
+ private TBDimensionService tbDimensionService;
|
|
|
+ @Resource
|
|
|
+ private TBExamCourseService tbExamCourseService;
|
|
|
+ @Resource
|
|
|
+ private TBExamStudentService tbExamStudentService;
|
|
|
+ @Resource
|
|
|
+ private TBModuleConfigService tbModuleConfigService;
|
|
|
+ @Resource
|
|
|
+ private TBModuleProficiencyService tbModuleProficiencyService;
|
|
|
+ @Resource
|
|
|
+ private TBPaperService tbPaperService;
|
|
|
+ @Resource
|
|
|
+ private TBTeacherService tbTeacherService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseService taExamCourseService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseClazzService taExamCourseClazzService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseCollegeInspectService taExamCourseCollegeInspectService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseCollegeInspectDioService taExamCourseCollegeInspectDioService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseCollegePaperStructService taExamCourseCollegePaperStructService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseCollegeTeacherService taExamCourseCollegeTeacherService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseDifficultService taExamCourseDifficultService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseDioService taExamCourseDioService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseRecordDioService taExamCourseRecordDioService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseRecordModService taExamCourseRecordModService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseTeacherService taExamCourseTeacherService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseTeacherCollegeDifficultService taExamCourseTeacherCollegeDifficultService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseTeacherCollegeDioService taExamCourseTeacherCollegeDioService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseTeacherCollegePaperStructService taExamCourseTeacherCollegePaperStructService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseTeacherDifficultService taExamCourseTeacherDifficultService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseTeacherDioService taExamCourseTeacherDioService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseTeacherPaperStructService taExamCourseTeacherPaperStructService;
|
|
|
+ @Resource
|
|
|
+ private TAExamTotalService taExamTotalService;
|
|
|
+ @Resource
|
|
|
+ private TAPaperStructService taPaperStructService;
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public String changeBasicCourse(MultipartFile file, Long schoolId) throws IOException, NoSuchFieldException {
|
|
|
+ // 基础课程数据源
|
|
|
+ List<BasicCourse> basicCourseDatasource = basicCourseService.list(new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getSchoolId, schoolId));
|
|
|
+
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(BasicCourseChangeDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ if (finalExcelErrorList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
+ }
|
|
|
+ return finalExcelList;
|
|
|
+ });
|
|
|
+ List<BasicCourse> updateData = 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> dataSource = map.get(i);
|
|
|
+ for (int y = 0; y < Objects.requireNonNull(dataSource).size(); y++) {
|
|
|
+ if (dataSource.get(y) instanceof BasicCourseChangeDto) {
|
|
|
+ BasicCourseChangeDto basicCourseChangeDto = (BasicCourseChangeDto) dataSource.get(y);
|
|
|
+ Long id = SystemConstant.convertIdToLong(basicCourseChangeDto.getId());
|
|
|
+
|
|
|
+
|
|
|
+ List<BasicCourse> basicCourseVerifyList = basicCourseDatasource.stream().filter(e -> e.getId().equals(id)).collect(Collectors.toList());
|
|
|
+ if (basicCourseVerifyList.size() > 0) {
|
|
|
+ BasicCourse basicCourse = basicCourseVerifyList.get(0);
|
|
|
+ Long excelSchoolId = SystemConstant.convertIdToLong(basicCourseChangeDto.getSchoolId());
|
|
|
+ String courseCode = basicCourseChangeDto.getCourseCode();
|
|
|
+ String historicName = basicCourseChangeDto.getHistoricName();
|
|
|
+ String newName = basicCourseChangeDto.getNewName();
|
|
|
+ if (!SystemConstant.strNotNull(newName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据校验
|
|
|
+ if (!basicCourse.getSchoolId().equals(excelSchoolId) || !basicCourse.getCode().equals(courseCode) || !basicCourse.getName().equals(historicName)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("第【" + (y + 2) + "】行数据不对应");
|
|
|
+ }
|
|
|
+ // 基础数据替换
|
|
|
+ basicCourse.setName(newName);
|
|
|
+ basicCourse.setHistoricName(historicName);
|
|
|
+ updateData.add(basicCourse);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ basicCourseService.updateBatchById(updateData);
|
|
|
+ return "'basic_course' 基础课程表完成更新【" + updateData.size() + "】课次";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public String changeSysOrg(MultipartFile file, Long schoolId) throws IOException, NoSuchFieldException {
|
|
|
+ // 基础机构数据
|
|
|
+ List<SysOrg> sysOrgDatasource = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId));
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(SysOrgChangeDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ if (finalExcelErrorList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
+ }
|
|
|
+ return finalExcelList;
|
|
|
+ });
|
|
|
+ List<SysOrg> updateData = new ArrayList<>();
|
|
|
+ Map<String, Integer> nameCheck = new HashMap<>();
|
|
|
+
|
|
|
+ if (Objects.nonNull(finalList) && finalList.size() > 0) {
|
|
|
+ for (int i = 0; i < finalList.size(); i++) {
|
|
|
+ LinkedMultiValueMap<Integer, Object> map = finalList.get(i);
|
|
|
+ List<Object> dataSource = map.get(i);
|
|
|
+ for (int y = 0; y < Objects.requireNonNull(dataSource).size(); y++) {
|
|
|
+ if (dataSource.get(y) instanceof SysOrgChangeDto) {
|
|
|
+ SysOrgChangeDto sysOrgChangeDto = (SysOrgChangeDto) dataSource.get(y);
|
|
|
+ Long id = SystemConstant.convertIdToLong(sysOrgChangeDto.getId());
|
|
|
+
|
|
|
+
|
|
|
+ List<SysOrg> sysOrgVerifyList = sysOrgDatasource.stream().filter(e -> e.getId().equals(id)).collect(Collectors.toList());
|
|
|
+ if (sysOrgVerifyList.size() > 0) {
|
|
|
+ SysOrg sysOrg = sysOrgVerifyList.get(0);
|
|
|
+ Long excelSchoolId = SystemConstant.convertIdToLong(sysOrgChangeDto.getSchoolId());
|
|
|
+ String orgCode = sysOrgChangeDto.getOrgCode();
|
|
|
+ String historicName = sysOrgChangeDto.getHistoricName();
|
|
|
+ String newName = sysOrgChangeDto.getNewName();
|
|
|
+ if (!SystemConstant.strNotNull(newName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据校验
|
|
|
+ if (nameCheck.containsKey(newName)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("第【" + (y + 2) + "】行变更的机构名称【" + newName + "】和第【" + nameCheck.get(newName) + "】行重复");
|
|
|
+ } else {
|
|
|
+ nameCheck.put(newName, (y + 2));
|
|
|
+ }
|
|
|
+ if (!sysOrg.getSchoolId().equals(excelSchoolId) || !sysOrg.getCode().equals(orgCode) || !sysOrg.getName().equals(historicName)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("第【" + (y + 2) + "】行数据不对应");
|
|
|
+ }
|
|
|
+ // 基础数据替换
|
|
|
+ sysOrg.setName(newName);
|
|
|
+ sysOrg.setHistoricName(historicName);
|
|
|
+ updateData.add(sysOrg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sysOrgService.updateBatchById(updateData);
|
|
|
+ return "'sys_org' 系统机构表完成更新【" + updateData.size() + "】次";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public String changeSysUser(MultipartFile file, Long schoolId) throws IOException, NoSuchFieldException {
|
|
|
+ // 基础机构数据
|
|
|
+ List<SysOrg> sysOrgDatasource = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId));
|
|
|
+ // 基础用户数据
|
|
|
+ List<SysUser> sysUserDatasource = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getSchoolId, schoolId));
|
|
|
+
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(SysUserChangeDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ if (finalExcelErrorList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
+ }
|
|
|
+ return finalExcelList;
|
|
|
+ });
|
|
|
+
|
|
|
+ List<SysUser> updateData = 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> dataSource = map.get(i);
|
|
|
+ for (int y = 0; y < Objects.requireNonNull(dataSource).size(); y++) {
|
|
|
+ if (dataSource.get(y) instanceof SysUserChangeDto) {
|
|
|
+ SysUserChangeDto sysUserChangeDto = (SysUserChangeDto) dataSource.get(y);
|
|
|
+ Long id = SystemConstant.convertIdToLong(sysUserChangeDto.getId());
|
|
|
+
|
|
|
+
|
|
|
+ List<SysUser> sysUserVerifyList = sysUserDatasource.stream().filter(e -> e.getId().equals(id)).collect(Collectors.toList());
|
|
|
+ if (sysUserDatasource.size() > 0) {
|
|
|
+ SysUser sysUser = sysUserVerifyList.get(0);
|
|
|
+ Long excelSchoolId = SystemConstant.convertIdToLong(sysUserChangeDto.getSchoolId());
|
|
|
+ String historicName = sysUserChangeDto.getHistoricName();
|
|
|
+ String newName = sysUserChangeDto.getNewName();
|
|
|
+ if (!SystemConstant.strNotNull(newName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 如果该用户是机构表中自动创建的考察学院院长用户,则同步更新用户名为机构表名称
|
|
|
+ List<SysOrg> sysOrgList = sysOrgDatasource.stream().filter(e -> e.getHistoricName().equals(historicName)).collect(Collectors.toList());
|
|
|
+ if (sysOrgList.size() == 1) {
|
|
|
+ sysUser.setRealName(sysOrgList.get(0).getName());
|
|
|
+ } else {
|
|
|
+ // 数据校验
|
|
|
+ if (!sysUser.getSchoolId().equals(excelSchoolId) || !sysUser.getRealName().equals(historicName)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("第【" + (y + 2) + "】行数据不对应");
|
|
|
+ }
|
|
|
+ // 基础数据替换
|
|
|
+ sysUser.setRealName(newName);
|
|
|
+ }
|
|
|
+ sysUser.setHistoricName(historicName);
|
|
|
+ updateData.add(sysUser);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sysUserService.updateBatchById(updateData);
|
|
|
+ return "'sys_user' 系统用户表完成更新【" + updateData.size() + "】次";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void createDemoData() {
|
|
|
+ this.changeBasicDataTable();
|
|
|
+ this.changeAnalyzeDataTable();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询 课程编号 - 课程名称 map
|
|
|
+ *
|
|
|
+ * @return map
|
|
|
+ */
|
|
|
+ private Map<String, String> findCourseMap() {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ for (BasicCourse basicCourse : basicCourseService.list()) {
|
|
|
+ map.put(basicCourse.getCode(), basicCourse.getName());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询 机构id - 机构名称 map
|
|
|
+ *
|
|
|
+ * @return map
|
|
|
+ */
|
|
|
+ private Map<Long, String> findOrgMap() {
|
|
|
+ Map<Long, String> map = new HashMap<>();
|
|
|
+ for (SysOrg sysOrg : sysOrgService.list()) {
|
|
|
+ map.put(sysOrg.getId(), sysOrg.getName());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询 用户登录名(工号) - 用户真实名
|
|
|
+ *
|
|
|
+ * @return map
|
|
|
+ */
|
|
|
+ private Map<String, String> findUserCodeNameMap() {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ for (SysUser sysUser : sysUserService.list()) {
|
|
|
+ map.put(sysUser.getLoginName(), sysUser.getRealName());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询 用户id - 用户真实名
|
|
|
+ *
|
|
|
+ * @return map
|
|
|
+ */
|
|
|
+ private Map<Long, String> findUserIdNameMap() {
|
|
|
+ Map<Long, String> map = new HashMap<>();
|
|
|
+ for (SysUser sysUser : sysUserService.list()) {
|
|
|
+ map.put(sysUser.getId(), sysUser.getRealName());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新基础数据表
|
|
|
+ */
|
|
|
+ private void changeBasicDataTable() {
|
|
|
+ Map<String, String> courseMap = this.findCourseMap();
|
|
|
+ Map<Long, String> orgMap = this.findOrgMap();
|
|
|
+ Map<String, String> userMap = this.findUserCodeNameMap();
|
|
|
+ // t_b_common_level_config
|
|
|
+ tbCommonLevelConfigService.updateBatchById(tbCommonLevelConfigService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+ // t_b_common_rank_level_config
|
|
|
+ tbCommonRankLevelConfigService.updateBatchById(tbCommonRankLevelConfigService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+ // t_b_dimension
|
|
|
+ tbDimensionService.updateBatchById(tbDimensionService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+ // t_b_exam_course
|
|
|
+ tbExamCourseService.updateBatchById(tbExamCourseService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getTeachCollegeId())) {
|
|
|
+ e.setTeachCollegeName(orgMap.get(e.getTeachCollegeId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+ // t_b_exam_student
|
|
|
+ tbExamStudentService.updateBatchById(tbExamStudentService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+ // t_b_module_config
|
|
|
+ tbModuleConfigService.updateBatchById(tbModuleConfigService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+ // t_b_module_proficiency
|
|
|
+ tbModuleProficiencyService.updateBatchById(tbModuleProficiencyService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+ // t_b_paper
|
|
|
+ tbPaperService.updateBatchById(tbPaperService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+ // t_b_teacher
|
|
|
+ tbTeacherService.updateBatchById(tbTeacherService.list().stream().filter(e -> userMap.containsKey(e.getTeacherCode())).peek(e -> e.setTeacherName(userMap.get(e.getTeacherCode()))).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新分析数据表
|
|
|
+ */
|
|
|
+ public void changeAnalyzeDataTable() {
|
|
|
+ Map<String, String> courseMap = this.findCourseMap();
|
|
|
+ Map<Long, String> orgMap = this.findOrgMap();
|
|
|
+ Map<Long, String> userMap = this.findUserIdNameMap();
|
|
|
+ List<SysOrg> sysOrgList = sysOrgService.list();
|
|
|
+
|
|
|
+ // t_a_exam_course
|
|
|
+ this.complicatedTableTAExamCourseChanged();
|
|
|
+
|
|
|
+ // t_a_exam_course_clazz
|
|
|
+ taExamCourseClazzService.updateBatchById(taExamCourseClazzService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ List<SysOrg> cellList = sysOrgList.stream().filter(o -> o.getHistoricName().equals(e.getCollegeName()) && o.getSchoolId().equals(e.getSchoolId())).collect(Collectors.toList());
|
|
|
+ if (cellList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据异常");
|
|
|
+ }
|
|
|
+ if (cellList.size() == 1) {
|
|
|
+ e.setCollegeName(cellList.get(0).getName());
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // t_a_exam_course_college_inspect
|
|
|
+ taExamCourseCollegeInspectService.updateBatchById(taExamCourseCollegeInspectService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // t_a_exam_course_college_inspect_dio
|
|
|
+ taExamCourseCollegeInspectDioService.updateBatchById(taExamCourseCollegeInspectDioService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getInspectCollegeId())) {
|
|
|
+ e.setInspectCollegeName(orgMap.get(e.getInspectCollegeId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // t_a_exam_course_college_paper_struct
|
|
|
+ taExamCourseCollegePaperStructService.updateBatchById(taExamCourseCollegePaperStructService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getInspectCollegeId())) {
|
|
|
+ e.setInspectCollegeName(orgMap.get(e.getInspectCollegeId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // t_a_exam_course_college_teacher
|
|
|
+ taExamCourseCollegeTeacherService.updateBatchById(taExamCourseCollegeTeacherService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getInspectCollegeId())) {
|
|
|
+ e.setInspectCollegeName(orgMap.get(e.getInspectCollegeId()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getTeachCollegeId())) {
|
|
|
+ e.setTeachCollegeName(orgMap.get(e.getTeachCollegeId()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // t_a_exam_course_difficult
|
|
|
+ taExamCourseDifficultService.updateBatchById(taExamCourseDifficultService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // t_a_exam_course_dio
|
|
|
+ taExamCourseDioService.updateBatchById(taExamCourseDioService.list().stream().filter(e -> courseMap.containsKey(e.getCourseCode())).peek(e -> e.setCourseName(courseMap.get(e.getCourseCode()))).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_record_dio
|
|
|
+ taExamCourseRecordDioService.updateBatchById(taExamCourseRecordDioService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getInspectCollegeId())) {
|
|
|
+ e.setInspectCollegeName(orgMap.get(e.getInspectCollegeId()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_record_mod
|
|
|
+ taExamCourseRecordModService.updateBatchById(taExamCourseRecordModService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getInspectCollegeId())) {
|
|
|
+ e.setInspectCollegeName(orgMap.get(e.getInspectCollegeId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_teacher
|
|
|
+ taExamCourseTeacherService.updateBatchById(taExamCourseTeacherService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_teacher_college_difficult
|
|
|
+ taExamCourseTeacherCollegeDifficultService.updateBatchById(taExamCourseTeacherCollegeDifficultService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getInspectCollegeId())) {
|
|
|
+ e.setInspectCollegeName(orgMap.get(e.getInspectCollegeId()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_teacher_college_dio
|
|
|
+ taExamCourseTeacherCollegeDioService.updateBatchById(taExamCourseTeacherCollegeDioService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getInspectCollegeId())) {
|
|
|
+ e.setInspectCollegeName(orgMap.get(e.getInspectCollegeId()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_teacher_college_paper_struct
|
|
|
+ taExamCourseTeacherCollegePaperStructService.updateBatchById(taExamCourseTeacherCollegePaperStructService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(e.getInspectCollegeId())) {
|
|
|
+ e.setInspectCollegeName(orgMap.get(e.getInspectCollegeId()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_teacher_difficult
|
|
|
+ taExamCourseTeacherDifficultService.updateBatchById(taExamCourseTeacherDifficultService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_teacher_dio
|
|
|
+ taExamCourseTeacherDioService.updateBatchById(taExamCourseTeacherDioService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_course_teacher_paper_struct
|
|
|
+ taExamCourseTeacherPaperStructService.updateBatchById(taExamCourseTeacherPaperStructService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (userMap.containsKey(e.getTeacherId())) {
|
|
|
+ e.setTeacherName(userMap.get(e.getTeacherId()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //t_a_exam_total
|
|
|
+ this.complicatedTableTAExamTotalChanged();
|
|
|
+
|
|
|
+ //t_a_paper_struct
|
|
|
+ taPaperStructService.updateBatchById(taPaperStructService.list().stream().peek(e -> {
|
|
|
+ if (courseMap.containsKey(e.getCourseCode())) {
|
|
|
+ e.setCourseName(courseMap.get(e.getCourseCode()));
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复杂表 't_a_exam_course' 创建
|
|
|
+ */
|
|
|
+ private void complicatedTableTAExamCourseChanged() {
|
|
|
+ Map<String, String> courseMap = this.findCourseMap();
|
|
|
+ Map<Long, String> orgMap = this.findOrgMap();
|
|
|
+ List<SysOrg> sysOrgList = sysOrgService.list();
|
|
|
+
|
|
|
+ List<TAExamCourse> taExamCourseList = taExamCourseService.list();
|
|
|
+ for (TAExamCourse taExamCourse : taExamCourseList) {
|
|
|
+ Long schoolId = taExamCourse.getSchoolId();
|
|
|
+
|
|
|
+ if (courseMap.containsKey(taExamCourse.getCourseCode())) {
|
|
|
+ taExamCourse.setCourseName(courseMap.get(taExamCourse.getCourseCode()));
|
|
|
+ }
|
|
|
+ if (orgMap.containsKey(taExamCourse.getTeachCollegeId())) {
|
|
|
+ taExamCourse.setTeachCollegeName(orgMap.get(taExamCourse.getTeachCollegeId()));
|
|
|
+ }
|
|
|
+ String inspectCollegeNameStr = taExamCourse.getInspectCollegeNames();
|
|
|
+ List<String> newInspect = new ArrayList<>();
|
|
|
+ String[] inspectCollegeNameList = inspectCollegeNameStr.split("、");
|
|
|
+ for (String s : inspectCollegeNameList) {
|
|
|
+ List<SysOrg> cellList = sysOrgList.stream().filter(e -> e.getHistoricName().equals(s) && e.getSchoolId().equals(schoolId)).collect(Collectors.toList());
|
|
|
+ if (cellList.size() > 0) {
|
|
|
+ if (cellList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据异常");
|
|
|
+ }
|
|
|
+ SysOrg cell = cellList.get(0);
|
|
|
+ newInspect.add(cell.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (newInspect.size() > 0) {
|
|
|
+ taExamCourse.setInspectCollegeNames(String.join("、", newInspect));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taExamCourseService.updateBatchById(taExamCourseList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复杂表 't_a_exam_total' 创建
|
|
|
+ */
|
|
|
+ private void complicatedTableTAExamTotalChanged() {
|
|
|
+ List<SysOrg> sysOrgList = sysOrgService.list();
|
|
|
+ List<TAExamTotal> taExamTotalList = taExamTotalService.list();
|
|
|
+ for (TAExamTotal taExamTotal : taExamTotalList) {
|
|
|
+ String collegeNameStr = taExamTotal.getCollegeNames();
|
|
|
+ List<String> newCollegeList = new ArrayList<>();
|
|
|
+ String[] collegeNameList = collegeNameStr.split("、");
|
|
|
+ for (String s : collegeNameList) {
|
|
|
+ List<SysOrg> cellList = sysOrgList.stream().filter(e -> e.getHistoricName().equals(s) && e.getSchoolId().equals(taExamTotal.getSchoolId())).collect(Collectors.toList());
|
|
|
+ if (cellList.size() > 0) {
|
|
|
+ if (cellList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据异常");
|
|
|
+ }
|
|
|
+ SysOrg cell = cellList.get(0);
|
|
|
+ newCollegeList.add(cell.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (newCollegeList.size() > 0) {
|
|
|
+ taExamTotal.setCollegeNames(String.join("、", newCollegeList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|