修改互联网抓取岗位上传

This commit is contained in:
sh
2026-06-25 11:37:19 +08:00
parent 7d09bd59e3
commit 21fccf991c

View File

@@ -887,7 +887,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
}
}
//插入岗位表
// importData();
importData();
logger.info("数据导入完成,总共插入 {} 条数据", totalInserted);
} catch (Exception e) {
logger.error("导入数据过程中发生异常: " + e.getMessage(), e);
@@ -949,6 +949,8 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
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();
@@ -959,6 +961,15 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
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());
@@ -1014,6 +1025,10 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
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);
@@ -1043,6 +1058,17 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
} 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);