1.修改岗位上传添加社会信用代码
2.修改es查询时,不放逐添加,修改为精准查询
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.cms.controller.cms;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.cms.domain.*;
|
||||
import com.ruoyi.cms.domain.query.ESJobSearch;
|
||||
@@ -7,9 +8,9 @@ import com.ruoyi.cms.domain.vo.CandidateVO;
|
||||
import com.ruoyi.cms.domain.vo.CompanyVo;
|
||||
import com.ruoyi.cms.domain.vo.JobExcelVo;
|
||||
import com.ruoyi.cms.service.*;
|
||||
import com.ruoyi.cms.util.EasyExcelUtils;
|
||||
import com.ruoyi.cms.util.RoleUtils;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.cms.util.excel.JobExcelListener;
|
||||
import com.ruoyi.cms.util.sensitiveWord.SensitiveWordChecker;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
@@ -40,6 +41,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 岗位Controller
|
||||
@@ -390,14 +392,29 @@ public class CmsJobController extends BaseController
|
||||
}
|
||||
|
||||
try (InputStream inputStream = file.getInputStream()){
|
||||
List<JobExcelVo> allExcelVoList = new ArrayList<>();
|
||||
EasyExcelUtils.readExcelByBatch(inputStream, JobExcelVo.class, 100, list -> {
|
||||
allExcelVoList.addAll(list);
|
||||
});
|
||||
if (CollectionUtils.isEmpty(allExcelVoList)) {
|
||||
throw new Exception("Excel文件中无有效数据");
|
||||
JobExcelListener listener = new JobExcelListener();
|
||||
EasyExcel.read(inputStream, JobExcelVo.class, listener).sheet().headRowNumber(1).doRead();
|
||||
|
||||
if (listener.hasColumnError()) {
|
||||
return AjaxResult.error(listener.getColumnErrorMsg());
|
||||
}
|
||||
jobService.uploadFileJob(allExcelVoList);
|
||||
|
||||
List<Integer> emptyRowNumbers = listener.getEmptyRowNumbers();
|
||||
List<JobExcelVo> validDataList = listener.getValidDataList();
|
||||
int emptyCount = emptyRowNumbers.size();
|
||||
|
||||
if (emptyCount > 0) {
|
||||
String rowNumStr = emptyRowNumbers.stream()
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining("、"));
|
||||
return AjaxResult.error(String.format("检测到第%s行社会信用代码为空,本次上传终止,未插入任何数据!", rowNumStr));
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(validDataList)) {
|
||||
return AjaxResult.error("Excel文件中无有效数据!");
|
||||
}
|
||||
|
||||
jobService.uploadFileJob(validDataList);
|
||||
return AjaxResult.success("已上传!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -44,41 +44,46 @@ public class JobExcelVo
|
||||
@ApiModelProperty("用人单位名称")
|
||||
private String companyName;
|
||||
|
||||
@ExcelProperty(value = "职位名称", index = 6,converter = LongConverter.class)
|
||||
@ExcelProperty(value = "社会信用代码", index = 6)
|
||||
@Excel(name = "社会信用代码")
|
||||
@ApiModelProperty("社会信用代码")
|
||||
private String code;
|
||||
|
||||
@ExcelProperty(value = "职位名称", index = 7,converter = LongConverter.class)
|
||||
@Excel(name = "招聘人数")
|
||||
@ApiModelProperty("招聘人数")
|
||||
private Long vacancies;
|
||||
|
||||
@ExcelProperty(value = "职位名称", index = 7)
|
||||
@ExcelProperty(value = "职位名称", index = 8)
|
||||
@ApiModelProperty("岗位描述")
|
||||
private String description;
|
||||
|
||||
@ExcelProperty(value = "职位名称", index = 8)
|
||||
@ExcelProperty(value = "职位名称", index = 9)
|
||||
@ApiModelProperty("岗位分类")
|
||||
private String jobCategory;
|
||||
|
||||
@ExcelProperty(value = "职位名称", index = 9)
|
||||
@ExcelProperty(value = "职位名称", index = 10)
|
||||
@ApiModelProperty("岗位类型 0疆内 1疆外")
|
||||
private String jobType;
|
||||
|
||||
@ExcelProperty(value = "职位名称", index = 10)
|
||||
@ExcelProperty(value = "职位名称", index = 11)
|
||||
@ApiModelProperty("类型 0常规岗位 1就业见习岗位 2实习实训岗位 3社区实践岗位 4零工 对应字段字典position_type")
|
||||
private String type;
|
||||
|
||||
@ExcelProperty(value = "职位名称", index = 11)
|
||||
@ExcelProperty(value = "职位名称", index = 12)
|
||||
@ApiModelProperty("工作地点")
|
||||
private String jobAddress;
|
||||
|
||||
@ExcelProperty(value = "职位名称", index = 12)
|
||||
@ExcelProperty(value = "职位名称", index = 13)
|
||||
@Excel(name = "岗位区划")
|
||||
@ApiModelProperty("岗位区划")
|
||||
private String jobLocation;
|
||||
|
||||
@ExcelProperty(value = "联系人", index = 13)
|
||||
@ExcelProperty(value = "联系人", index = 14)
|
||||
@ApiModelProperty("联系人")
|
||||
private String contactPerson;
|
||||
|
||||
@ExcelProperty(value = "联系人电话", index = 14)
|
||||
@ExcelProperty(value = "联系人电话", index = 15)
|
||||
@ApiModelProperty("联系人电话")
|
||||
private String contactPersonPhone;
|
||||
|
||||
|
||||
@@ -33,4 +33,6 @@ public interface CompanyMapper extends BaseMapper<Company>
|
||||
List<Company> selectByNames(List<String> list);
|
||||
|
||||
public Company selectByCode(@Param("code") String code);
|
||||
|
||||
List<Company> selectBycodes(List<String> list);
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
|
||||
List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
|
||||
if (!isCompanyUser &&esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
/*if (!isCompanyUser &&esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
// 定义要逐步放宽的搜索条件字段
|
||||
List<Runnable> relaxConditions = new ArrayList<>();
|
||||
relaxConditions.add(() -> newSearch.setArea(null));
|
||||
@@ -290,7 +290,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
} else {
|
||||
esJobDocuments = allDocuments;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return esJobDocuments;
|
||||
}
|
||||
@@ -489,7 +489,8 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getEducation())){
|
||||
Integer maxValue = StringUtil.findMaxValue(esJobSearch.getEducation());
|
||||
wrapper.and(x->x.le(ESJobDocument::getEducation_int,maxValue));
|
||||
//wrapper.and(x->x.le(ESJobDocument::getEducation_int,maxValue));//模糊查询
|
||||
wrapper.and(x->x.eq(ESJobDocument::getEducation_int,maxValue));//精准查询
|
||||
}
|
||||
if(Objects.nonNull(esJobSearch.getMaxSalary())){
|
||||
wrapper.and(x->x.le(ESJobDocument::getMaxSalary,esJobSearch.getMaxSalary()));
|
||||
@@ -499,7 +500,8 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){
|
||||
Integer maxValue = StringUtil.findMaxValue(esJobSearch.getExperience());
|
||||
wrapper.and(x->x.le(ESJobDocument::getExperience_int,maxValue));
|
||||
//wrapper.and(x->x.le(ESJobDocument::getExperience_int,maxValue));
|
||||
wrapper.and(x->x.eq(ESJobDocument::getExperience_int,maxValue));//精准查询
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())){
|
||||
//wrapper.and(x->x.eq(ESJobDocument::getJobCategory,esJobSearch.getJobCategory()));
|
||||
@@ -510,7 +512,8 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getScale())){
|
||||
Integer maxValue = StringUtil.findMaxValue(esJobSearch.getScale());
|
||||
wrapper.and(x->x.le(ESJobDocument::getScale,maxValue));
|
||||
//wrapper.and(x->x.le(ESJobDocument::getScale,maxValue));
|
||||
wrapper.and(x->x.eq(ESJobDocument::getScale,maxValue));//精准查询
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getArea())){
|
||||
List<Integer> integers = StringUtil.convertStringToIntegerList(esJobSearch.getArea());
|
||||
@@ -544,7 +547,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
wrapper.and(x->x.like(ESJobDocument::getRegionCode,esJobSearch.getRegionCode()));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getStaffType())){
|
||||
wrapper.and(x->x.like(ESJobDocument::getStaffType,esJobSearch.getStaffType()));
|
||||
wrapper.and(x->x.eq(ESJobDocument::getStaffType,esJobSearch.getStaffType()));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobStatus())){
|
||||
wrapper.and(x->x.eq(ESJobDocument::getJobStatus,esJobSearch.getJobStatus()));
|
||||
@@ -587,14 +590,16 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
.match(ESJobDocument::getDescription,jobQuery.getJobTitle(),1.0f));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(jobQuery.getEducation())){
|
||||
wrapper.and(a->a.le(ESJobDocument::getEducation,jobQuery.getEducation()));
|
||||
//wrapper.and(a->a.le(ESJobDocument::getEducation,jobQuery.getEducation()));
|
||||
wrapper.and(a->a.eq(ESJobDocument::getEducation,jobQuery.getEducation()));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(jobQuery.getArea())){
|
||||
List<Integer> integers = StringUtil.convertStringToIntegerList(jobQuery.getArea());
|
||||
wrapper.and(x->x.in(ESJobDocument::getJobLocationAreaCode,integers));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(jobQuery.getExperience())){
|
||||
wrapper.and(a->a.le(ESJobDocument::getExperience,jobQuery.getExperience()));
|
||||
//wrapper.and(a->a.le(ESJobDocument::getExperience,jobQuery.getExperience()));
|
||||
wrapper.and(a->a.eq(ESJobDocument::getExperience,jobQuery.getExperience()));
|
||||
}
|
||||
if(Objects.nonNull(jobQuery.getMaxSalary())){
|
||||
wrapper.and(x->x.le(ESJobDocument::getMaxSalary,jobQuery.getMaxSalary()));
|
||||
@@ -811,7 +816,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
wrapper.limit(esJobSearch.getPageSize());
|
||||
List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
|
||||
if (esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
/*if (esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
// 定义要逐步放宽的搜索条件字段
|
||||
List<Runnable> relaxConditions = new ArrayList<>();
|
||||
relaxConditions.add(() -> newSearch.setArea(null));
|
||||
@@ -854,7 +859,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
} else {
|
||||
esJobDocuments = allDocuments;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return esJobDocuments;
|
||||
}
|
||||
|
||||
@@ -1175,7 +1175,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
*/
|
||||
private Map<String, Long> companyNameToIdMap(List<JobExcelVo> allExcelVoList) {
|
||||
Set<String> companyNameSet = allExcelVoList.stream()
|
||||
.map(JobExcelVo::getCompanyName)
|
||||
.map(JobExcelVo::getCode)
|
||||
.filter(StringUtils::hasText)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
@@ -1183,13 +1183,13 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
List<Company> companies = companyMapper.selectByNames(new ArrayList<>(companyNameSet));
|
||||
List<Company> companies = companyMapper.selectBycodes(new ArrayList<>(companyNameSet));
|
||||
if (CollectionUtils.isEmpty(companies)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return companies.stream()
|
||||
.collect(Collectors.toMap(
|
||||
Company::getName,
|
||||
Company::getCode,
|
||||
Company::getCompanyId,
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
@@ -1225,7 +1225,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
|
||||
String companyName = it.getCompanyName();
|
||||
job.setCompanyName(companyName);
|
||||
job.setCompanyId(companyNameToIdMap.getOrDefault(companyName, null));
|
||||
job.setCompanyId(companyNameToIdMap.getOrDefault(it.getCode(), null));
|
||||
|
||||
return job;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ruoyi.cms.util.excel;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.ruoyi.cms.domain.vo.JobExcelVo;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 企业岗位excel监听
|
||||
*/
|
||||
@Getter
|
||||
public class JobExcelListener extends AnalysisEventListener<JobExcelVo> {
|
||||
|
||||
private final List<JobExcelVo> validDataList = new ArrayList<>();
|
||||
private final List<Integer> emptyRowNumbers = new ArrayList<>();
|
||||
private boolean isHeadChecked = false;
|
||||
private String columnErrorMsg;
|
||||
|
||||
@Override
|
||||
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
|
||||
if (!isHeadChecked) {
|
||||
ReadCellData<?> cellData = headMap.get(6);
|
||||
String seventhColumnTitle = null;
|
||||
if (cellData != null) {
|
||||
seventhColumnTitle = cellData.getStringValue();
|
||||
}
|
||||
if (StringUtils.isBlank(seventhColumnTitle) || !seventhColumnTitle.trim().equals("社会信用代码")) {
|
||||
columnErrorMsg = "Excel模板格式错误:第7列标题应为「社会信用代码」,请下载标准模板后重新上传!";
|
||||
}
|
||||
|
||||
isHeadChecked = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invoke(JobExcelVo jobExcelVo, AnalysisContext analysisContext) {
|
||||
int currentRowNum = analysisContext.readRowHolder().getRowIndex() + 1;
|
||||
String creditCode = jobExcelVo.getCode();
|
||||
|
||||
if (creditCode != null) {
|
||||
creditCode = creditCode.trim();
|
||||
jobExcelVo.setCode(creditCode.toUpperCase());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(creditCode)) {
|
||||
emptyRowNumbers.add(currentRowNum);
|
||||
} else {
|
||||
validDataList.add(jobExcelVo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {}
|
||||
|
||||
public boolean hasColumnError() {
|
||||
return StringUtils.isNotBlank(columnErrorMsg);
|
||||
}
|
||||
}
|
||||
@@ -129,4 +129,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by create_time desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectBycodes" resultType="com.ruoyi.common.core.domain.entity.Company" parameterType="java.util.List">
|
||||
SELECT company_id, code FROM company
|
||||
WHERE del_flag = '0' and code IN
|
||||
<foreach collection="list" item="code" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user