update
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.domain.Job;
|
||||
import com.ruoyi.cms.domain.JobCollection;
|
||||
import com.ruoyi.cms.domain.vo.CompetitivenessResponse;
|
||||
|
||||
/**
|
||||
* 用户岗位收藏Service接口
|
||||
@@ -70,5 +71,5 @@ public interface IJobCollectionService
|
||||
|
||||
List<Job> collectionJob();
|
||||
|
||||
String competitiveness(Long jobId);
|
||||
CompetitivenessResponse competitiveness(Long jobId);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public interface IJobService
|
||||
|
||||
Job selectJobByJobIdApp(Long jobId);
|
||||
|
||||
void importRow();
|
||||
void importRow(String path);
|
||||
|
||||
List<CandidateVO> candidates(Long jobId);
|
||||
|
||||
@@ -88,13 +88,4 @@ public interface IJobService
|
||||
|
||||
List<ESJobDocument> littleVideoRandom(String uuid, Integer count,String jobTitle);
|
||||
|
||||
void updateEs();
|
||||
|
||||
AppWechatEntity getWechatUrl(String wechatUrl);
|
||||
|
||||
String insertTemp(Job job);
|
||||
|
||||
String htmlGen(Long id);
|
||||
|
||||
void fix();
|
||||
}
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cms.domain.AppReviewJob;
|
||||
import com.ruoyi.cms.domain.Company;
|
||||
import com.ruoyi.cms.domain.Job;
|
||||
import com.ruoyi.cms.domain.query.MineJobQuery;
|
||||
import com.ruoyi.cms.mapper.AppReviewJobMapper;
|
||||
import com.ruoyi.cms.service.IAppReviewJobService;
|
||||
import com.ruoyi.cms.service.IJobService;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 用户岗位浏览记录Service业务层处理
|
||||
@@ -32,8 +27,7 @@ public class AppReviewJobServiceImpl extends ServiceImpl<AppReviewJobMapper, App
|
||||
{
|
||||
@Autowired
|
||||
private AppReviewJobMapper appReviewJobMapper;
|
||||
@Autowired
|
||||
private IJobService jobService;
|
||||
|
||||
private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
/**
|
||||
* 查询用户岗位浏览记录
|
||||
|
||||
@@ -168,7 +168,7 @@ public class BussinessDictDataServiceImpl implements IBussinessDictDataService
|
||||
type.replace("学历","");
|
||||
}
|
||||
if(Objects.equals(type, "不限学历")||Objects.equals(type, "学历不限")){
|
||||
return "11";
|
||||
return "-1";
|
||||
}
|
||||
if(Objects.equals(type, "中专")){
|
||||
return "1";
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
/**
|
||||
* 项目启动时,初始化索引及数据
|
||||
*/
|
||||
// @PostConstruct
|
||||
@PostConstruct
|
||||
public void init()
|
||||
{
|
||||
resetTextCache();
|
||||
@@ -75,7 +75,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
public void resetTextCache() {
|
||||
logger.info("正在重新刷新es");
|
||||
// 删除并重新创建索引
|
||||
esJobDocumentMapper.deleteIndex("job_document_gt");
|
||||
esJobDocumentMapper.deleteIndex("job_document");
|
||||
esJobDocumentMapper.createIndex();
|
||||
|
||||
// 分批次处理数据
|
||||
@@ -107,14 +107,14 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
if(!StringUtil.isEmptyOrNull(job.getExperience())){
|
||||
esJobDocument.setExperience_int(Integer.valueOf(job.getExperience()));
|
||||
}else {
|
||||
esJobDocument.setExperience("8");
|
||||
esJobDocument.setEducation_int(8);
|
||||
esJobDocument.setExperience("0");
|
||||
esJobDocument.setEducation_int(0);
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(job.getEducation())){
|
||||
esJobDocument.setEducation_int(Integer.valueOf(job.getEducation()));
|
||||
}else {
|
||||
esJobDocument.setEducation("11");
|
||||
esJobDocument.setExperience_int(11);
|
||||
esJobDocument.setEducation("-1");
|
||||
esJobDocument.setExperience_int(-1);
|
||||
}
|
||||
if (esJobDocument.getLatitude() != null) {
|
||||
esJobDocument.setLatAndLon(esJobDocument.getLatitude().toString() + "," + esJobDocument.getLongitude().toString());
|
||||
@@ -137,37 +137,97 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
@Override
|
||||
public List<ESJobDocument> selectTextListExceptJobId(ESJobSearch esJobSearch, List<Long> jobIds) {
|
||||
|
||||
ESJobSearch newSearch = new ESJobSearch();
|
||||
BeanUtils.copyProperties(esJobSearch,newSearch);
|
||||
//查询
|
||||
if(SecurityUtils.isLogin()){
|
||||
AppUser appUser = appUserService.selectAppUserByUserId(SecurityUtils.getUserId());
|
||||
if(!ListUtil.isEmptyOrNull(appUser.getJobTitle())&&!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){
|
||||
esJobSearch.setJobTitle(String.join(",", appUser.getJobTitle()));
|
||||
if(!ListUtil.isEmptyOrNull(appUser.getJobTitle())){
|
||||
List<String> jobTitle = appUser.getJobTitle();
|
||||
newSearch.setJobTitle(String.join(",", jobTitle));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(appUser.getEducation())&&!StringUtil.isEmptyOrNull(esJobSearch.getEducation())){
|
||||
esJobSearch.setEducation(appUser.getEducation());
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){
|
||||
newSearch.setJobTitle(esJobSearch.getJobTitle());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(appUser.getEducation())){
|
||||
newSearch.setEducation(appUser.getEducation());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getEducation())){
|
||||
newSearch.setEducation(esJobSearch.getEducation());
|
||||
}
|
||||
|
||||
if(!StringUtil.isEmptyOrNull(appUser.getArea())){
|
||||
esJobSearch.setJobLocationAreaCode(Integer.valueOf(appUser.getArea()));
|
||||
newSearch.setArea(appUser.getArea());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(appUser.getExperience())&&!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){
|
||||
esJobSearch.setExperience(appUser.getExperience());
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getArea())){
|
||||
newSearch.setArea(esJobSearch.getArea());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(appUser.getExperience())){
|
||||
newSearch.setExperience(appUser.getExperience());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){
|
||||
newSearch.setExperience(esJobSearch.getExperience());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(appUser.getSalaryMax())){
|
||||
esJobSearch.setMaxSalary(Long.valueOf(appUser.getSalaryMax()));
|
||||
newSearch.setMaxSalary(Long.valueOf(appUser.getSalaryMax()));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(appUser.getSalaryMin())){
|
||||
esJobSearch.setMaxSalary(Long.valueOf(appUser.getSalaryMin()));
|
||||
newSearch.setMinSalary(Long.valueOf(appUser.getSalaryMin()));
|
||||
}
|
||||
}
|
||||
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(esJobSearch);
|
||||
if(!ListUtil.isListEmptyOrNull(jobIds)){
|
||||
wrapper.in(ESJobDocument::getJobId, jobIds);
|
||||
}
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(newSearch,jobIds);
|
||||
|
||||
//todo 暂时
|
||||
wrapper.limit(esJobSearch.getPageSize());
|
||||
wrapper.orderByDesc(ESJobDocument::getCompanyId);
|
||||
return esJobDocumentMapper.selectList(wrapper);
|
||||
List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
|
||||
if (esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
// 定义要逐步放宽的搜索条件字段
|
||||
List<Runnable> relaxConditions = new ArrayList<>();
|
||||
relaxConditions.add(() -> newSearch.setArea(null));
|
||||
relaxConditions.add(() -> newSearch.setExperience(null));
|
||||
relaxConditions.add(() -> newSearch.setMaxSalary(null));
|
||||
relaxConditions.add(() -> newSearch.setMinSalary(null));
|
||||
relaxConditions.add(() -> newSearch.setEducation(null));
|
||||
relaxConditions.add(()-> newSearch.setJobTitle(null));
|
||||
// 保存所有查询到的文档
|
||||
List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments);
|
||||
|
||||
// 记录已经放宽的条件数量
|
||||
int relaxedConditions = 0;
|
||||
|
||||
// 继续放宽条件直到满足分页或所有条件都已放宽
|
||||
while (allDocuments.size() < esJobSearch.getPageSize()
|
||||
&& relaxedConditions < relaxConditions.size()) {
|
||||
// 放宽下一个条件
|
||||
relaxConditions.get(relaxedConditions).run();
|
||||
relaxedConditions++;
|
||||
|
||||
// 查询新增的文档(不包含之前已经查询到的)
|
||||
wrapper = getWrapper(newSearch, jobIds);
|
||||
wrapper.limit(esJobSearch.getPageSize() - allDocuments.size());
|
||||
if (!allDocuments.isEmpty()) {
|
||||
// 排除已经查询到的文档ID
|
||||
Set<String> existingIds = allDocuments.stream()
|
||||
.map(ESJobDocument::getId)
|
||||
.collect(Collectors.toSet());
|
||||
wrapper.not().in(ESJobDocument::getId, existingIds);
|
||||
}
|
||||
|
||||
List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
allDocuments.addAll(newDocuments);
|
||||
}
|
||||
|
||||
// 如果总数超过分页大小,截取所需数量
|
||||
if (allDocuments.size() > esJobSearch.getPageSize()) {
|
||||
esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize());
|
||||
} else {
|
||||
esJobDocuments = allDocuments;
|
||||
}
|
||||
}
|
||||
|
||||
return esJobDocuments;
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +281,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
public EsPageInfo<ESJobDocument> nearJob(ESJobSearch jobQuery) {
|
||||
Integer pageNum = jobQuery.getCurrent();
|
||||
Integer pageSize = jobQuery.getPageSize();
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(jobQuery);
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(jobQuery,null);
|
||||
EsPageInfo<ESJobDocument> esJobDocumentEsPageInfo = esJobDocumentMapper.pageQuery(wrapper, pageNum, pageSize);
|
||||
return esJobDocumentEsPageInfo;
|
||||
}
|
||||
@@ -230,7 +290,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
public EsPageInfo<ESJobDocument> countyJobList(ESJobSearch jobQuery) {
|
||||
Integer pageNum = jobQuery.getCurrent();
|
||||
Integer pageSize = jobQuery.getPageSize();
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(jobQuery);
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(jobQuery, null);
|
||||
if(jobQuery.getCountyIds()!=null){
|
||||
wrapper.and(x->x.in(ESJobDocument::getJobLocationAreaCode,jobQuery.getCountyIds()));
|
||||
}
|
||||
@@ -242,7 +302,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
public EsPageInfo<ESJobDocument> subway(ESJobSearch jobQuery) {
|
||||
Integer pageNum = jobQuery.getCurrent();
|
||||
Integer pageSize = jobQuery.getPageSize();
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(jobQuery);
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(jobQuery,null);
|
||||
EsPageInfo<ESJobDocument> esJobDocumentEsPageInfo = esJobDocumentMapper.pageQuery(wrapper, pageNum, pageSize);
|
||||
return esJobDocumentEsPageInfo;
|
||||
}
|
||||
@@ -251,7 +311,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
public EsPageInfo<ESJobDocument> commercialArea(ESJobSearch jobQuery) {
|
||||
Integer pageNum = jobQuery.getCurrent();
|
||||
Integer pageSize = jobQuery.getPageSize();
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(jobQuery);
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = getWrapper(jobQuery,null);
|
||||
if(jobQuery.getLongitude()!=null){
|
||||
wrapper.geoDistance(ESJobDocument::getLatAndLon,Double.valueOf(jobQuery.getRadius()), DistanceUnit.KILOMETERS,new GeoPoint(Double.parseDouble(jobQuery.getLatitude().toString()), Double.parseDouble(jobQuery.getLongitude().toString())));
|
||||
}
|
||||
@@ -263,7 +323,6 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
public List<ESJobDocument> littleVideo(ESJobSearch esJobSearch) {
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.eq(ESJobDocument::getIsExplain, 1);
|
||||
wrapper.orderByDesc(ESJobDocument::getIsExplain);
|
||||
wrapper.limit(esJobSearch.getPageSize());
|
||||
return esJobDocumentMapper.selectList(wrapper);
|
||||
}
|
||||
@@ -297,29 +356,17 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
return esJobDocumentMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
private LambdaEsQueryWrapper<ESJobDocument> getWrapper(ESJobSearch esJobSearch){
|
||||
List<String> searchList = new ArrayList<>();
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){
|
||||
searchList.add(esJobSearch.getJobTitle());
|
||||
}else {
|
||||
if(SecurityUtils.isLogin()){
|
||||
AppUser appUser = appUserService.selectAppUserByUserId(SecurityUtils.getUserId());
|
||||
List<String> jobTitleList = appUser.getJobTitle();
|
||||
if(!jobTitleList.isEmpty()){
|
||||
searchList.addAll(jobTitleList);
|
||||
}
|
||||
}
|
||||
}
|
||||
private LambdaEsQueryWrapper<ESJobDocument> getWrapper(ESJobSearch esJobSearch,List<Long> jobIds){
|
||||
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = new LambdaEsQueryWrapper<>();
|
||||
if (!searchList.isEmpty())
|
||||
{
|
||||
for (String keyWords:searchList){
|
||||
wrapper.or(a -> a.like(ESJobDocument::getJobTitle, keyWords, 5.0f)
|
||||
.or()
|
||||
.like(ESJobDocument::getDescription, keyWords, 1.0f)
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){
|
||||
for (String keyWord:esJobSearch.getJobTitle().split(",")) {
|
||||
wrapper.and(a -> a.match(ESJobDocument::getJobTitle, keyWord, 5.0f)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(esJobSearch.getLongitude()!=null){
|
||||
wrapper.geoDistance(ESJobDocument::getLatAndLon,Double.valueOf(esJobSearch.getRadius()), DistanceUnit.KILOMETERS,new GeoPoint(Double.parseDouble(esJobSearch.getLatitude().toString()), Double.parseDouble(esJobSearch.getLongitude().toString())));
|
||||
}
|
||||
@@ -344,6 +391,10 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
Integer maxValue = StringUtil.findMaxValue(esJobSearch.getScale());
|
||||
wrapper.and(x->x.le(ESJobDocument::getScale,maxValue));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getArea())){
|
||||
List<Integer> integers = StringUtil.convertStringToIntegerList(esJobSearch.getArea());
|
||||
wrapper.and(x->x.in(ESJobDocument::getJobLocationAreaCode,integers));
|
||||
}
|
||||
if(Objects.nonNull(esJobSearch.getOrder())){
|
||||
if(esJobSearch.getOrder()==1){
|
||||
wrapper.orderByDesc(ESJobDocument::getIsHot);
|
||||
@@ -352,7 +403,9 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
wrapper.orderByDesc(ESJobDocument::getPostingDate);
|
||||
}
|
||||
}
|
||||
//TODO LIST
|
||||
if(!ListUtil.isListEmptyOrNull(jobIds)){
|
||||
wrapper.not().in(ESJobDocument::getJobId, jobIds);
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -362,6 +415,13 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
Integer pageNum = jobQuery.getCurrent();
|
||||
Integer pageSize = jobQuery.getPageSize();
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = new LambdaEsQueryWrapper<>();
|
||||
// if(SecurityUtils.isLogin()){
|
||||
// AppUser appUser = appUserService.selectAppUserByUserId(SecurityUtils.getUserId());
|
||||
// if(!ListUtil.isEmptyOrNull(appUser.getJobTitle())){
|
||||
// List<String> jobTitle = appUser.getJobTitle();
|
||||
// jobQuery.setJobTitle(String.join(",", jobTitle));
|
||||
// }
|
||||
// }
|
||||
if(!StringUtil.isEmptyOrNull(jobQuery.getJobTitle())){
|
||||
wrapper.and(a->a.match(ESJobDocument::getJobTitle,jobQuery.getJobTitle(),5.0f)
|
||||
.or()
|
||||
@@ -370,7 +430,10 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
if(!StringUtil.isEmptyOrNull(jobQuery.getEducation())){
|
||||
wrapper.and(a->a.le(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()));
|
||||
}
|
||||
@@ -430,6 +493,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
for (ESJobDocument esJobDocument : esJobDocuments) {
|
||||
Job job = new Job();
|
||||
BeanUtils.copyProperties(esJobDocument,job);
|
||||
job.setJobId(null);
|
||||
jobMapper.insert(job);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.cms.domain.AppUser;
|
||||
import com.ruoyi.cms.domain.Job;
|
||||
import com.ruoyi.cms.domain.JobApply;
|
||||
import com.ruoyi.cms.domain.*;
|
||||
import com.ruoyi.cms.domain.vo.CompetitivenessResponse;
|
||||
import com.ruoyi.cms.domain.vo.RadarChart;
|
||||
import com.ruoyi.cms.mapper.AppUserMapper;
|
||||
import com.ruoyi.cms.mapper.JobApplyMapper;
|
||||
import com.ruoyi.cms.mapper.JobMapper;
|
||||
import com.ruoyi.cms.service.IBussinessDictTypeService;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.cms.mapper.JobCollectionMapper;
|
||||
import com.ruoyi.cms.domain.JobCollection;
|
||||
import com.ruoyi.cms.service.IJobCollectionService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -34,6 +37,10 @@ public class JobCollectionServiceImpl extends ServiceImpl<JobCollectionMapper,Jo
|
||||
private JobApplyMapper jobApplyMapper;
|
||||
@Autowired
|
||||
private AppUserMapper appUserMapper;
|
||||
@Autowired
|
||||
private JobMapper jobMapper;
|
||||
@Autowired
|
||||
private IBussinessDictTypeService iBussinessDictTypeService;
|
||||
/**
|
||||
* 查询用户岗位收藏
|
||||
*
|
||||
@@ -147,9 +154,237 @@ public class JobCollectionServiceImpl extends ServiceImpl<JobCollectionMapper,Jo
|
||||
}
|
||||
|
||||
@Override
|
||||
public String competitiveness(Long jobId) {
|
||||
AppUser appUser = appUserMapper.selectById(SecurityUtils.getUserId());
|
||||
String education = appUser.getEducation();
|
||||
return "90.5";
|
||||
public CompetitivenessResponse competitiveness(Long jobId) {
|
||||
// 查询岗位信息
|
||||
Job job = jobMapper.selectById(jobId);
|
||||
if (job == null) {
|
||||
throw new RuntimeException("岗位不存在");
|
||||
}
|
||||
|
||||
// 获取所有申请该岗位的用户
|
||||
List<AppUser> appUsers = appUserMapper.selectByJobId(jobId);
|
||||
Long applyCount = (long) appUsers.size();
|
||||
|
||||
if (appUsers.isEmpty()) {
|
||||
// 没有人申请,返回默认值或0
|
||||
CompetitivenessResponse emptyResponse = new CompetitivenessResponse();
|
||||
emptyResponse.setTotalApplicants(0);
|
||||
emptyResponse.setMatchScore(0);
|
||||
emptyResponse.setRank(0);
|
||||
emptyResponse.setPercentile(0);
|
||||
RadarChart radarChart = new RadarChart();
|
||||
emptyResponse.setRadarChart(radarChart);
|
||||
return emptyResponse;
|
||||
}
|
||||
|
||||
// ================== 数据字典映射(用于排序比较)==================
|
||||
// 假设你有字典工具类,如 DictUtils.getSort("education", value) 返回排序值
|
||||
// 这里我们用 Map 模拟字典排序(越小要求越低)
|
||||
// 获取字典数据
|
||||
List<BussinessDictData> educationDict = iBussinessDictTypeService.selectDictDataByType("education");
|
||||
List<BussinessDictData> experienceDict = iBussinessDictTypeService.selectDictDataByType("experience");
|
||||
|
||||
// 构建学历排序映射:dictLabel -> dictSort(越小要求越低)
|
||||
Map<String, Integer> educationRank = educationDict.stream()
|
||||
.collect(Collectors.toMap(
|
||||
BussinessDictData::getDictLabel,
|
||||
data -> Math.toIntExact(data.getDictSort()),
|
||||
(a, b) -> a // 若有重复 key,保留第一个
|
||||
));
|
||||
|
||||
Map<String, Integer> experienceRank = experienceDict.stream()
|
||||
.collect(Collectors.toMap(
|
||||
BussinessDictData::getDictLabel,
|
||||
data -> Math.toIntExact(data.getDictSort()),
|
||||
(a, b) -> a
|
||||
));
|
||||
|
||||
// ================== 提取岗位要求 ==================
|
||||
Integer jobEducationRank = educationRank.getOrDefault(job.getEducation(), 999);
|
||||
Integer jobExperienceRank = experienceRank.getOrDefault(job.getExperience(), 999);
|
||||
Integer jobMinSalary = job.getMinSalary() != null ? job.getMinSalary().intValue() : 0;
|
||||
String jobLocation = job.getJobLocation();
|
||||
|
||||
// ================== 聚合用户数据用于分析 ==================
|
||||
List<UserCompetitiveness> userScores = new ArrayList<>();
|
||||
|
||||
for (AppUser user : appUsers) {
|
||||
int matchScore = 0;
|
||||
int totalFactors = 6; // 年龄、经验、学历、技能(暂用期望岗位匹配)、薪资、地点
|
||||
|
||||
// 1. 学历匹配(越接近越好)
|
||||
Integer userEduRank = educationRank.getOrDefault(user.getEducation(), 999);
|
||||
if (userEduRank <= jobEducationRank) {
|
||||
matchScore += 1; // 达标
|
||||
} else if (userEduRank == jobEducationRank + 1) {
|
||||
matchScore += 0.5; // 略高也算匹配
|
||||
}
|
||||
|
||||
// 2. 经验匹配
|
||||
Integer userExpRank = experienceRank.getOrDefault(user.getExperience(), 999);
|
||||
if (userExpRank >= jobExperienceRank) {
|
||||
matchScore += 1; // 满足经验要求
|
||||
}
|
||||
|
||||
// 3. 薪资匹配(用户期望 <= 岗位最大薪资,且不低于最小太多)
|
||||
Integer userMinSalary = parseSalary(user.getSalaryMin());
|
||||
if (userMinSalary != null && userMinSalary <= job.getMaxSalary()) {
|
||||
if (userMinSalary >= job.getMinSalary()) {
|
||||
matchScore += 1;
|
||||
} else if (userMinSalary >= job.getMinSalary() * 0.8) {
|
||||
matchScore += 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 地点匹配
|
||||
if (user.getArea() != null && user.getArea().contains(jobLocation) || jobLocation.contains(user.getArea())) {
|
||||
matchScore += 1;
|
||||
}
|
||||
|
||||
// 5. 年龄估算(从生日计算)
|
||||
int userAge = getUserAge(user.getBirthDate());
|
||||
// 假设最佳年龄区间为 22-35,越接近越匹配
|
||||
if (userAge >= 22 && userAge <= 35) {
|
||||
matchScore += 1;
|
||||
} else if (userAge >= 18 && userAge <= 45) {
|
||||
matchScore += 0.5;
|
||||
}
|
||||
|
||||
// 6. 技能/岗位匹配(简化:期望岗位是否包含该岗位关键词)
|
||||
boolean jobMatch = user.getJobTitle() != null &&
|
||||
user.getJobTitle().stream().anyMatch(title -> title.contains(job.getJobTitle()) || job.getJobTitle().contains(title));
|
||||
if (jobMatch) {
|
||||
matchScore += 1;
|
||||
}
|
||||
|
||||
// 匹配度:0-6 → 映射为 0-100 分
|
||||
int finalScore = (int) Math.round((matchScore / (double) totalFactors) * 100);
|
||||
userScores.add(new UserCompetitiveness(user, finalScore));
|
||||
}
|
||||
|
||||
// 按匹配度降序
|
||||
userScores.sort((a, b) -> Integer.compare(b.getScore(), a.getScore()));
|
||||
|
||||
// ================== 计算雷达图数据(取平均值)==================
|
||||
RadarChart radarChart = new RadarChart();
|
||||
|
||||
double avgAgeScore = userScores.stream().mapToInt(u -> getAgeScore(u.getUser().getBirthDate())).average().orElse(0);
|
||||
double avgExperienceScore = userScores.stream().mapToInt(u -> getExperienceScore(u.getUser().getExperience(), job.getExperience(), experienceRank)).average().orElse(0);
|
||||
double avgEducationScore = userScores.stream().mapToInt(u -> getEducationScore(u.getUser().getEducation(), job.getEducation(), educationRank)).average().orElse(0);
|
||||
double avgSkillScore = userScores.stream().mapToInt(u -> getSkillScore(u.getUser(), job)).average().orElse(0);
|
||||
double avgSalaryScore = userScores.stream().mapToInt(u -> getSalaryScore(u.getUser(), job)).average().orElse(0);
|
||||
double avgLocationScore = userScores.stream().mapToInt(u -> getLocationScore(u.getUser(), job)).average().orElse(0);
|
||||
|
||||
radarChart.setAge((int) avgAgeScore);
|
||||
radarChart.setExperience((int) avgExperienceScore);
|
||||
radarChart.setEducation((int) avgEducationScore);
|
||||
radarChart.setSkill((int) avgSkillScore);
|
||||
radarChart.setSalary((int) avgSalaryScore);
|
||||
radarChart.setLocation((int) avgLocationScore);
|
||||
|
||||
// ================== 返回响应 ==================
|
||||
CompetitivenessResponse response = new CompetitivenessResponse();
|
||||
response.setTotalApplicants(Math.toIntExact(applyCount));
|
||||
|
||||
// Top 用户的匹配分
|
||||
int topMatchScore = userScores.get(0).getScore();
|
||||
response.setMatchScore(topMatchScore);
|
||||
|
||||
// 排名(Top1)
|
||||
response.setRank(1);
|
||||
|
||||
// 百分位:top用户超过多少人?(100%)
|
||||
response.setPercentile(100);
|
||||
|
||||
response.setRadarChart(radarChart);
|
||||
|
||||
return response;
|
||||
}
|
||||
private int getUserAge(Date birthDate) {
|
||||
if (birthDate == null) return 0;
|
||||
try {
|
||||
LocalDate birth = birthDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
return Period.between(birth, LocalDate.now()).getYears();
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
private int getEducationScore(String userEdu, String jobEdu, Map<String, Integer> rankMap) {
|
||||
if (userEdu == null || jobEdu == null) return 60;
|
||||
Integer u = rankMap.getOrDefault(userEdu, 999);
|
||||
Integer j = rankMap.getOrDefault(jobEdu, 999);
|
||||
if (u <= j) return 90;
|
||||
if (u == j + 1) return 75;
|
||||
return 60;
|
||||
}
|
||||
private int getExperienceScore(String userExp, String jobExp, Map<String, Integer> rankMap) {
|
||||
if (userExp == null || jobExp == null) return 60;
|
||||
Integer u = rankMap.getOrDefault(userExp, 999);
|
||||
Integer j = rankMap.getOrDefault(jobExp, 999);
|
||||
if (u >= j) return 90;
|
||||
if (u >= j - 1) return 75; // 容忍略低一年
|
||||
return 60;
|
||||
}
|
||||
private int getSalaryScore(AppUser user, Job job) {
|
||||
Integer min = parseSalary(user.getSalaryMin());
|
||||
if (min == null) return 60;
|
||||
if (job.getMinSalary() == null || job.getMaxSalary() == null) return 60;
|
||||
|
||||
long jobMin = job.getMinSalary();
|
||||
long jobMax = job.getMaxSalary();
|
||||
|
||||
if (min >= jobMin && min <= jobMax) return 90;
|
||||
if (min >= jobMin * 0.8 && min <= jobMax * 1.2) return 75;
|
||||
return 60;
|
||||
}
|
||||
private int getLocationScore(AppUser user, Job job) {
|
||||
String area = user.getArea();
|
||||
String loc = job.getJobLocation();
|
||||
if (area != null && (area.contains(loc) || loc.contains(area))) return 90;
|
||||
return 60;
|
||||
}
|
||||
private int getSkillScore(AppUser user, Job job) {
|
||||
String jobTitle = job.getJobTitle();
|
||||
List<String> userTitles = user.getJobTitle();
|
||||
if (jobTitle == null || userTitles == null || userTitles.isEmpty()) return 60;
|
||||
|
||||
boolean match = userTitles.stream()
|
||||
.anyMatch(title -> title != null &&
|
||||
(title.contains(jobTitle) || jobTitle.contains(title)));
|
||||
return match ? 90 : 60;
|
||||
}
|
||||
private Integer parseSalary(String salaryStr) {
|
||||
if (salaryStr == null || salaryStr.trim().isEmpty()) return null;
|
||||
try {
|
||||
// 提取第一个连续数字
|
||||
String numberStr = salaryStr.replaceAll("[^0-9]", "");
|
||||
return numberStr.isEmpty() ? null : Integer.parseInt(numberStr);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private int getAgeScore(Date birthDate) {
|
||||
int age = getUserAge(birthDate);
|
||||
if (age == 0) return 60; // 无法获取年龄,默认低分
|
||||
if (age >= 22 && age <= 35) return 90;
|
||||
if (age >= 18 && age <= 45) return 75;
|
||||
return 60;
|
||||
}
|
||||
private static class UserCompetitiveness {
|
||||
private final AppUser user;
|
||||
private final int score;
|
||||
|
||||
public UserCompetitiveness(AppUser user, int score) {
|
||||
this.user = user;
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public AppUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,6 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
}else {
|
||||
jobList = cacheObject.toList(Long.class);
|
||||
}
|
||||
//从kafka中消费 bert模型跑出来的结果
|
||||
//从es中查询
|
||||
List<ESJobDocument> jobListResult = iesJobSearchService.selectTextListExceptJobId(esJobSearch,jobList);
|
||||
//存入当前session中查看的岗位 避免重复 todo 定时删除 key上保存用户信息
|
||||
@@ -331,41 +330,34 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
|
||||
@Override
|
||||
public Job selectJobByJobIdApp(Long jobId) {
|
||||
try {
|
||||
Job job = new Job();
|
||||
ESJobDocument esJobDocument = iesJobSearchService.selectById(jobId);
|
||||
BeanUtils.copyProperties(esJobDocument,job);
|
||||
Job job = jobMapper.selectById(jobId);
|
||||
//查询公司信息
|
||||
if(Objects.nonNull(job.getCompanyId())){
|
||||
Company company = companyMapper.selectById(job.getCompanyId());
|
||||
job.setCompany(company);
|
||||
}
|
||||
// if(SecurityUtils.isLogin()){
|
||||
// //查询申请信息
|
||||
// Long applyCount = jobApplyMapper.selectCount(Wrappers.<JobApply>lambdaQuery().eq(JobApply::getJobId, jobId).eq(JobApply::getUserId, SecurityUtils.getUserId()));
|
||||
// job.setIsApply(applyCount>0?1:0);
|
||||
// //查询收藏信息
|
||||
// Long collectionCount = jobCollectionMapper.selectCount(Wrappers.<JobCollection>lambdaQuery().eq(JobCollection::getJobId, jobId).eq(JobCollection::getUserId, SecurityUtils.getUserId()));
|
||||
// job.setIsCollection(collectionCount>0?1:0);
|
||||
// //todo asyn
|
||||
// //保存浏览记录
|
||||
// List<AppReviewJob> appReviewJobs = appReviewJobMapper.selectList(Wrappers.<AppReviewJob>lambdaQuery().eq(AppReviewJob::getUserId, SecurityUtils.getUserId()).eq(AppReviewJob::getJobId, jobId));
|
||||
// //之前相同岗位的记录删除 保存最新的浏览记录
|
||||
// if(!appReviewJobs.isEmpty()){
|
||||
// appReviewJobMapper.deleteBatchIds(appReviewJobs.stream().map(AppReviewJob::getId).collect(Collectors.toList()));
|
||||
// }
|
||||
// AppReviewJob appReviewJob = new AppReviewJob();
|
||||
// appReviewJob.setUserId(SecurityUtils.getUserId());
|
||||
// appReviewJob.setReviewDate(new Date());
|
||||
// appReviewJob.setJobId(jobId);
|
||||
// appReviewJobMapper.insert(appReviewJob);
|
||||
// }
|
||||
//浏览量+1
|
||||
// this.view(jobId);
|
||||
if(SecurityUtils.isLogin()){
|
||||
//查询申请信息
|
||||
Long applyCount = jobApplyMapper.selectCount(Wrappers.<JobApply>lambdaQuery().eq(JobApply::getJobId, jobId).eq(JobApply::getUserId, SecurityUtils.getUserId()));
|
||||
job.setIsApply(applyCount>0?1:0);
|
||||
//查询收藏信息
|
||||
Long collectionCount = jobCollectionMapper.selectCount(Wrappers.<JobCollection>lambdaQuery().eq(JobCollection::getJobId, jobId).eq(JobCollection::getUserId, SecurityUtils.getUserId()));
|
||||
job.setIsCollection(collectionCount>0?1:0);
|
||||
//todo asyn
|
||||
//保存浏览记录
|
||||
List<AppReviewJob> appReviewJobs = appReviewJobMapper.selectList(Wrappers.<AppReviewJob>lambdaQuery().eq(AppReviewJob::getUserId, SecurityUtils.getUserId()).eq(AppReviewJob::getJobId, jobId));
|
||||
//之前相同岗位的记录删除 保存最新的浏览记录
|
||||
if(!appReviewJobs.isEmpty()){
|
||||
appReviewJobMapper.deleteBatchIds(appReviewJobs.stream().map(AppReviewJob::getId).collect(Collectors.toList()));
|
||||
}
|
||||
AppReviewJob appReviewJob = new AppReviewJob();
|
||||
appReviewJob.setUserId(SecurityUtils.getUserId());
|
||||
appReviewJob.setReviewDate(new Date());
|
||||
appReviewJob.setJobId(jobId);
|
||||
appReviewJobMapper.insert(appReviewJob);
|
||||
}
|
||||
this.view(jobId);
|
||||
return job;
|
||||
}catch (Exception e){
|
||||
return this.selectJobByJobId(jobId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -398,12 +390,9 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
|
||||
@Override
|
||||
public List<ESJobDocument> littleVideo(ESJobSearch esJobSearch) {
|
||||
return iesJobSearchService.littleVideo(esJobSearch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEs() {
|
||||
iesJobSearchService.updateEs();
|
||||
return iesJobSearchService.littleVideo(esJobSearch);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -450,77 +439,12 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
return esJobDocuments;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void importRow() {
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// logger.info("开始导入Excel数据...");
|
||||
//
|
||||
// // 读取Excel文件中的数据
|
||||
// List<RowWork> rowWorks = ExcelToObject.readExcelToObjects("D:\\QD\\青岛市近一个月数据.xlsx", RowWork.class);
|
||||
// logger.info("从Excel中读取到 {} 条数据", rowWorks.size());
|
||||
//
|
||||
// // 从数据库中获取已有的数据
|
||||
// List<RowWork> rowWorksInMysql = jobMapper.selectAllRowWork();
|
||||
// logger.info("从数据库中查询到 {} 条已有数据", rowWorksInMysql.size());
|
||||
//
|
||||
// // 创建一个Set来存储数据库中已有的记录的唯一标识
|
||||
// Set<String> existingRecords = new HashSet<>();
|
||||
// for (RowWork rowWork : rowWorksInMysql) {
|
||||
// String uniqueKey = rowWork.getJobCategory() + "_" + rowWork.getAca112() + "_" + rowWork.getAcb202();
|
||||
// existingRecords.add(uniqueKey);
|
||||
// }
|
||||
// logger.info("已加载 {} 条唯一标识到内存", existingRecords.size());
|
||||
//
|
||||
// // 创建一个列表来收集待插入的数据
|
||||
// List<RowWork> batchList = new ArrayList<>();
|
||||
// int batchSize = 100; // 每批次插入的数量
|
||||
// int totalInserted = 0; // 记录总共插入的数据量
|
||||
//
|
||||
// // 遍历Excel中的数据,进行去重并收集待插入的数据
|
||||
// for (RowWork rowWork : rowWorks) {
|
||||
// String uniqueKey = rowWork.getStd_class() + "_" + rowWork.getAca112() + "_" + rowWork.getAcb202();
|
||||
// if (!existingRecords.contains(uniqueKey)) {
|
||||
// batchList.add(rowWork); // 添加到待插入列表
|
||||
// existingRecords.add(uniqueKey); // 添加到已存在集合,避免重复
|
||||
// // 当待插入列表达到批次大小时,执行批量插入
|
||||
// if (batchList.size() >= batchSize) {
|
||||
// try {
|
||||
// jobMapper.insertBatchRowWork(batchList); // 批量插入
|
||||
// totalInserted += batchList.size();
|
||||
// logger.info("成功插入 {} 条数据,当前总共插入 {} 条数据", batchList.size(), totalInserted);
|
||||
// batchList.clear(); // 清空列表,准备下一批次
|
||||
// } catch (Exception e) {
|
||||
// logger.error("批量插入失败: " + e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 插入剩余的数据(如果不足100条)
|
||||
// if (!batchList.isEmpty()) {
|
||||
// try {
|
||||
// jobMapper.insertBatchRowWork(batchList); // 插入剩余数据
|
||||
// totalInserted += batchList.size();
|
||||
// logger.info("成功插入剩余的 {} 条数据,当前总共插入 {} 条数据", batchList.size(), totalInserted);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("批量插入剩余数据失败: " + e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// logger.info("数据导入完成,总共插入 {} 条数据", totalInserted);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("导入数据过程中发生异常: " + e.getMessage(), e);
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public void importRow() {
|
||||
public void importRow(String path) {
|
||||
try {
|
||||
logger.info("开始导入Excel数据...");
|
||||
// 读取Excel文件中的数据
|
||||
List<RowWork> rowWorks = ExcelToObject.readExcelToObjects("/home/lapuda/Desktop/import.xlsx", RowWork.class);
|
||||
List<RowWork> rowWorks = ExcelToObject.readExcelToObjects(path, RowWork.class);
|
||||
logger.info("从Excel中读取到 {} 条数据", rowWorks.size());
|
||||
|
||||
// 按ORG分类存储数据
|
||||
@@ -651,11 +575,22 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
for (RowWork rowWork : rowWorks) {
|
||||
try {
|
||||
Job job = new Job();
|
||||
if(StringUtil.isEmptyOrNull(rowWork.getAca112())){
|
||||
continue;
|
||||
}
|
||||
job.setJobTitle(rowWork.getAca112());
|
||||
job.setMinSalary(Long.valueOf(rowWork.getSalaryLow()));
|
||||
job.setMaxSalary(Long.valueOf(rowWork.getSalaryHight()));
|
||||
job.setEducation(iBussinessDictDataService.findCode(dictData, rowWork.getAac011()));
|
||||
job.setExperience(iBussinessDictDataService.findCode(expData, rowWork.getExperience()));
|
||||
if(Objects.isNull(rowWork.getAac011())){
|
||||
job.setEducation("-1");
|
||||
}else {
|
||||
job.setEducation(iBussinessDictDataService.findCode(dictData, rowWork.getAac011()));
|
||||
}
|
||||
if(Objects.isNull(rowWork.getExperience())){
|
||||
job.setExperience("0");
|
||||
}else {
|
||||
job.setExperience(iBussinessDictDataService.findCode(expData, rowWork.getExperience()));
|
||||
}
|
||||
job.setCompanyName(rowWork.getAAB004());
|
||||
job.setJobLocation(rowWork.getAAE006());
|
||||
job.setPostingDate(new Date());
|
||||
@@ -673,7 +608,11 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
job.setCompanyId(getCompanyId(allCompany, rowWork.getAAB004()));
|
||||
job.setIsHot(0);
|
||||
job.setApplyNum(0);
|
||||
job.setJobLocationAreaCode(Integer.valueOf(Objects.requireNonNull(iBussinessDictDataService.findCode(areaData, rowWork.getCounty()))));
|
||||
if(Objects.isNull(rowWork.getCounty())){
|
||||
job.setJobLocationAreaCode(null);
|
||||
}else {
|
||||
job.setJobLocationAreaCode(Integer.valueOf(Objects.requireNonNull(iBussinessDictDataService.findCode(areaData, rowWork.getCounty()))));
|
||||
}
|
||||
job.setDescription(rowWork.getAcb22a());
|
||||
job.setIsPublish(1);
|
||||
job.setDataSource(rowWork.getORG());
|
||||
@@ -730,19 +669,28 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
Company companyNew = new Company();
|
||||
companyNew.setName(company.getName());
|
||||
companyNew.setLocation(company.getLocation());
|
||||
companyNew.setScale(iBussinessDictDataService.findCode(scaleData,company.getScale()));
|
||||
if(Objects.isNull(company.getScale())){
|
||||
companyNew.setScale("0");
|
||||
}else {
|
||||
companyNew.setScale(iBussinessDictDataService.findCode(scaleData,company.getScale()));
|
||||
}
|
||||
companyNew.setDelFlag("0");
|
||||
companyNew.setCreateBy("system");
|
||||
companyNew.setCreateTime(new Date());
|
||||
companyNew.setRemark("add");
|
||||
companyNew.setDescription(company.getDescription());
|
||||
companyNew.setIndustry(findIndustry(treeSelects,company));
|
||||
companyNew.setNature(iBussinessDictDataService.findCode(natureData,company.getNature()));
|
||||
if(Objects.isNull(company.getNature())){
|
||||
companyNew.setNature("8");
|
||||
}else {
|
||||
companyNew.setNature(iBussinessDictDataService.findCode(natureData,company.getNature()));
|
||||
}
|
||||
companyList.add(companyNew);
|
||||
}
|
||||
return companyList;
|
||||
}
|
||||
|
||||
|
||||
private String findIndustry(List<TreeSelect> treeSelects, Company company) {
|
||||
if(company.getRemark()==null){return "";}
|
||||
if(Objects.equals(company.getRemark(), "")){return "";}
|
||||
@@ -776,108 +724,5 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
}
|
||||
return jobs;
|
||||
}
|
||||
@Autowired
|
||||
private WechatUtil wechatUtil;
|
||||
@Override
|
||||
public AppWechatEntity getWechatUrl(String weChatUrl) {
|
||||
return wechatUtil.sign(weChatUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String insertTemp(Job job) {
|
||||
String companyName = job.getCompanyName();
|
||||
Company company = new Company();
|
||||
company.setName(companyName);
|
||||
companyMapper.insert(company);
|
||||
job.setCompanyId(company.getCompanyId());
|
||||
this.insertJob(job);
|
||||
System.out.println(job.getJobId());
|
||||
String url = "https://qd.zhaopinzao8dian.com/app#/packageA/pages/post/post?jobId="+Base64.getEncoder().encodeToString(String.valueOf(job.getJobId()).getBytes());
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String htmlGen(Long id) {
|
||||
ESJobDocument esJobDocument = iesJobSearchService.selectById(id);
|
||||
String jobTitle = esJobDocument.getJobTitle();
|
||||
Long maxSalary = esJobDocument.getMaxSalary();
|
||||
Long minSalary = esJobDocument.getMinSalary();
|
||||
String companyName = esJobDocument.getCompanyName();
|
||||
Long vacancies = esJobDocument.getVacancies();
|
||||
|
||||
// 1. 从服务器获取模板文件内容
|
||||
String templateContent = fetchTemplateFromServer();
|
||||
if (templateContent == null || templateContent.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 2. 替换模板中的动态变量
|
||||
String htmlContent = templateContent
|
||||
.replace("${jobTitle}", jobTitle)
|
||||
.replace("${companyName}", companyName)
|
||||
.replace("${minSalary}", String.valueOf(minSalary))
|
||||
.replace("${maxSalary}", String.valueOf(maxSalary))
|
||||
.replace("${vacancies}", String.valueOf(vacancies))
|
||||
.replace("${jobId}", String.valueOf(id));
|
||||
|
||||
// 3. 检查并创建目录
|
||||
String directoryPath = "/data/file/share";
|
||||
String directoryPath_domain = "/file/share";
|
||||
File directory = new File(directoryPath);
|
||||
if (!directory.exists()) {
|
||||
directory.mkdirs();
|
||||
}
|
||||
|
||||
// 4. 生成HTML文件
|
||||
String fileName = "share_" + id + ".html";
|
||||
String filePath = directoryPath + "/" + fileName;
|
||||
File htmlFile = new File(filePath);
|
||||
|
||||
try {
|
||||
// 如果文件已存在,先删除
|
||||
if (htmlFile.exists()) {
|
||||
return "https://qd.zhaopinzao8dian.com/file/share/"+fileName;
|
||||
}
|
||||
|
||||
// 写入新内容
|
||||
FileWriter writer = new FileWriter(htmlFile);
|
||||
writer.write(htmlContent);
|
||||
writer.close();
|
||||
|
||||
return "https://qd.zhaopinzao8dian.com/file/share/"+fileName;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String fetchTemplateFromServer() {
|
||||
String templateUrl = "https://qd.zhaopinzao8dian.com/file/share/template.html";
|
||||
try {
|
||||
URL url = new URL(templateUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
|
||||
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
StringBuilder response = new StringBuilder();
|
||||
String line;
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
return response.toString();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fix() {
|
||||
iesJobSearchService.fix();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user