1.添加根据区划查询code
2.添加上传全疆岗位方法——未完成
This commit is contained in:
@@ -757,6 +757,7 @@ public class CmsJobController extends BaseController
|
|||||||
}
|
}
|
||||||
String path = filePath + File.separator + fileName.replace("profile/upload/", "");
|
String path = filePath + File.separator + fileName.replace("profile/upload/", "");
|
||||||
jobService.importRow(path);
|
jobService.importRow(path);
|
||||||
|
// jobService.importRowOne(path);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,6 @@ public interface SysAreaMapper{
|
|||||||
List<SysArea> getList(SysArea sysArea);
|
List<SysArea> getList(SysArea sysArea);
|
||||||
|
|
||||||
List<SysArea> getCityList(SysArea sysArea);
|
List<SysArea> getCityList(SysArea sysArea);
|
||||||
|
|
||||||
|
SysArea getAreaByName(SysArea sysArea);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ public interface IJobService
|
|||||||
|
|
||||||
void importData();
|
void importData();
|
||||||
|
|
||||||
|
void importDataOne();
|
||||||
|
|
||||||
List<ESJobDocument> recommend(ESJobSearch esJobSearch);
|
List<ESJobDocument> recommend(ESJobSearch esJobSearch);
|
||||||
|
|
||||||
EsPageInfo<ESJobDocument> countyJobList(ESJobSearch job);
|
EsPageInfo<ESJobDocument> countyJobList(ESJobSearch job);
|
||||||
@@ -85,6 +87,8 @@ public interface IJobService
|
|||||||
|
|
||||||
void importRow(String path);
|
void importRow(String path);
|
||||||
|
|
||||||
|
void importRowOne(String path);
|
||||||
|
|
||||||
List<CandidateVO> candidates(Long jobId);
|
List<CandidateVO> candidates(Long jobId);
|
||||||
|
|
||||||
void updateLon();
|
void updateLon();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import com.ruoyi.cms.util.DictUtils;
|
|||||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||||
import com.ruoyi.cms.util.notice.NoticeUtils;
|
import com.ruoyi.cms.util.notice.NoticeUtils;
|
||||||
import com.ruoyi.common.constant.SM4Constants;
|
import com.ruoyi.common.constant.SM4Constants;
|
||||||
import com.ruoyi.common.core.domain.entity.File;
|
import com.ruoyi.common.core.domain.entity.*;
|
||||||
import com.ruoyi.cms.domain.query.ESJobSearch;
|
import com.ruoyi.cms.domain.query.ESJobSearch;
|
||||||
import com.ruoyi.cms.domain.vo.CandidateVO;
|
import com.ruoyi.cms.domain.vo.CandidateVO;
|
||||||
import com.ruoyi.cms.mapper.*;
|
import com.ruoyi.cms.mapper.*;
|
||||||
@@ -22,9 +22,7 @@ import com.ruoyi.cms.util.*;
|
|||||||
import com.ruoyi.common.constant.CacheConstants;
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.TreeSelect;
|
import com.ruoyi.common.core.domain.TreeSelect;
|
||||||
import com.ruoyi.common.core.domain.entity.AppUser;
|
import com.ruoyi.common.core.domain.entity.File;
|
||||||
import com.ruoyi.common.core.domain.entity.Company;
|
|
||||||
import com.ruoyi.common.core.domain.entity.JobTitle;
|
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.*;
|
import com.ruoyi.common.utils.*;
|
||||||
@@ -95,6 +93,8 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
|||||||
private CompanyCollectionMapper companyCollectionMapper;
|
private CompanyCollectionMapper companyCollectionMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private NoticeMapper noticeMapper;
|
private NoticeMapper noticeMapper;
|
||||||
|
@Autowired
|
||||||
|
private SysAreaMapper sysAreaMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新工作地址的经纬度信息
|
* 更新工作地址的经纬度信息
|
||||||
@@ -894,6 +894,58 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void importRowOne(String path) {
|
||||||
|
try {
|
||||||
|
logger.info("开始导入Excel数据...");
|
||||||
|
//先清理旧数据
|
||||||
|
Long oldDataNum = jobMapper.delRowWork();
|
||||||
|
logger.info("删除旧的row-work..." + oldDataNum);
|
||||||
|
logger.info("文件路径path..." + path);
|
||||||
|
// 读取Excel文件中的数据
|
||||||
|
List<RowWork> rowWorks = ExcelToObject.readExcelToObjects(path, RowWork.class);
|
||||||
|
logger.info("从Excel中读取到 {} 条数据", rowWorks.size());
|
||||||
|
|
||||||
|
// 批量插入数据
|
||||||
|
int batchSize = 50;
|
||||||
|
int totalInserted = 0;
|
||||||
|
List<RowWork> batchList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (RowWork rowWork : rowWorks) {
|
||||||
|
// Thread.sleep(500); // 控制处理速度(可选)
|
||||||
|
batchList.add(rowWork);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入剩余数据
|
||||||
|
if (!batchList.isEmpty()) {
|
||||||
|
try {
|
||||||
|
jobMapper.insertBatchRowWork(batchList);
|
||||||
|
totalInserted += batchList.size();
|
||||||
|
logger.info("成功插入剩余的 {} 条数据,当前总共插入 {} 条数据", batchList.size(), totalInserted);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("批量插入剩余数据失败: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//插入岗位表
|
||||||
|
importDataOne();
|
||||||
|
logger.info("数据导入完成,总共插入 {} 条数据", totalInserted);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("导入数据过程中发生异常: " + e.getMessage(), e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importData() {
|
public void importData() {
|
||||||
try {
|
try {
|
||||||
@@ -1080,6 +1132,207 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
|||||||
iesJobSearchService.resetTextCache();
|
iesJobSearchService.resetTextCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void importDataOne() {
|
||||||
|
try {
|
||||||
|
logger.info("开始导入数据...");
|
||||||
|
|
||||||
|
// 获取字典数据
|
||||||
|
List<BussinessDictData> dictData = iBussinessDictTypeService.selectDictDataByType("education");
|
||||||
|
List<BussinessDictData> expData = iBussinessDictTypeService.selectDictDataByType("experience");
|
||||||
|
List<BussinessDictData> areaData = iBussinessDictTypeService.selectDictDataByType("area");
|
||||||
|
logger.info("成功获取字典数据: education={}, experience={}, area={}", dictData.size(), expData.size(), areaData.size());
|
||||||
|
|
||||||
|
// 获取需要插入的行数据
|
||||||
|
List<RowWork> rowWorks = this.baseMapper.selectAllInsertRowWork();
|
||||||
|
logger.info("从数据库中获取到 {} 条待插入的行数据", rowWorks.size());
|
||||||
|
|
||||||
|
// 获取公司数据并转换
|
||||||
|
List<Company> companyRowList = this.baseMapper.selectRowCompany();
|
||||||
|
List<Company> companyList = company2New(companyRowList);
|
||||||
|
logger.info("成功转换 {} 条公司数据", companyList.size());
|
||||||
|
|
||||||
|
// 批量插入公司数据
|
||||||
|
int batchSizeCompany = 50; // 每批次插入50条数据
|
||||||
|
List<Company> companyBatch = new ArrayList<>();
|
||||||
|
int totalCompanyInserted = 0;
|
||||||
|
|
||||||
|
for (Company company : companyList) {
|
||||||
|
companyBatch.add(company);
|
||||||
|
if (companyBatch.size() == batchSizeCompany) {
|
||||||
|
companyMapper.batchInsert(companyBatch); // 批量插入
|
||||||
|
totalCompanyInserted += companyBatch.size();
|
||||||
|
logger.info("成功插入 {} 条公司数据,当前总共插入 {} 条", companyBatch.size(), totalCompanyInserted);
|
||||||
|
companyBatch.clear(); // 清空批次
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入剩余的记录
|
||||||
|
if (!companyBatch.isEmpty()) {
|
||||||
|
companyMapper.batchInsert(companyBatch);
|
||||||
|
totalCompanyInserted += companyBatch.size();
|
||||||
|
logger.info("成功插入剩余的 {} 条公司数据,当前总共插入 {} 条", companyBatch.size(), totalCompanyInserted);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有公司数据
|
||||||
|
List<Company> allCompany = companyMapper.selectCompanyList(new Company());
|
||||||
|
logger.info("从数据库中获取到 {} 条公司数据", allCompany.size());
|
||||||
|
|
||||||
|
// 批量插入职位数据
|
||||||
|
List<Job> jobBatch = new ArrayList<>();
|
||||||
|
int batchSize = 50;
|
||||||
|
int totalJobInserted = 0;
|
||||||
|
String string = UUID.randomUUID().toString();
|
||||||
|
logger.info("生成唯一标识符: {}", string);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
String formattedDate = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
Job jobOne = null;
|
||||||
|
int repeatJobCount = 0;
|
||||||
|
List<String> repeatJobInfoList = new ArrayList<>();
|
||||||
|
for (RowWork rowWork : rowWorks) {
|
||||||
|
try {
|
||||||
|
Job job = new Job();
|
||||||
|
if(StringUtil.isEmptyOrNull(rowWork.getAca112())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//去重
|
||||||
|
jobOne = jobMapper.selectOne(Wrappers.lambdaQuery(Job.class).eq(Job::getJobTitle, rowWork.getAca112()).eq(Job::getMinSalary, Long.valueOf(rowWork.getSalaryLow())).eq(Job::getMaxSalary, rowWork.getSalaryHight())
|
||||||
|
.eq(Job::getCompanyName, rowWork.getAAB004()).eq(Job::getJobLocation, rowWork.getAAE006()).orderByDesc(Job::getCreateTime).last("LIMIT 1"));
|
||||||
|
if (jobOne != null) {
|
||||||
|
//统计重复
|
||||||
|
repeatJobCount++;
|
||||||
|
String repeatInfo = String.format("岗位名称:%s,公司:%s,地点:%s,薪资区间:%s-%s",
|
||||||
|
rowWork.getAca112(),
|
||||||
|
rowWork.getAAB004(),
|
||||||
|
rowWork.getAAE006(),
|
||||||
|
rowWork.getSalaryLow(),
|
||||||
|
rowWork.getSalaryHight());
|
||||||
|
repeatJobInfoList.add(repeatInfo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
job.setJobTitle(rowWork.getAca112());
|
||||||
|
job.setMinSalary(Long.valueOf(rowWork.getSalaryLow()));
|
||||||
|
job.setMaxSalary(Long.valueOf(rowWork.getSalaryHight()));
|
||||||
|
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(formattedDate);
|
||||||
|
job.setJobCategory(rowWork.getJobCategory());
|
||||||
|
if (rowWork.getAcb240() == null) {
|
||||||
|
job.setVacancies(-1L);
|
||||||
|
} else {
|
||||||
|
String v = rowWork.getAcb240().replace("人", "").replace("以上", "");
|
||||||
|
if (v.contains("若干")) {
|
||||||
|
job.setVacancies(20L);
|
||||||
|
}else if (org.apache.commons.lang3.StringUtils.isNotEmpty(v) && v.contains("-")) {
|
||||||
|
v = v.split("-")[1];
|
||||||
|
job.setVacancies(org.apache.commons.lang3.StringUtils.isNotEmpty(v) ? Long.valueOf(v) : -1L);
|
||||||
|
}else {
|
||||||
|
job.setVacancies(org.apache.commons.lang3.StringUtils.isNotEmpty(v) ? Long.valueOf(v) : -1L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rowWork.getLatitude() != null && !rowWork.getLatitude().isEmpty()) {
|
||||||
|
job.setLatitude(new BigDecimal(rowWork.getLatitude()));
|
||||||
|
job.setLongitude(new BigDecimal(rowWork.getLongitude()));
|
||||||
|
}
|
||||||
|
job.setView(0L);
|
||||||
|
job.setCompanyId(getCompanyId(allCompany, rowWork.getAAB004()));
|
||||||
|
job.setIsHot(0);
|
||||||
|
job.setApplyNum(0);
|
||||||
|
if(Objects.isNull(rowWork.getCounty())){
|
||||||
|
job.setJobLocationAreaCode(null);
|
||||||
|
job.setRegionCode(null);
|
||||||
|
}else {
|
||||||
|
String countyName = rowWork.getCounty();
|
||||||
|
String provName = rowWork.getProvince();
|
||||||
|
String areaCode = null;
|
||||||
|
areaCode = iBussinessDictDataService.findCode(areaData, countyName);
|
||||||
|
if (Objects.isNull(areaCode)) {
|
||||||
|
SysArea sysAreaParm = new SysArea();
|
||||||
|
sysAreaParm.setParentName(provName);
|
||||||
|
sysAreaParm.setName(countyName);
|
||||||
|
SysArea sysArea = sysAreaMapper.getAreaByName(sysAreaParm);
|
||||||
|
if (Objects.nonNull(sysArea) && StringUtils.isNotBlank(sysArea.getCode())) {
|
||||||
|
areaCode = sysArea.getCode();
|
||||||
|
}
|
||||||
|
job.setRegionCode(areaCode);
|
||||||
|
job.setJobLocationAreaCode(areaCode);
|
||||||
|
}else{
|
||||||
|
job.setJobLocationAreaCode(areaCode);
|
||||||
|
job.setRegionCode(StringUtil.getAreaToRegionCode(areaCode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
job.setDescription(rowWork.getAcb22a());
|
||||||
|
job.setIsPublish(1);
|
||||||
|
//job.setDataSource(rowWork.getORG());
|
||||||
|
job.setDataSource("4");//互联网抓取
|
||||||
|
job.setJobUrl(rowWork.getACE760());
|
||||||
|
job.setRemark(string);
|
||||||
|
job.setDelFlag("0");
|
||||||
|
job.setCreateBy(string);
|
||||||
|
job.setCreateTime(formattedDate);
|
||||||
|
job.setRowId(Long.valueOf(rowWork.getId()));
|
||||||
|
job.setJobStatus(StringUtil.HIRE_LY);//上架
|
||||||
|
job.setDownTime(DateUtils.getMonthThree(DateUtils.YYYY_MM_DD_HH_MM_SS));//下架时间当前时间+3个月
|
||||||
|
if(StringUtils.isBlank(job.getJobLocationAreaCode())){
|
||||||
|
job.setRegionCode(StringUtil.getAreaToRegionCode(job.getJobLocationAreaCode()));//行政区划
|
||||||
|
}
|
||||||
|
|
||||||
|
jobBatch.add(job);
|
||||||
|
|
||||||
|
// 当批次达到50条时,执行批量插入
|
||||||
|
if (jobBatch.size() == batchSize) {
|
||||||
|
this.baseMapper.batchInsert(jobBatch);
|
||||||
|
totalJobInserted += jobBatch.size();
|
||||||
|
logger.info("成功插入 {} 条职位数据,当前总共插入 {} 条", jobBatch.size(), totalJobInserted);
|
||||||
|
jobBatch.clear(); // 清空批次
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("处理职位数据时发生异常: {}", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入剩余的记录
|
||||||
|
if (!jobBatch.isEmpty()) {
|
||||||
|
this.baseMapper.batchInsert(jobBatch);
|
||||||
|
totalJobInserted += jobBatch.size();
|
||||||
|
logger.info("成功插入剩余的 {} 条职位数据,当前总共插入 {} 条", jobBatch.size(), totalJobInserted);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("数据导入完成,总共插入 {} 条公司数据和 {} 条职位数据", totalCompanyInserted, totalJobInserted);
|
||||||
|
Job job = jobMapper.selectOne(Wrappers.lambdaQuery(Job.class).eq(Job::getCreateTime, formattedDate).last("LIMIT 1"));
|
||||||
|
if (job != null) {
|
||||||
|
logger.info("存在新插入的数据,日期为:" + formattedDate);
|
||||||
|
} else {
|
||||||
|
logger.info("不存在新插入的数据:");
|
||||||
|
}
|
||||||
|
System.out.println("====================岗位重复统计结果====================");
|
||||||
|
System.out.println("本次导入重复岗位总数量:" + repeatJobCount);
|
||||||
|
if (repeatJobCount > 0) {
|
||||||
|
System.out.println("重复岗位明细列表:");
|
||||||
|
for (String info : repeatJobInfoList) {
|
||||||
|
System.out.println(info);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("本次导入无重复岗位");
|
||||||
|
}
|
||||||
|
System.out.println("========================================================");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("导入数据过程中发生异常: {}", e.getMessage(), e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
// iesJobSearchService.resetTextCache();
|
||||||
|
}
|
||||||
|
|
||||||
private Long getCompanyId(List<Company> allCompany, String aab004) {
|
private Long getCompanyId(List<Company> allCompany, String aab004) {
|
||||||
for (Company company:allCompany){
|
for (Company company:allCompany){
|
||||||
if(company.getName().equals(aab004)){
|
if(company.getName().equals(aab004)){
|
||||||
|
|||||||
@@ -33,4 +33,11 @@
|
|||||||
SELECT sa.*,get_name_first_pinyin(sa.name) AS zm FROM sys_area sa INNER JOIN top_area ta ON sa.parent_code = ta.code WHERE ta.is_municipality = FALSE
|
SELECT sa.*,get_name_first_pinyin(sa.name) AS zm FROM sys_area sa INNER JOIN top_area ta ON sa.parent_code = ta.code WHERE ta.is_municipality = FALSE
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getAreaByName" resultType="com.ruoyi.common.core.domain.entity.SysArea" parameterType="com.ruoyi.common.core.domain.entity.SysArea">
|
||||||
|
SELECT t.* FROM(WITH RECURSIVE area_tree AS (SELECT code, name, parent_code, del_flag FROM sys_area WHERE del_flag = '0' AND name = #{parentName}
|
||||||
|
UNION ALL SELECT child.code, child.name, child.parent_code, child.del_flag FROM sys_area child
|
||||||
|
INNER JOIN area_tree p ON child.parent_code = p.code WHERE child.del_flag = '0') SELECT code, name, parent_code, del_flag FROM area_tree WHERE name = #{name}
|
||||||
|
UNION ALL SELECT code, name, parent_code, del_flag FROM sys_area WHERE del_flag = '0' AND name = #{name} AND code NOT IN (SELECT code FROM area_tree WHERE name = #{name})) t LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ public class SysArea extends BaseEntity {
|
|||||||
@ApiModelProperty("父级地区编码(顶级为NULL)")
|
@ApiModelProperty("父级地区编码(顶级为NULL)")
|
||||||
private String parentCode;
|
private String parentCode;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty("父级名称")
|
||||||
|
private String parentName;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@ApiModelProperty("字母")
|
@ApiModelProperty("字母")
|
||||||
private String zm;
|
private String zm;
|
||||||
|
|||||||
Reference in New Issue
Block a user