完善招聘信息主键关联与工作经历维护
This commit is contained in:
@@ -69,9 +69,9 @@ public class CcdiStaffRecruitmentController extends BaseController {
|
||||
*/
|
||||
@Operation(summary = "获取招聘信息详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffRecruitment:query')")
|
||||
@GetMapping(value = "/{recruitId}")
|
||||
public AjaxResult getInfo(@PathVariable String recruitId) {
|
||||
return success(recruitmentService.selectRecruitmentById(recruitId));
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable Long id) {
|
||||
return success(recruitmentService.selectRecruitmentById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,9 +102,9 @@ public class CcdiStaffRecruitmentController extends BaseController {
|
||||
@Operation(summary = "删除招聘信息")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffRecruitment:remove')")
|
||||
@Log(title = "员工招聘信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{recruitIds}")
|
||||
public AjaxResult remove(@PathVariable String[] recruitIds) {
|
||||
return toAjax(recruitmentService.deleteRecruitmentByIds(recruitIds));
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(recruitmentService.deleteRecruitmentByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,8 +22,11 @@ public class CcdiStaffRecruitment implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 招聘记录编号 */
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String recruitId;
|
||||
|
||||
/** 招聘项目名称 */
|
||||
|
||||
@@ -28,6 +28,9 @@ public class CcdiStaffRecruitmentWork implements Serializable {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 关联招聘信息主键ID */
|
||||
private Long recruitmentId;
|
||||
|
||||
/** 关联招聘记录编号 */
|
||||
private String recruitId;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.info.collection.domain.dto;
|
||||
import com.ruoyi.info.collection.annotation.EnumValid;
|
||||
import com.ruoyi.info.collection.enums.AdmitStatus;
|
||||
import com.ruoyi.info.collection.enums.RecruitType;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -10,6 +11,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工招聘信息新增DTO
|
||||
@@ -102,4 +104,8 @@ public class CcdiStaffRecruitmentAddDTO implements Serializable {
|
||||
/** 面试官2工号 */
|
||||
@Size(max = 10, message = "面试官2工号长度不能超过10个字符")
|
||||
private String interviewerId2;
|
||||
|
||||
/** 历史工作经历列表 */
|
||||
@Valid
|
||||
private List<CcdiStaffRecruitmentWorkEditDTO> workExperienceList;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,13 @@ public class CcdiStaffRecruitmentEditDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@NotNull(message = "招聘信息ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/** 招聘记录编号 */
|
||||
@NotNull(message = "招聘记录编号不能为空")
|
||||
@NotBlank(message = "招聘记录编号不能为空")
|
||||
@Size(max = 32, message = "招聘记录编号长度不能超过32个字符")
|
||||
private String recruitId;
|
||||
|
||||
/** 招聘项目名称 */
|
||||
|
||||
@@ -19,6 +19,9 @@ public class CcdiStaffRecruitmentVO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 招聘记录编号 */
|
||||
private String recruitId;
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ public interface CcdiStaffRecruitmentMapper extends BaseMapper<CcdiStaffRecruitm
|
||||
/**
|
||||
* 查询招聘信息详情
|
||||
*
|
||||
* @param recruitId 招聘项目编号
|
||||
* @param id 主键ID
|
||||
* @return 招聘信息VO
|
||||
*/
|
||||
CcdiStaffRecruitmentVO selectRecruitmentById(@Param("recruitId") String recruitId);
|
||||
CcdiStaffRecruitmentVO selectRecruitmentById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 批量插入招聘信息数据
|
||||
|
||||
@@ -46,10 +46,10 @@ public interface ICcdiStaffRecruitmentService {
|
||||
/**
|
||||
* 查询招聘信息详情
|
||||
*
|
||||
* @param recruitId 招聘项目编号
|
||||
* @param id 主键ID
|
||||
* @return 招聘信息VO
|
||||
*/
|
||||
CcdiStaffRecruitmentVO selectRecruitmentById(String recruitId);
|
||||
CcdiStaffRecruitmentVO selectRecruitmentById(Long id);
|
||||
|
||||
/**
|
||||
* 新增招聘信息
|
||||
@@ -70,10 +70,10 @@ public interface ICcdiStaffRecruitmentService {
|
||||
/**
|
||||
* 批量删除招聘信息
|
||||
*
|
||||
* @param recruitIds 需要删除的招聘项目编号
|
||||
* @param ids 需要删除的招聘信息ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRecruitmentByIds(String[] recruitIds);
|
||||
int deleteRecruitmentByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导入招聘信息数据
|
||||
|
||||
@@ -165,12 +165,8 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
return new MainImportResult(Collections.emptyMap(), 0);
|
||||
}
|
||||
|
||||
Set<String> existingRecruitIds = getExistingRecruitIds(
|
||||
mainRows.stream().map(MainImportRow::data).toList()
|
||||
);
|
||||
Set<String> processedRecruitIds = new HashSet<>();
|
||||
List<CcdiStaffRecruitment> newRecords = new ArrayList<>();
|
||||
Map<String, CcdiStaffRecruitment> importedRecruitmentMap = new LinkedHashMap<>();
|
||||
Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> importedRecruitmentMap = new LinkedHashMap<>();
|
||||
int successCount = 0;
|
||||
|
||||
for (int index = 0; index < mainRows.size(); index++) {
|
||||
MainImportRow mainRow = mainRows.get(index);
|
||||
@@ -183,31 +179,17 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
validateRecruitmentData(addDTO, mainRow.sheetRowNum());
|
||||
|
||||
String recruitId = trim(excel.getRecruitId());
|
||||
if (existingRecruitIds.contains(recruitId)) {
|
||||
throw buildValidationException(
|
||||
MAIN_SHEET_NAME,
|
||||
List.of(mainRow.sheetRowNum()),
|
||||
String.format("招聘记录编号[%s]已存在,请勿重复导入", recruitId)
|
||||
);
|
||||
}
|
||||
if (!processedRecruitIds.add(recruitId)) {
|
||||
throw buildValidationException(
|
||||
MAIN_SHEET_NAME,
|
||||
List.of(mainRow.sheetRowNum()),
|
||||
String.format("招聘记录编号[%s]在导入文件中重复,已跳过此条记录", recruitId)
|
||||
);
|
||||
}
|
||||
|
||||
CcdiStaffRecruitment recruitment = new CcdiStaffRecruitment();
|
||||
BeanUtils.copyProperties(excel, recruitment);
|
||||
recruitment.setRecruitId(recruitId);
|
||||
recruitment.setRecruitType(addDTO.getRecruitType());
|
||||
recruitment.setCreatedBy(userName);
|
||||
recruitment.setUpdatedBy(userName);
|
||||
newRecords.add(recruitment);
|
||||
importedRecruitmentMap.put(recruitId, recruitment);
|
||||
recruitmentMapper.insert(recruitment);
|
||||
successCount++;
|
||||
addRecruitment(importedRecruitmentMap, recruitment);
|
||||
|
||||
ImportLogUtils.logProgress(log, taskId, index + 1, mainRows.size(), newRecords.size(), failures.size());
|
||||
ImportLogUtils.logProgress(log, taskId, index + 1, mainRows.size(), successCount, failures.size());
|
||||
} catch (Exception exception) {
|
||||
FailureMeta failureMeta = resolveFailureMeta(exception, List.of(mainRow.sheetRowNum()), MAIN_SHEET_NAME);
|
||||
failures.add(buildFailure(excel, failureMeta.sheetName(), failureMeta.sheetRowNum(), exception.getMessage()));
|
||||
@@ -221,16 +203,11 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
}
|
||||
}
|
||||
|
||||
if (!newRecords.isEmpty()) {
|
||||
ImportLogUtils.logBatchOperationStart(log, taskId, "插入招聘信息", (newRecords.size() + 499) / 500, 500);
|
||||
saveBatch(newRecords, 500);
|
||||
}
|
||||
|
||||
return new MainImportResult(importedRecruitmentMap, newRecords.size());
|
||||
return new MainImportResult(importedRecruitmentMap, successCount);
|
||||
}
|
||||
|
||||
private int importWorkSheet(List<WorkImportRow> workRows,
|
||||
Map<String, CcdiStaffRecruitment> importedRecruitmentMap,
|
||||
Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> importedRecruitmentMap,
|
||||
List<RecruitmentImportFailureVO> failures,
|
||||
String userName,
|
||||
String taskId) {
|
||||
@@ -238,7 +215,7 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
return 0;
|
||||
}
|
||||
|
||||
Map<String, CcdiStaffRecruitment> existingRecruitmentMap =
|
||||
Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> existingRecruitmentMap =
|
||||
getExistingRecruitmentMap(workRows, importedRecruitmentMap);
|
||||
Map<String, List<WorkImportRow>> groupedRows = groupWorkRows(workRows);
|
||||
int successCount = 0;
|
||||
@@ -248,15 +225,18 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
processedGroups++;
|
||||
WorkImportRow firstRow = recruitWorkRows.get(0);
|
||||
String recruitId = trim(firstRow.data().getRecruitId());
|
||||
CcdiStaffRecruitment recruitment = importedRecruitmentMap.get(recruitId);
|
||||
if (recruitment == null) {
|
||||
recruitment = existingRecruitmentMap.get(recruitId);
|
||||
}
|
||||
|
||||
try {
|
||||
RecruitmentMatchKey matchKey = buildMatchKey(firstRow.data());
|
||||
CcdiStaffRecruitment recruitment = resolveMatchedRecruitment(
|
||||
matchKey,
|
||||
importedRecruitmentMap,
|
||||
existingRecruitmentMap,
|
||||
extractWorkRowNums(recruitWorkRows)
|
||||
);
|
||||
validateWorkGroup(recruitWorkRows, recruitment);
|
||||
|
||||
if (StringUtils.isNotEmpty(recruitId) && hasExistingWorkHistory(recruitId)) {
|
||||
if (recruitment != null && hasExistingWorkHistory(recruitment.getId())) {
|
||||
throw buildValidationException(
|
||||
WORK_SHEET_NAME,
|
||||
extractWorkRowNums(recruitWorkRows),
|
||||
@@ -264,7 +244,7 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
);
|
||||
}
|
||||
|
||||
List<CcdiStaffRecruitmentWork> entities = buildWorkEntities(recruitWorkRows, userName);
|
||||
List<CcdiStaffRecruitmentWork> entities = buildWorkEntities(recruitWorkRows, recruitment, userName);
|
||||
entities.forEach(entity -> recruitmentWorkMapper.insert(entity));
|
||||
successCount += recruitWorkRows.size();
|
||||
|
||||
@@ -299,33 +279,59 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
}
|
||||
|
||||
private String buildWorkGroupKey(WorkImportRow workRow) {
|
||||
String recruitId = trim(workRow.data().getRecruitId());
|
||||
if (StringUtils.isNotEmpty(recruitId)) {
|
||||
return recruitId;
|
||||
RecruitmentMatchKey key = buildMatchKey(workRow.data());
|
||||
if (key.isComplete()) {
|
||||
return key.value();
|
||||
}
|
||||
return "__ROW__" + workRow.sheetRowNum();
|
||||
}
|
||||
|
||||
private Map<String, CcdiStaffRecruitment> getExistingRecruitmentMap(List<WorkImportRow> workRows,
|
||||
Map<String, CcdiStaffRecruitment> importedRecruitmentMap) {
|
||||
private Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> getExistingRecruitmentMap(
|
||||
List<WorkImportRow> workRows,
|
||||
Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> importedRecruitmentMap
|
||||
) {
|
||||
LinkedHashSet<String> recruitIds = workRows.stream()
|
||||
.filter(row -> !importedRecruitmentMap.containsKey(buildMatchKey(row.data())))
|
||||
.map(row -> trim(row.data().getRecruitId()))
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.filter(recruitId -> !importedRecruitmentMap.containsKey(recruitId))
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
if (recruitIds.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<CcdiStaffRecruitment> recruitments = recruitmentMapper.selectBatchIds(recruitIds);
|
||||
return recruitments.stream().collect(Collectors.toMap(CcdiStaffRecruitment::getRecruitId, item -> item));
|
||||
List<CcdiStaffRecruitment> recruitments = selectRecruitmentsByRecruitIds(recruitIds);
|
||||
Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> result = new LinkedHashMap<>();
|
||||
recruitments.forEach(item -> addRecruitment(result, item));
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<CcdiStaffRecruitmentWork> buildWorkEntities(List<WorkImportRow> workRows, String userName) {
|
||||
private CcdiStaffRecruitment resolveMatchedRecruitment(
|
||||
RecruitmentMatchKey matchKey,
|
||||
Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> importedRecruitmentMap,
|
||||
Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> existingRecruitmentMap,
|
||||
List<Integer> rowNums
|
||||
) {
|
||||
List<CcdiStaffRecruitment> matchedRecruitments = new ArrayList<>();
|
||||
matchedRecruitments.addAll(importedRecruitmentMap.getOrDefault(matchKey, Collections.emptyList()));
|
||||
matchedRecruitments.addAll(existingRecruitmentMap.getOrDefault(matchKey, Collections.emptyList()));
|
||||
if (matchedRecruitments.size() > 1) {
|
||||
throw buildValidationException(
|
||||
WORK_SHEET_NAME,
|
||||
rowNums,
|
||||
String.format("招聘记录编号[%s]匹配到多条招聘主信息,无法确定历史工作经历归属", matchKey.recruitId())
|
||||
);
|
||||
}
|
||||
return matchedRecruitments.isEmpty() ? null : matchedRecruitments.get(0);
|
||||
}
|
||||
|
||||
private List<CcdiStaffRecruitmentWork> buildWorkEntities(List<WorkImportRow> workRows,
|
||||
CcdiStaffRecruitment recruitment,
|
||||
String userName) {
|
||||
List<CcdiStaffRecruitmentWork> entities = new ArrayList<>();
|
||||
for (WorkImportRow workRow : workRows) {
|
||||
CcdiStaffRecruitmentWork entity = new CcdiStaffRecruitmentWork();
|
||||
BeanUtils.copyProperties(workRow.data(), entity);
|
||||
entity.setRecruitId(trim(workRow.data().getRecruitId()));
|
||||
entity.setRecruitmentId(recruitment.getId());
|
||||
entity.setRecruitId(recruitment.getRecruitId());
|
||||
entity.setCreatedBy(userName);
|
||||
entity.setUpdatedBy(userName);
|
||||
entities.add(entity);
|
||||
@@ -333,29 +339,9 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
return entities;
|
||||
}
|
||||
|
||||
private Set<String> getExistingRecruitIds(List<CcdiStaffRecruitmentExcel> recruitmentList) {
|
||||
List<String> recruitIds = recruitmentList.stream()
|
||||
.map(CcdiStaffRecruitmentExcel::getRecruitId)
|
||||
.map(this::trim)
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.toList();
|
||||
|
||||
if (recruitIds.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<CcdiStaffRecruitment> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(CcdiStaffRecruitment::getRecruitId, recruitIds);
|
||||
List<CcdiStaffRecruitment> existingRecruitments = recruitmentMapper.selectList(wrapper);
|
||||
|
||||
return existingRecruitments.stream()
|
||||
.map(CcdiStaffRecruitment::getRecruitId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private boolean hasExistingWorkHistory(String recruitId) {
|
||||
private boolean hasExistingWorkHistory(Long recruitmentId) {
|
||||
LambdaQueryWrapper<CcdiStaffRecruitmentWork> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CcdiStaffRecruitmentWork::getRecruitId, recruitId);
|
||||
wrapper.eq(CcdiStaffRecruitmentWork::getRecruitmentId, recruitmentId);
|
||||
return recruitmentWorkMapper.selectCount(wrapper) > 0;
|
||||
}
|
||||
|
||||
@@ -568,30 +554,36 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
redisTemplate.opsForHash().putAll(key, statusData);
|
||||
}
|
||||
|
||||
private void saveBatch(List<CcdiStaffRecruitment> list, int batchSize) {
|
||||
for (int i = 0; i < list.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, list.size());
|
||||
List<CcdiStaffRecruitment> subList = list.subList(i, end);
|
||||
|
||||
List<String> recruitIds = subList.stream()
|
||||
.map(CcdiStaffRecruitment::getRecruitId)
|
||||
.toList();
|
||||
if (recruitIds.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<CcdiStaffRecruitment> existingRecords = recruitmentMapper.selectBatchIds(recruitIds);
|
||||
Set<String> existingIds = existingRecords.stream()
|
||||
.map(CcdiStaffRecruitment::getRecruitId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<CcdiStaffRecruitment> toInsert = subList.stream()
|
||||
.filter(record -> !existingIds.contains(record.getRecruitId()))
|
||||
.toList();
|
||||
if (!toInsert.isEmpty()) {
|
||||
recruitmentMapper.insertBatch(toInsert);
|
||||
}
|
||||
private List<CcdiStaffRecruitment> selectRecruitmentsByRecruitIds(Set<String> recruitIds) {
|
||||
if (recruitIds == null || recruitIds.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
LambdaQueryWrapper<CcdiStaffRecruitment> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(CcdiStaffRecruitment::getRecruitId, recruitIds);
|
||||
return recruitmentMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
private void addRecruitment(Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> map,
|
||||
CcdiStaffRecruitment recruitment) {
|
||||
map.computeIfAbsent(buildMatchKey(recruitment), key -> new ArrayList<>()).add(recruitment);
|
||||
}
|
||||
|
||||
private RecruitmentMatchKey buildMatchKey(CcdiStaffRecruitment recruitment) {
|
||||
return new RecruitmentMatchKey(
|
||||
trim(recruitment.getRecruitId()),
|
||||
trim(recruitment.getCandName()),
|
||||
trim(recruitment.getRecruitName()),
|
||||
trim(recruitment.getPosName())
|
||||
);
|
||||
}
|
||||
|
||||
private RecruitmentMatchKey buildMatchKey(CcdiStaffRecruitmentWorkExcel excel) {
|
||||
return new RecruitmentMatchKey(
|
||||
trim(excel.getRecruitId()),
|
||||
trim(excel.getCandName()),
|
||||
trim(excel.getRecruitName()),
|
||||
trim(excel.getPosName())
|
||||
);
|
||||
}
|
||||
|
||||
private List<MainImportRow> buildMainImportRows(List<CcdiStaffRecruitmentExcel> recruitmentList) {
|
||||
@@ -641,10 +633,25 @@ public class CcdiStaffRecruitmentImportServiceImpl implements ICcdiStaffRecruitm
|
||||
|
||||
private record WorkImportRow(CcdiStaffRecruitmentWorkExcel data, int sheetRowNum) {}
|
||||
|
||||
private record MainImportResult(Map<String, CcdiStaffRecruitment> importedRecruitmentMap, int successCount) {}
|
||||
private record MainImportResult(Map<RecruitmentMatchKey, List<CcdiStaffRecruitment>> importedRecruitmentMap,
|
||||
int successCount) {}
|
||||
|
||||
private record FailureMeta(String sheetName, String sheetRowNum) {}
|
||||
|
||||
private record RecruitmentMatchKey(String recruitId, String candName, String recruitName, String posName) {
|
||||
|
||||
private boolean isComplete() {
|
||||
return StringUtils.isNotEmpty(recruitId)
|
||||
&& StringUtils.isNotEmpty(candName)
|
||||
&& StringUtils.isNotEmpty(recruitName)
|
||||
&& StringUtils.isNotEmpty(posName);
|
||||
}
|
||||
|
||||
private String value() {
|
||||
return String.join("|", recruitId, candName, recruitName, posName);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ImportValidationException extends RuntimeException {
|
||||
|
||||
private final String sheetName;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.info.collection.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.info.collection.domain.CcdiStaffRecruitment;
|
||||
import com.ruoyi.info.collection.domain.CcdiStaffRecruitmentWork;
|
||||
@@ -27,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -108,15 +110,15 @@ public class CcdiStaffRecruitmentServiceImpl implements ICcdiStaffRecruitmentSer
|
||||
/**
|
||||
* 查询招聘信息详情
|
||||
*
|
||||
* @param recruitId 招聘记录编号
|
||||
* @param id 主键ID
|
||||
* @return 招聘信息VO
|
||||
*/
|
||||
@Override
|
||||
public CcdiStaffRecruitmentVO selectRecruitmentById(String recruitId) {
|
||||
CcdiStaffRecruitmentVO vo = recruitmentMapper.selectRecruitmentById(recruitId);
|
||||
public CcdiStaffRecruitmentVO selectRecruitmentById(Long id) {
|
||||
CcdiStaffRecruitmentVO vo = recruitmentMapper.selectRecruitmentById(id);
|
||||
if (vo != null) {
|
||||
vo.setAdmitStatusDesc(AdmitStatus.getDescByCode(vo.getAdmitStatus()));
|
||||
vo.setWorkExperienceList(selectWorkExperienceList(recruitId));
|
||||
vo.setWorkExperienceList(selectWorkExperienceList(vo.getId()));
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
@@ -130,15 +132,14 @@ public class CcdiStaffRecruitmentServiceImpl implements ICcdiStaffRecruitmentSer
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertRecruitment(CcdiStaffRecruitmentAddDTO addDTO) {
|
||||
// 检查招聘记录编号唯一性
|
||||
if (recruitmentMapper.selectById(addDTO.getRecruitId()) != null) {
|
||||
throw new RuntimeException("该招聘记录编号已存在");
|
||||
}
|
||||
String recruitId = trim(addDTO.getRecruitId());
|
||||
|
||||
CcdiStaffRecruitment recruitment = new CcdiStaffRecruitment();
|
||||
BeanUtils.copyProperties(addDTO, recruitment);
|
||||
int result = recruitmentMapper.insert(recruitment);
|
||||
recruitment.setRecruitId(recruitId);
|
||||
|
||||
int result = recruitmentMapper.insert(recruitment);
|
||||
insertWorkExperienceList(recruitment.getId(), recruitId, addDTO.getRecruitType(), addDTO.getWorkExperienceList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -151,9 +152,20 @@ public class CcdiStaffRecruitmentServiceImpl implements ICcdiStaffRecruitmentSer
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateRecruitment(CcdiStaffRecruitmentEditDTO editDTO) {
|
||||
CcdiStaffRecruitment existing = recruitmentMapper.selectById(editDTO.getId());
|
||||
if (existing == null) {
|
||||
throw new RuntimeException("招聘信息不存在");
|
||||
}
|
||||
|
||||
String recruitId = trim(editDTO.getRecruitId());
|
||||
editDTO.setRecruitId(recruitId);
|
||||
|
||||
CcdiStaffRecruitment recruitment = new CcdiStaffRecruitment();
|
||||
BeanUtils.copyProperties(editDTO, recruitment);
|
||||
int result = recruitmentMapper.updateById(recruitment);
|
||||
if (!Objects.equals(existing.getRecruitId(), recruitId)) {
|
||||
updateWorkRecruitId(editDTO.getId(), recruitId);
|
||||
}
|
||||
replaceWorkExperienceList(editDTO);
|
||||
|
||||
return result;
|
||||
@@ -162,16 +174,19 @@ public class CcdiStaffRecruitmentServiceImpl implements ICcdiStaffRecruitmentSer
|
||||
/**
|
||||
* 批量删除招聘信息
|
||||
*
|
||||
* @param recruitIds 需要删除的招聘记录编号
|
||||
* @param ids 需要删除的招聘信息ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteRecruitmentByIds(String[] recruitIds) {
|
||||
LambdaQueryWrapper<CcdiStaffRecruitmentWork> workWrapper = new LambdaQueryWrapper<>();
|
||||
workWrapper.in(CcdiStaffRecruitmentWork::getRecruitId, List.of(recruitIds));
|
||||
recruitmentWorkMapper.delete(workWrapper);
|
||||
return recruitmentMapper.deleteBatchIds(List.of(recruitIds));
|
||||
public int deleteRecruitmentByIds(Long[] ids) {
|
||||
List<Long> idList = Arrays.asList(ids);
|
||||
if (!idList.isEmpty()) {
|
||||
LambdaQueryWrapper<CcdiStaffRecruitmentWork> workWrapper = new LambdaQueryWrapper<>();
|
||||
workWrapper.in(CcdiStaffRecruitmentWork::getRecruitmentId, idList);
|
||||
recruitmentWorkMapper.delete(workWrapper);
|
||||
}
|
||||
return recruitmentMapper.deleteBatchIds(idList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,9 +231,9 @@ public class CcdiStaffRecruitmentServiceImpl implements ICcdiStaffRecruitmentSer
|
||||
return taskId;
|
||||
}
|
||||
|
||||
private List<CcdiStaffRecruitmentWorkVO> selectWorkExperienceList(String recruitId) {
|
||||
private List<CcdiStaffRecruitmentWorkVO> selectWorkExperienceList(Long recruitmentId) {
|
||||
LambdaQueryWrapper<CcdiStaffRecruitmentWork> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CcdiStaffRecruitmentWork::getRecruitId, recruitId)
|
||||
wrapper.eq(CcdiStaffRecruitmentWork::getRecruitmentId, recruitmentId)
|
||||
.orderByAsc(CcdiStaffRecruitmentWork::getSortOrder)
|
||||
.orderByDesc(CcdiStaffRecruitmentWork::getId);
|
||||
List<CcdiStaffRecruitmentWork> workList = recruitmentWorkMapper.selectList(wrapper);
|
||||
@@ -232,9 +247,20 @@ public class CcdiStaffRecruitmentServiceImpl implements ICcdiStaffRecruitmentSer
|
||||
}).toList();
|
||||
}
|
||||
|
||||
private void updateWorkRecruitId(Long recruitmentId, String newRecruitId) {
|
||||
LambdaUpdateWrapper<CcdiStaffRecruitmentWork> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(CcdiStaffRecruitmentWork::getRecruitmentId, recruitmentId)
|
||||
.set(CcdiStaffRecruitmentWork::getRecruitId, newRecruitId);
|
||||
recruitmentWorkMapper.update(null, updateWrapper);
|
||||
}
|
||||
|
||||
private String trim(String value) {
|
||||
return value == null ? null : value.trim();
|
||||
}
|
||||
|
||||
private void replaceWorkExperienceList(CcdiStaffRecruitmentEditDTO editDTO) {
|
||||
LambdaQueryWrapper<CcdiStaffRecruitmentWork> deleteWrapper = new LambdaQueryWrapper<>();
|
||||
deleteWrapper.eq(CcdiStaffRecruitmentWork::getRecruitId, editDTO.getRecruitId());
|
||||
deleteWrapper.eq(CcdiStaffRecruitmentWork::getRecruitmentId, editDTO.getId());
|
||||
|
||||
if (!Objects.equals(RecruitType.SOCIAL.getCode(), editDTO.getRecruitType())) {
|
||||
recruitmentWorkMapper.delete(deleteWrapper);
|
||||
@@ -246,12 +272,28 @@ public class CcdiStaffRecruitmentServiceImpl implements ICcdiStaffRecruitmentSer
|
||||
}
|
||||
|
||||
recruitmentWorkMapper.delete(deleteWrapper);
|
||||
List<CcdiStaffRecruitmentWork> workList = buildWorkExperienceEntities(editDTO);
|
||||
List<CcdiStaffRecruitmentWork> workList = buildWorkExperienceEntities(
|
||||
editDTO.getId(),
|
||||
editDTO.getRecruitId(),
|
||||
editDTO.getWorkExperienceList()
|
||||
);
|
||||
workList.forEach(recruitmentWorkMapper::insert);
|
||||
}
|
||||
|
||||
private List<CcdiStaffRecruitmentWork> buildWorkExperienceEntities(CcdiStaffRecruitmentEditDTO editDTO) {
|
||||
List<CcdiStaffRecruitmentWorkEditDTO> workExperienceList = editDTO.getWorkExperienceList();
|
||||
private void insertWorkExperienceList(Long recruitmentId,
|
||||
String recruitId,
|
||||
String recruitType,
|
||||
List<CcdiStaffRecruitmentWorkEditDTO> workExperienceList) {
|
||||
if (!Objects.equals(RecruitType.SOCIAL.getCode(), recruitType)) {
|
||||
return;
|
||||
}
|
||||
List<CcdiStaffRecruitmentWork> workList = buildWorkExperienceEntities(recruitmentId, recruitId, workExperienceList);
|
||||
workList.forEach(recruitmentWorkMapper::insert);
|
||||
}
|
||||
|
||||
private List<CcdiStaffRecruitmentWork> buildWorkExperienceEntities(Long recruitmentId,
|
||||
String recruitId,
|
||||
List<CcdiStaffRecruitmentWorkEditDTO> workExperienceList) {
|
||||
if (workExperienceList == null || workExperienceList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -264,7 +306,8 @@ public class CcdiStaffRecruitmentServiceImpl implements ICcdiStaffRecruitmentSer
|
||||
}
|
||||
CcdiStaffRecruitmentWork work = new CcdiStaffRecruitmentWork();
|
||||
BeanUtils.copyProperties(item, work);
|
||||
work.setRecruitId(editDTO.getRecruitId());
|
||||
work.setRecruitmentId(recruitmentId);
|
||||
work.setRecruitId(recruitId);
|
||||
work.setSortOrder(i + 1);
|
||||
entityList.add(work);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
<!-- 招聘信息ResultMap -->
|
||||
<resultMap type="com.ruoyi.info.collection.domain.vo.CcdiStaffRecruitmentVO" id="CcdiStaffRecruitmentVOResult">
|
||||
<id property="recruitId" column="recruit_id"/>
|
||||
<id property="id" column="id"/>
|
||||
<result property="recruitId" column="recruit_id"/>
|
||||
<result property="recruitName" column="recruit_name"/>
|
||||
<result property="posName" column="pos_name"/>
|
||||
<result property="posCategory" column="pos_category"/>
|
||||
@@ -33,17 +34,17 @@
|
||||
<!-- 分页查询招聘信息列表 -->
|
||||
<select id="selectRecruitmentPage" resultMap="CcdiStaffRecruitmentVOResult">
|
||||
SELECT
|
||||
r.recruit_id, r.recruit_name, r.pos_name, r.pos_category, r.pos_desc,
|
||||
r.id, r.recruit_id, r.recruit_name, r.pos_name, r.pos_category, r.pos_desc,
|
||||
r.cand_name, r.recruit_type, r.cand_edu, r.cand_id, r.cand_school, r.cand_major, r.cand_grad,
|
||||
r.admit_status, COALESCE(w.work_experience_count, 0) AS work_experience_count,
|
||||
r.interviewer_name1, r.interviewer_id1, r.interviewer_name2, r.interviewer_id2,
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time
|
||||
FROM ccdi_staff_recruitment r
|
||||
LEFT JOIN (
|
||||
SELECT recruit_id COLLATE utf8mb4_general_ci AS recruit_id, COUNT(1) AS work_experience_count
|
||||
SELECT recruitment_id, COUNT(1) AS work_experience_count
|
||||
FROM ccdi_staff_recruitment_work
|
||||
GROUP BY recruit_id COLLATE utf8mb4_general_ci
|
||||
) w ON w.recruit_id COLLATE utf8mb4_general_ci = r.recruit_id COLLATE utf8mb4_general_ci
|
||||
GROUP BY recruitment_id
|
||||
) w ON w.recruitment_id = r.id
|
||||
<where>
|
||||
<if test="query.recruitName != null and query.recruitName != ''">
|
||||
AND r.recruit_name LIKE CONCAT('%', #{query.recruitName}, '%')
|
||||
@@ -78,16 +79,16 @@
|
||||
<!-- 查询招聘信息详情 -->
|
||||
<select id="selectRecruitmentById" resultMap="CcdiStaffRecruitmentVOResult">
|
||||
SELECT
|
||||
recruit_id, recruit_name, pos_name, pos_category, pos_desc,
|
||||
id, recruit_id, recruit_name, pos_name, pos_category, pos_desc,
|
||||
cand_name, recruit_type, cand_edu, cand_id, cand_school, cand_major, cand_grad,
|
||||
admit_status, interviewer_name1, interviewer_id1, interviewer_name2, interviewer_id2,
|
||||
created_by, create_time, updated_by, update_time
|
||||
FROM ccdi_staff_recruitment
|
||||
WHERE recruit_id = #{recruitId}
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 批量插入招聘信息数据 -->
|
||||
<insert id="insertBatch">
|
||||
<insert id="insertBatch" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO ccdi_staff_recruitment
|
||||
(recruit_id, recruit_name, pos_name, pos_category, pos_desc,
|
||||
cand_name, recruit_type, cand_edu, cand_id, cand_school, cand_major, cand_grad,
|
||||
@@ -124,7 +125,7 @@
|
||||
interviewer_id2 = #{item.interviewerId2},
|
||||
updated_by = #{item.updatedBy},
|
||||
update_time = NOW()
|
||||
WHERE recruit_id = #{item.recruitId}
|
||||
WHERE id = #{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user