|
|
@@ -5,11 +5,9 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
@@ -21,8 +19,6 @@ import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.utils.RedisUtil;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
|
-import com.xjrsoft.module.base.entity.BaseCourseSubject;
|
|
|
-import com.xjrsoft.module.base.entity.CourseSubjectDetail;
|
|
|
import com.xjrsoft.module.hikvision.util.DataUtil;
|
|
|
import com.xjrsoft.module.organization.entity.*;
|
|
|
import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
|
|
|
@@ -40,10 +36,7 @@ import com.xjrsoft.module.teacher.dto.UpdateXjrUserDto;
|
|
|
import com.xjrsoft.module.teacher.entity.*;
|
|
|
import com.xjrsoft.module.teacher.mapper.*;
|
|
|
import com.xjrsoft.module.teacher.service.ITeacherbaseManagerService;
|
|
|
-import com.xjrsoft.module.teacher.vo.ProfessionalTitleImportVo;
|
|
|
-import com.xjrsoft.module.teacher.vo.XjrUserPageVo;
|
|
|
-import com.xjrsoft.module.veb.util.ImportExcelUtil;
|
|
|
-import com.xjrsoft.module.veb.vo.BaseCourseSubjectImportVo;
|
|
|
+import com.xjrsoft.module.teacher.vo.*;
|
|
|
import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
|
|
|
import com.xjrsoft.module.workflow.mapper.WorkflowFormRelationMapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -60,12 +53,13 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.xjrsoft.module.veb.util.ImportExcelUtil.isRequiredFieldsFilled;
|
|
|
-import static com.xjrsoft.module.veb.util.ImportExcelUtil.validateAndSetDictionaryField;
|
|
|
|
|
|
/**
|
|
|
* @title: service
|
|
|
@@ -104,6 +98,14 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
|
|
|
private WorkflowFormRelationMapper workflowFormRelationMapper;
|
|
|
|
|
|
private ProfessionalTitleMapper professionalTitleMapper;
|
|
|
+ private TeacherCertificationMapper teacherCertificationMapper;
|
|
|
+ private EvaluatorInformationMapper evaluatorInformationMapper;
|
|
|
+ private LanguageCompetenceMapper languageCompetenceMapper;
|
|
|
+ private FacultyContractMapper facultyContractMapper;
|
|
|
+ private OutsideAssociationsMapper outsideAssociationsMapper;
|
|
|
+ private CoreTeacherMapper coreTeacherMapper;
|
|
|
+ private ScientificResearchMapper scientificResearchMapper;
|
|
|
+ private JobInformationMapper jobInformationMapper;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -923,137 +925,805 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String professionalTitle(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- List<ProfessionalTitleImportVo> excelDataList = EasyExcel.read(file.getInputStream()).headRowNumber(1).head(ProfessionalTitleImportVo.class).sheet().doReadSync();
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
+ // 读取 Excel 数据
|
|
|
+ List<ProfessionalTitleImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(ProfessionalTitleImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
|
|
|
- // 获取所有的教职工
|
|
|
- MPJLambdaWrapper<XjrUser> xjrUserMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
- xjrUserMPJLambdaWrapper
|
|
|
- .select(XjrUser::getId)
|
|
|
- .select(XjrUser::getUserName, XjrUser::getUserName)
|
|
|
- .select(XjrUser::getName, XjrUser::getName)
|
|
|
- .select(" (SELECT GROUP_CONCAT(a.id) FROM xjr_department a" +
|
|
|
- " INNER JOIN xjr_user_dept_relation b ON a.id = b.dept_id" +
|
|
|
- " WHERE a.delete_mark = 0 AND b.user_id = t.id) as code")
|
|
|
- .innerJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
|
|
|
- .eq(UserRoleRelation::getRoleId, 2)
|
|
|
- ;
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
- List<XjrUser> xjrUsers = this.selectJoinList(XjrUser.class, xjrUserMPJLambdaWrapper);
|
|
|
- // 根据姓名和工号映射
|
|
|
- Map<String, XjrUser> mapByUsernameAndName = xjrUsers.stream()
|
|
|
- .collect(Collectors.toMap(u -> u.getUserName() + "-" + u.getName(), u -> u, (u1, u2) -> u1));
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
|
|
|
if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
sb.append("系统教职工数据有误,请联系管理员");
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
- List<ProfessionalTitle> oldProfessionalTitles = professionalTitleMapper.selectList(Wrappers.lambdaQuery(ProfessionalTitle.class)
|
|
|
- .eq(ProfessionalTitle::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ // 获取现有职称数据
|
|
|
+ List<ProfessionalTitle> oldList = professionalTitleMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(ProfessionalTitle.class)
|
|
|
+ .eq(ProfessionalTitle::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
);
|
|
|
|
|
|
- // 先根据用户分组,再根据
|
|
|
- Map<Long, Map<String, ProfessionalTitle>> mapByUserIdThenNo = oldProfessionalTitles.stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- ProfessionalTitle::getUserId, // 第一级分组:按 userId 分组
|
|
|
- Collectors.toMap(
|
|
|
- ProfessionalTitle::getProfessionalTitleNo, // 第二级分组的键:professionalTitleNo
|
|
|
- pt -> pt // 第二级分组的值:整个 ProfessionalTitle 对象
|
|
|
- )
|
|
|
- ));
|
|
|
-
|
|
|
- List<ProfessionalTitle> professionalTitles = new ArrayList<>();
|
|
|
- ProfessionalTitle insert;
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<String, ProfessionalTitle>> mapByUserIdThenNo = groupByUserIdAndKey(
|
|
|
+ oldList,
|
|
|
+ ProfessionalTitle::getUserId,
|
|
|
+ ProfessionalTitle::getProfessionalTitleNo
|
|
|
+ );
|
|
|
+
|
|
|
+ // 新增和更新列表
|
|
|
+ List<ProfessionalTitle> inserts = new ArrayList<>();
|
|
|
+ List<ProfessionalTitle> updates = new ArrayList<>();
|
|
|
for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
ProfessionalTitleImportVo vo = excelDataList.get(i);
|
|
|
- if (isRequiredFieldsFilled(vo,
|
|
|
- sb,
|
|
|
- i + 1)) {
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
- XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "-" + vo.getName());
|
|
|
- if (ObjectUtils.isEmpty(user)) {
|
|
|
- sb
|
|
|
- .append("第")
|
|
|
- .append(i + 1)
|
|
|
- .append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ // 查找对应的教职工
|
|
|
+ XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "&" + vo.getUserIdCn());
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
- insert = new ProfessionalTitle();
|
|
|
- BeanUtils.copyProperties(vo, insert);
|
|
|
- insert.setUserId(user.getId());
|
|
|
- insert.setDeptId(user.getCode());
|
|
|
-
|
|
|
+ // 转换在职状态
|
|
|
+ String jobStatus = StringUtils.isNotEmpty(vo.getJobStatus()) && "是".equals(vo.getJobStatus()) ? "1" : "0";
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<String, ProfessionalTitle> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ ProfessionalTitle existing = existingMap.get(vo.getProfessionalTitleNo());
|
|
|
+
|
|
|
+ ProfessionalTitle insertOrUpdate = new ProfessionalTitle();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+ insertOrUpdate.setJobStatus(jobStatus);
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- professionalTitles.add(insert);
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (ProfessionalTitle insert : inserts) {
|
|
|
+ professionalTitleMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (ProfessionalTitle update : updates) {
|
|
|
+ professionalTitleMapper.updateById(update);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-// //批量新增
|
|
|
-// if (!professionalTitles.isEmpty()) {
|
|
|
-// for (BaseCourseSubject baseCourseSubject : baseCourseSubjects) {
|
|
|
-// baseCourseSubjectMapper.insert(baseCourseSubject);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (!courseSubjectDetails.isEmpty()) {
|
|
|
-// for (CourseSubjectDetail courseSubjectDetail : courseSubjectDetails) {
|
|
|
-// courseSubjectDetailMapper.insert(courseSubjectDetail);
|
|
|
-// }
|
|
|
-// }
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String teacherCertification(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- return "";
|
|
|
+ List<TeacherCertificationImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(TeacherCertificationImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
+
|
|
|
+ if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
+ sb.append("系统教职工数据有误,请联系管理员");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TeacherCertification> oldList = teacherCertificationMapper.selectList(Wrappers.lambdaQuery(TeacherCertification.class)
|
|
|
+ .eq(TeacherCertification::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<String, TeacherCertification>> mapByUserIdThenNo = groupByUserIdAndKey(
|
|
|
+ oldList,
|
|
|
+ TeacherCertification::getUserId,
|
|
|
+ TeacherCertification::getCertificationNo
|
|
|
+ );
|
|
|
+
|
|
|
+ List<TeacherCertification> inserts = new ArrayList<>();
|
|
|
+ List<TeacherCertification> updates = new ArrayList<>();
|
|
|
+ for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
+ TeacherCertificationImportVo vo = excelDataList.get(i);
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "&" + vo.getUserIdCn());
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<String, TeacherCertification> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ TeacherCertification existing = existingMap.get(vo.getCertificationNo());
|
|
|
+
|
|
|
+ TeacherCertification insertOrUpdate = new TeacherCertification();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (TeacherCertification insert : inserts) {
|
|
|
+ teacherCertificationMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (TeacherCertification update : updates) {
|
|
|
+ teacherCertificationMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String evaluatorInformation(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- return "";
|
|
|
+ List<EvaluatorInformationImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(EvaluatorInformationImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
+
|
|
|
+ if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
+ sb.append("系统教职工数据有误,请联系管理员");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<EvaluatorInformation> oldList = evaluatorInformationMapper.selectList(Wrappers.lambdaQuery(EvaluatorInformation.class)
|
|
|
+ .eq(EvaluatorInformation::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<String, EvaluatorInformation>> mapByUserIdThenNo = groupByUserIdAndKey(
|
|
|
+ oldList,
|
|
|
+ EvaluatorInformation::getUserId,
|
|
|
+ EvaluatorInformation::getCertificationNo
|
|
|
+ );
|
|
|
+
|
|
|
+ List<EvaluatorInformation> inserts = new ArrayList<>();
|
|
|
+ List<EvaluatorInformation> updates = new ArrayList<>();
|
|
|
+ for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
+ EvaluatorInformationImportVo vo = excelDataList.get(i);
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "&" + vo.getUserIdCn());
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<String, EvaluatorInformation> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ EvaluatorInformation existing = existingMap.get(vo.getCertificationNo());
|
|
|
+
|
|
|
+ EvaluatorInformation insertOrUpdate = new EvaluatorInformation();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (EvaluatorInformation insert : inserts) {
|
|
|
+ evaluatorInformationMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (EvaluatorInformation update : updates) {
|
|
|
+ evaluatorInformationMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String languageCompetence(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- return "";
|
|
|
+ List<LanguageCompetenceImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(EvaluatorInformationImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
+
|
|
|
+ if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
+ sb.append("系统教职工数据有误,请联系管理员");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LanguageCompetence> oldList = languageCompetenceMapper.selectList(Wrappers.lambdaQuery(LanguageCompetence.class)
|
|
|
+ .eq(LanguageCompetence::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<String, LanguageCompetence>> mapByUserIdThenNo = groupByUserIdAndKey(
|
|
|
+ oldList,
|
|
|
+ LanguageCompetence::getUserId,
|
|
|
+ LanguageCompetence::getCertificationNo
|
|
|
+ );
|
|
|
+
|
|
|
+ List<LanguageCompetence> inserts = new ArrayList<>();
|
|
|
+ List<LanguageCompetence> updates = new ArrayList<>();
|
|
|
+ for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
+ LanguageCompetenceImportVo vo = excelDataList.get(i);
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "&" + vo.getUserIdCn());
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<String, LanguageCompetence> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ LanguageCompetence existing = existingMap.get(vo.getCertificationNo());
|
|
|
+
|
|
|
+ LanguageCompetence insertOrUpdate = new LanguageCompetence();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (LanguageCompetence insert : inserts) {
|
|
|
+ languageCompetenceMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (LanguageCompetence update : updates) {
|
|
|
+ languageCompetenceMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String facultyContract(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- return "";
|
|
|
+ List<FacultyContractImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(FacultyContractImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
+
|
|
|
+ if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
+ sb.append("系统教职工数据有误,请联系管理员");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FacultyContract> oldList = facultyContractMapper.selectList(Wrappers.lambdaQuery(FacultyContract.class)
|
|
|
+ .eq(FacultyContract::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<LocalDate, FacultyContract>> mapByUserIdThenNo = oldList.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ FacultyContract::getUserId,
|
|
|
+ Collectors.toMap(
|
|
|
+ FacultyContract::getStartDate,
|
|
|
+ record -> record,
|
|
|
+ (existing, replacement) -> existing // 如果有重复键,保留第一个值
|
|
|
+ )
|
|
|
+ ));
|
|
|
+
|
|
|
+ List<FacultyContract> inserts = new ArrayList<>();
|
|
|
+ List<FacultyContract> updates = new ArrayList<>();
|
|
|
+ for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
+ FacultyContractImportVo vo = excelDataList.get(i);
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "&" + vo.getUserIdCn());
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<LocalDate, FacultyContract> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ FacultyContract existing = existingMap.get(vo.getStartDate());
|
|
|
+
|
|
|
+ FacultyContract insertOrUpdate = new FacultyContract();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (FacultyContract insert : inserts) {
|
|
|
+ facultyContractMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (FacultyContract update : updates) {
|
|
|
+ facultyContractMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String outsideAssociations(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- return "";
|
|
|
+ List<OutsideAssociationsImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(OutsideAssociationsImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
+
|
|
|
+ if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
+ sb.append("系统教职工数据有误,请联系管理员");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<OutsideAssociations> oldList = outsideAssociationsMapper.selectList(Wrappers.lambdaQuery(OutsideAssociations.class)
|
|
|
+ .eq(OutsideAssociations::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<String, OutsideAssociations>> mapByUserIdThenNo = groupByUserIdAndKey(
|
|
|
+ oldList,
|
|
|
+ OutsideAssociations::getUserId,
|
|
|
+ OutsideAssociations::getName
|
|
|
+ );
|
|
|
+
|
|
|
+ List<OutsideAssociations> inserts = new ArrayList<>();
|
|
|
+ List<OutsideAssociations> updates = new ArrayList<>();
|
|
|
+ for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
+ OutsideAssociationsImportVo vo = excelDataList.get(i);
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "&" + vo.getUserIdCn());
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<String, OutsideAssociations> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ OutsideAssociations existing = existingMap.get(vo.getName());
|
|
|
+
|
|
|
+ OutsideAssociations insertOrUpdate = new OutsideAssociations();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (OutsideAssociations insert : inserts) {
|
|
|
+ outsideAssociationsMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (OutsideAssociations update : updates) {
|
|
|
+ outsideAssociationsMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String coreTeacher(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- return "";
|
|
|
+ List<CoreTeacherImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(CoreTeacherImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
+
|
|
|
+ if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
+ sb.append("系统教职工数据有误,请联系管理员");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CoreTeacher> oldList = coreTeacherMapper.selectList(Wrappers.lambdaQuery(CoreTeacher.class)
|
|
|
+ .eq(CoreTeacher::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<String, CoreTeacher>> mapByUserIdThenNo = groupByUserIdAndKey(
|
|
|
+ oldList,
|
|
|
+ CoreTeacher::getUserId,
|
|
|
+ CoreTeacher::getCertificationNo
|
|
|
+ );
|
|
|
+
|
|
|
+ List<CoreTeacher> inserts = new ArrayList<>();
|
|
|
+ List<CoreTeacher> updates = new ArrayList<>();
|
|
|
+ for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
+ CoreTeacherImportVo vo = excelDataList.get(i);
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "&" + vo.getUserIdCn());
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<String, CoreTeacher> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ CoreTeacher existing = existingMap.get(vo.getCertificationNo());
|
|
|
+
|
|
|
+ CoreTeacher insertOrUpdate = new CoreTeacher();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (CoreTeacher insert : inserts) {
|
|
|
+ coreTeacherMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (CoreTeacher update : updates) {
|
|
|
+ coreTeacherMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String scientificResearch(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- return "";
|
|
|
+ List<ScientificResearchImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(ScientificResearchImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
+
|
|
|
+ if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
+ sb.append("系统教职工数据有误,请联系管理员");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ScientificResearch> oldList = scientificResearchMapper.selectList(Wrappers.lambdaQuery(ScientificResearch.class)
|
|
|
+ .eq(ScientificResearch::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<String, ScientificResearch>> mapByUserIdThenNo = groupByUserIdAndKey(
|
|
|
+ oldList,
|
|
|
+ ScientificResearch::getUserId,
|
|
|
+ ScientificResearch::getName
|
|
|
+ );
|
|
|
+
|
|
|
+ List<ScientificResearch> inserts = new ArrayList<>();
|
|
|
+ List<ScientificResearch> updates = new ArrayList<>();
|
|
|
+ for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
+ ScientificResearchImportVo vo = excelDataList.get(i);
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ XjrUser user = mapByUsernameAndName.get(vo.getUserName() + "&" + vo.getUserIdCn());
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<String, ScientificResearch> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ ScientificResearch existing = existingMap.get(vo.getName());
|
|
|
+
|
|
|
+ ScientificResearch insertOrUpdate = new ScientificResearch();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (ScientificResearch insert : inserts) {
|
|
|
+ scientificResearchMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (ScientificResearch update : updates) {
|
|
|
+ scientificResearchMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String jobInformation(MultipartFile file) throws IOException, IllegalAccessException {
|
|
|
- return "";
|
|
|
+ List<JobInformationImportVo> excelDataList = EasyExcel.read(file.getInputStream())
|
|
|
+ .headRowNumber(1)
|
|
|
+ .head(JobInformationImportVo.class)
|
|
|
+ .sheet()
|
|
|
+ .doReadSync();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, XjrUser> mapByUsernameAndName = getUserMap();
|
|
|
+
|
|
|
+ if (MapUtils.isEmpty(mapByUsernameAndName)) {
|
|
|
+ sb.append("系统教职工数据有误,请联系管理员");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<JobInformation> oldList = jobInformationMapper.selectList(Wrappers.lambdaQuery(JobInformation.class)
|
|
|
+ .eq(JobInformation::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 分组处理现有数据
|
|
|
+ Map<Long, Map<String, JobInformation>> mapByUserIdThenNo = groupByUserIdAndKey(
|
|
|
+ oldList,
|
|
|
+ JobInformation::getUserId,
|
|
|
+ JobInformation::getJobName
|
|
|
+ );
|
|
|
+
|
|
|
+ List<JobInformation> inserts = new ArrayList<>();
|
|
|
+ List<JobInformation> updates = new ArrayList<>();
|
|
|
+ for (int i = 0; i < excelDataList.size(); i++) {
|
|
|
+ JobInformationImportVo vo = excelDataList.get(i);
|
|
|
+
|
|
|
+ // 检查必填字段是否为空
|
|
|
+ if (isRequiredFieldsFilled(vo, sb, i + 2)) {
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = vo.getUserName() + "&" + vo.getUserIdCn();
|
|
|
+ XjrUser user = mapByUsernameAndName.get(key);
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ sb.append("第").append(i + 2).append("行工号和姓名对应的教职工不存在,请核实");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否需要新增或更新
|
|
|
+ Map<String, JobInformation> existingMap = mapByUserIdThenNo.getOrDefault(user.getId(), Collections.emptyMap());
|
|
|
+ JobInformation existing = existingMap.get(vo.getJobName());
|
|
|
+
|
|
|
+ JobInformation insertOrUpdate = new JobInformation();
|
|
|
+ BeanUtils.copyProperties(vo, insertOrUpdate);
|
|
|
+ insertOrUpdate.setUserId(user.getId());
|
|
|
+ insertOrUpdate.setDeptId(user.getCode());
|
|
|
+
|
|
|
+ if (existing != null) {
|
|
|
+ // 更新已有记录
|
|
|
+ insertOrUpdate.setId(existing.getId());
|
|
|
+ insertOrUpdate.setModifyDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ updates.add(insertOrUpdate);
|
|
|
+ } else {
|
|
|
+ // 新增记录
|
|
|
+ insertOrUpdate.setCreateDate(LocalDateTime.now());
|
|
|
+ insertOrUpdate.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ inserts.add(insertOrUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量新增
|
|
|
+ if (!inserts.isEmpty()) {
|
|
|
+ for (JobInformation insert : inserts) {
|
|
|
+ jobInformationMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!updates.isEmpty()) {
|
|
|
+ for (JobInformation update : updates) {
|
|
|
+ jobInformationMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
|
|
|
-// public String jobInformation(MultipartFile file) {
|
|
|
-// return "";
|
|
|
-// }
|
|
|
+ /**
|
|
|
+ * 获取教职工数据并映射为 Map
|
|
|
+ */
|
|
|
+ private Map<String, XjrUser> getUserMap() {
|
|
|
+ // 获取所有教职工数据
|
|
|
+ MPJLambdaWrapper<XjrUser> userQueryWrapper = new MPJLambdaWrapper<>();
|
|
|
+ userQueryWrapper
|
|
|
+ .select(XjrUser::getId, XjrUser::getUserName, XjrUser::getName)
|
|
|
+ .select(" (SELECT GROUP_CONCAT(a.name) FROM xjr_department a" +
|
|
|
+ " INNER JOIN xjr_user_dept_relation b ON a.id = b.dept_id" +
|
|
|
+ " WHERE a.delete_mark = 0 AND b.user_id = t.id) as code")
|
|
|
+ .innerJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
|
|
|
+ .eq(UserRoleRelation::getRoleId, 2);
|
|
|
+
|
|
|
+ List<XjrUser> xjrUsers = this.selectJoinList(XjrUser.class, userQueryWrapper);
|
|
|
+
|
|
|
+ // 如果有重复键,保留第一个值
|
|
|
+ return xjrUsers.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ u -> u.getUserName() + "&" + u.getName(),
|
|
|
+ u -> u,
|
|
|
+ (u1, u2) -> u1 // 如果有重复键,保留第一个值
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分组现有记录
|
|
|
+ */
|
|
|
+ private <T> Map<Long, Map<String, T>> groupByUserIdAndKey(
|
|
|
+ List<T> records,
|
|
|
+ Function<T, Long> userIdGetter,
|
|
|
+ Function<T, String> keyGetter
|
|
|
+ ) {
|
|
|
+ return records.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ userIdGetter,
|
|
|
+ Collectors.toMap(
|
|
|
+ keyGetter,
|
|
|
+ record -> record,
|
|
|
+ (existing, replacement) -> existing // 如果有重复键,保留第一个值
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ }
|
|
|
}
|