|
@@ -25,10 +25,7 @@ import com.qmth.teachcloud.common.bean.dto.excel.*;
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
|
-import com.qmth.teachcloud.common.enums.FlowStatusEnum;
|
|
|
|
-import com.qmth.teachcloud.common.enums.PageSizeEnum;
|
|
|
|
-import com.qmth.teachcloud.common.enums.UploadFileEnum;
|
|
|
|
|
|
+import com.qmth.teachcloud.common.enums.*;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.util.*;
|
|
import com.qmth.teachcloud.common.util.*;
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
@@ -40,6 +37,7 @@ import org.apache.poi.ss.usermodel.Row;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
+import org.checkerframework.checker.units.qual.K;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -151,6 +149,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
@Resource
|
|
@Resource
|
|
BasicClazzService basicClazzService;
|
|
BasicClazzService basicClazzService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ SysOrgService sysOrgService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TCStatisticsImportTempService tcStatisticsImportTempService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TCStatisticsService tcStatisticsService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建pdf前置条件
|
|
* 创建pdf前置条件
|
|
@@ -1312,8 +1318,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional
|
|
public Map<String, Object> executeImportStatisticsLogic(Map<String, Object> map) throws Exception {
|
|
public Map<String, Object> executeImportStatisticsLogic(Map<String, Object> map) throws Exception {
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
|
|
+ SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(StatisticsImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(StatisticsImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
// 只允许导入一个sheet
|
|
// 只允许导入一个sheet
|
|
if (finalExcelList.size() > 1) {
|
|
if (finalExcelList.size() > 1) {
|
|
@@ -1323,37 +1331,49 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
}
|
|
}
|
|
List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
|
|
+ Map<String, SysOrg> collegeOrgMap = new HashMap<>(), teachingRoomMap = new HashMap<>();//学院,部门
|
|
|
|
+ Map<String, BasicCourse> courseMap = new HashMap<>();//课程
|
|
|
|
+ Map<String, SysUser> userMap = new HashMap<>();//用户
|
|
|
|
+ Map<String, BasicClazz> clazzMap = new HashMap<>();//班级
|
|
|
|
+ String batchNo = SystemConstant.getUuid();
|
|
|
|
+ List<TCStatisticsImportTemp> tcStatisticsImportTempList = new ArrayList<>();
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
List<Object> statisticsTempList = excelMap.get(i);
|
|
List<Object> statisticsTempList = excelMap.get(i);
|
|
for (int y = 0; y < statisticsTempList.size(); y++) {
|
|
for (int y = 0; y < statisticsTempList.size(); y++) {
|
|
StatisticsImportDto statisticsImportDto = (StatisticsImportDto) statisticsTempList.get(y);
|
|
StatisticsImportDto statisticsImportDto = (StatisticsImportDto) statisticsTempList.get(y);
|
|
-
|
|
|
|
-// if (StringUtils.isBlank(userImportDto.getTicketNumber())) {
|
|
|
|
-// excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[准考证号]必填"));
|
|
|
|
-// }
|
|
|
|
-// if (StringUtils.isBlank(userImportDto.getCourseCode())) {
|
|
|
|
-// excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程代码]必填"));
|
|
|
|
-// }
|
|
|
|
-// if (StringUtils.isBlank(userImportDto.getCourseName())) {
|
|
|
|
-// excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程名称]必填"));
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// // 课程是否存在并且与名称对应
|
|
|
|
-// QueryWrapper<BasicCourse> queryWrapper = new QueryWrapper<>();
|
|
|
|
-// queryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, userImportDto.getCourseCode());
|
|
|
|
-// BasicCourse course = basicCourseService.getOne(queryWrapper);
|
|
|
|
-// if (course == null) {
|
|
|
|
-// excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程代码]在系统中不存在"));
|
|
|
|
-// } else if (!course.getName().equals(userImportDto.getCourseName())) {
|
|
|
|
-// excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程名称]与系统中不匹配"));
|
|
|
|
-// }
|
|
|
|
|
|
+ SysOrg collegeOrg = this.validSysOrgExists(collegeOrgMap, statisticsImportDto.getCollegeName(), sysUser.getSchoolId(), OrgTypeEnum.COLLEGE, excelErrorTemp, (y + 1), (i + 1), "开课学院");
|
|
|
|
+ SysOrg teachingRoomOrg = this.validSysOrgExists(teachingRoomMap, statisticsImportDto.getTeachingRoomName(), sysUser.getSchoolId(), OrgTypeEnum.TEACHING_ROOM, excelErrorTemp, (y + 1), (i + 1), "开课部门");
|
|
|
|
+ BasicCourse basicCourse = this.validBasicCourseExists(courseMap, statisticsImportDto.getCourseName(), sysUser.getSchoolId(), statisticsImportDto.getCourseCode(), excelErrorTemp, (y + 1), (i + 1), "课程代码");
|
|
|
|
+ String teacherName = statisticsImportDto.getTeacherName();
|
|
|
|
+ if (teacherName.indexOf(",") == -1) {
|
|
|
|
+ SysUser dbUser = this.validSysUserExists(userMap, teacherName, sysUser.getSchoolId(), excelErrorTemp, (y + 1), (i + 1), "任课老师");
|
|
|
|
+ } else {
|
|
|
|
+ String[] teacherNames = teacherName.split(",");
|
|
|
|
+ for (int k = 0; k < teacherNames.length; k++) {
|
|
|
|
+ SysUser dbUser = this.validSysUserExists(userMap, teacherNames[k], sysUser.getSchoolId(), excelErrorTemp, (y + 1), (i + 1), "任课老师" + teacherNames[k]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ BasicClazz basicClazz = this.validBasicClazzExists(clazzMap, statisticsImportDto.getClazzName(), sysUser.getSchoolId(), excelErrorTemp, (y + 1), (i + 1), "班级名称");
|
|
|
|
+
|
|
|
|
+ TCStatisticsImportTemp tcStatisticsImportTemp = new TCStatisticsImportTemp(collegeOrg.getId(),
|
|
|
|
+ collegeOrg.getName(),
|
|
|
|
+ teachingRoomOrg.getId(),
|
|
|
|
+ teachingRoomOrg.getName(),
|
|
|
|
+ basicCourse.getName(),
|
|
|
|
+ basicCourse.getCode(),
|
|
|
|
+ teacherName,
|
|
|
|
+ basicClazz.getId(),
|
|
|
|
+ basicClazz.getClazzName(),
|
|
|
|
+ batchNo);
|
|
|
|
+ tcStatisticsImportTempList.add(tcStatisticsImportTemp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (excelErrorTemp.size() > 0) {
|
|
if (excelErrorTemp.size() > 0) {
|
|
List<String> errors = excelErrorTemp.stream().map(m -> m.getExcelErrorType()).collect(Collectors.toList());
|
|
List<String> errors = excelErrorTemp.stream().map(m -> m.getExcelErrorType()).collect(Collectors.toList());
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
|
|
}
|
|
}
|
|
|
|
+ tcStatisticsImportTempService.saveBatch(tcStatisticsImportTempList);
|
|
return finalExcelList;
|
|
return finalExcelList;
|
|
});
|
|
});
|
|
return map;
|
|
return map;
|
|
@@ -1363,4 +1383,162 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
public String createTempNumber(SerialNumberParams serialNumberParams) {
|
|
public String createTempNumber(SerialNumberParams serialNumberParams) {
|
|
return convertUtil.getIncre(serialNumberParams.getPrefix(), serialNumberParams.getModel(), serialNumberParams.getDigit());
|
|
return convertUtil.getIncre(serialNumberParams.getPrefix(), serialNumberParams.getModel(), serialNumberParams.getDigit());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 验证机构是否存在
|
|
|
|
+ *
|
|
|
|
+ * @param orgMap
|
|
|
|
+ * @param key
|
|
|
|
+ * @param schoolId
|
|
|
|
+ * @param orgTypeEnum
|
|
|
|
+ * @param excelErrorTemp
|
|
|
|
+ * @param row
|
|
|
|
+ * @param sheet
|
|
|
|
+ * @param cloumnName
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private SysOrg validSysOrgExists(Map<String, SysOrg> orgMap,
|
|
|
|
+ String key,
|
|
|
|
+ Long schoolId,
|
|
|
|
+ OrgTypeEnum orgTypeEnum,
|
|
|
|
+ List<ExcelError> excelErrorTemp,
|
|
|
|
+ int row,
|
|
|
|
+ int sheet,
|
|
|
|
+ String cloumnName) {
|
|
|
|
+ SysOrg sysOrg = null;
|
|
|
|
+ if (!orgMap.containsKey(key)) {//不存在查询
|
|
|
|
+ QueryWrapper<SysOrg> sysOrgQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ sysOrgQueryWrapper.lambda().eq(SysOrg::getSchoolId, schoolId)
|
|
|
|
+ .eq(SysOrg::getName, key)
|
|
|
|
+ .eq(SysOrg::getType, orgTypeEnum)
|
|
|
|
+ .eq(SysOrg::getEnable, true);
|
|
|
|
+ sysOrg = sysOrgService.getOne(sysOrgQueryWrapper);
|
|
|
|
+ } else {
|
|
|
|
+ sysOrg = orgMap.get(key);
|
|
|
|
+ }
|
|
|
|
+ if (Objects.isNull(sysOrg)) {
|
|
|
|
+ excelErrorTemp.add(new ExcelError(row, "excel第" + sheet + "个sheet第" + row + "行[" + cloumnName + "]不存在"));
|
|
|
|
+ } else {
|
|
|
|
+ SysOrg finalSysOrg = sysOrg;
|
|
|
|
+ orgMap.computeIfAbsent(key, v -> finalSysOrg);
|
|
|
|
+ }
|
|
|
|
+ return sysOrg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 验证课程是否存在
|
|
|
|
+ *
|
|
|
|
+ * @param courseMap
|
|
|
|
+ * @param key
|
|
|
|
+ * @param schoolId
|
|
|
|
+ * @param value
|
|
|
|
+ * @param excelErrorTemp
|
|
|
|
+ * @param row
|
|
|
|
+ * @param sheet
|
|
|
|
+ * @param cloumnName
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private BasicCourse validBasicCourseExists(Map<String, BasicCourse> courseMap,
|
|
|
|
+ String key,
|
|
|
|
+ Long schoolId,
|
|
|
|
+ String value,
|
|
|
|
+ List<ExcelError> excelErrorTemp,
|
|
|
|
+ int row,
|
|
|
|
+ int sheet,
|
|
|
|
+ String cloumnName) {
|
|
|
|
+ BasicCourse basicCourse = null;
|
|
|
|
+ if (!courseMap.containsKey(key)) {//不存在查询
|
|
|
|
+ QueryWrapper<BasicCourse> basicCourseQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ basicCourseQueryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId)
|
|
|
|
+ .eq(BasicCourse::getName, key)
|
|
|
|
+ .eq(BasicCourse::getCode, value)
|
|
|
|
+ .eq(BasicCourse::getEnable, true);
|
|
|
|
+ basicCourse = basicCourseService.getOne(basicCourseQueryWrapper);
|
|
|
|
+ } else {
|
|
|
|
+ basicCourse = courseMap.get(key);
|
|
|
|
+ }
|
|
|
|
+ if (Objects.isNull(basicCourse)) {
|
|
|
|
+ excelErrorTemp.add(new ExcelError(row, "excel第" + sheet + "个sheet第" + row + "行[" + cloumnName + "]不存在"));
|
|
|
|
+ } else {
|
|
|
|
+ BasicCourse finalBasicCourse = basicCourse;
|
|
|
|
+ courseMap.computeIfAbsent(key, v -> finalBasicCourse);
|
|
|
|
+ }
|
|
|
|
+ return basicCourse;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 验证用户是否存在
|
|
|
|
+ *
|
|
|
|
+ * @param userMap
|
|
|
|
+ * @param key
|
|
|
|
+ * @param schoolId
|
|
|
|
+ * @param excelErrorTemp
|
|
|
|
+ * @param row
|
|
|
|
+ * @param sheet
|
|
|
|
+ * @param cloumnName
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private SysUser validSysUserExists(Map<String, SysUser> userMap,
|
|
|
|
+ String key,
|
|
|
|
+ Long schoolId,
|
|
|
|
+ List<ExcelError> excelErrorTemp,
|
|
|
|
+ int row,
|
|
|
|
+ int sheet,
|
|
|
|
+ String cloumnName) {
|
|
|
|
+ SysUser sysUser = null;
|
|
|
|
+ if (!userMap.containsKey(key)) {//不存在查询
|
|
|
|
+ QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ sysUserQueryWrapper.lambda().eq(SysUser::getSchoolId, schoolId)
|
|
|
|
+ .eq(SysUser::getRealName, key)
|
|
|
|
+ .eq(SysUser::getEnable, true);
|
|
|
|
+ sysUser = sysUserService.getOne(sysUserQueryWrapper);
|
|
|
|
+ } else {
|
|
|
|
+ sysUser = userMap.get(key);
|
|
|
|
+ }
|
|
|
|
+ if (Objects.isNull(sysUser)) {
|
|
|
|
+ excelErrorTemp.add(new ExcelError(row, "excel第" + sheet + "个sheet第" + row + "行[" + cloumnName + "]不存在"));
|
|
|
|
+ } else {
|
|
|
|
+ SysUser finalSysUser = sysUser;
|
|
|
|
+ userMap.computeIfAbsent(key, v -> finalSysUser);
|
|
|
|
+ }
|
|
|
|
+ return sysUser;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 验证课程是否存在
|
|
|
|
+ *
|
|
|
|
+ * @param clazzMap
|
|
|
|
+ * @param key
|
|
|
|
+ * @param schoolId
|
|
|
|
+ * @param excelErrorTemp
|
|
|
|
+ * @param row
|
|
|
|
+ * @param sheet
|
|
|
|
+ * @param cloumnName
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private BasicClazz validBasicClazzExists(Map<String, BasicClazz> clazzMap,
|
|
|
|
+ String key,
|
|
|
|
+ Long schoolId,
|
|
|
|
+ List<ExcelError> excelErrorTemp,
|
|
|
|
+ int row,
|
|
|
|
+ int sheet,
|
|
|
|
+ String cloumnName) {
|
|
|
|
+ BasicClazz basicClazz = null;
|
|
|
|
+ if (!clazzMap.containsKey(key)) {//不存在查询
|
|
|
|
+ QueryWrapper<BasicClazz> basicClazzQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ basicClazzQueryWrapper.lambda().eq(BasicClazz::getSchoolId, schoolId)
|
|
|
|
+ .eq(BasicClazz::getClazzName, key)
|
|
|
|
+ .eq(BasicClazz::getEnable, true);
|
|
|
|
+ basicClazz = basicClazzService.getOne(basicClazzQueryWrapper);
|
|
|
|
+ } else {
|
|
|
|
+ basicClazz = clazzMap.get(key);
|
|
|
|
+ }
|
|
|
|
+ if (Objects.isNull(basicClazz)) {
|
|
|
|
+ excelErrorTemp.add(new ExcelError(row, "excel第" + sheet + "个sheet第" + row + "行[" + cloumnName + "]不存在"));
|
|
|
|
+ } else {
|
|
|
|
+ BasicClazz finalBasicClazz = basicClazz;
|
|
|
|
+ clazzMap.computeIfAbsent(key, v -> finalBasicClazz);
|
|
|
|
+ }
|
|
|
|
+ return basicClazz;
|
|
|
|
+ }
|
|
}
|
|
}
|