2026-01-09 20:13:01 +08:00
|
|
|
|
package com.ruoyi.cms.cron;
|
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.cms.mapper.JobMapper;
|
|
|
|
|
|
import com.ruoyi.cms.service.IBussinessOperLogService;
|
|
|
|
|
|
import com.ruoyi.cms.service.ICompanyService;
|
|
|
|
|
|
import com.ruoyi.cms.service.IESJobSearchService;
|
|
|
|
|
|
import com.ruoyi.cms.service.IJobService;
|
2026-07-16 10:02:56 +08:00
|
|
|
|
import com.ruoyi.cms.service.IJobTitleSuggestService;
|
2026-07-21 16:17:07 +08:00
|
|
|
|
import com.ruoyi.cms.externalimport.ExternalJobImportProperties;
|
|
|
|
|
|
import com.ruoyi.cms.externalimport.ExternalJobImportResult;
|
|
|
|
|
|
import com.ruoyi.cms.externalimport.ExternalJobImportRunLog;
|
2026-07-21 14:56:47 +08:00
|
|
|
|
import com.ruoyi.cms.externalimport.IExternalJobImportService;
|
2026-01-09 20:13:01 +08:00
|
|
|
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
2026-07-21 16:17:07 +08:00
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
2026-01-09 20:13:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class JobCron {
|
2026-07-21 16:17:07 +08:00
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(JobCron.class);
|
|
|
|
|
|
|
2026-01-09 20:13:01 +08:00
|
|
|
|
public void isHot(){
|
|
|
|
|
|
SpringUtils.getBean(JobMapper.class).isHot();
|
|
|
|
|
|
}
|
|
|
|
|
|
public void resetEs(){
|
|
|
|
|
|
SpringUtils.getBean(IESJobSearchService.class).resetTextCache();
|
|
|
|
|
|
}
|
|
|
|
|
|
//查看索引是否存在,如果不存在,就更新
|
|
|
|
|
|
public void checkEsAndFix(){
|
|
|
|
|
|
SpringUtils.getBean(IESJobSearchService.class).checkEsAndFix();
|
|
|
|
|
|
}
|
|
|
|
|
|
//更新公司的招聘数量
|
|
|
|
|
|
public void updateJobCountOfCompany(){
|
|
|
|
|
|
SpringUtils.getBean(ICompanyService.class).updateJobCountOfCompany();
|
|
|
|
|
|
}
|
2026-07-16 10:02:56 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 重建岗位名称联想缓存。
|
|
|
|
|
|
* Quartz 任务调用目标:jobCron.rebuildJobTitleSuggest()
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void rebuildJobTitleSuggest(){
|
|
|
|
|
|
SpringUtils.getBean(IJobTitleSuggestService.class).rebuildCache();
|
|
|
|
|
|
}
|
2026-07-21 14:56:47 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 外部 Excel 全量快照同步。
|
2026-07-21 16:17:07 +08:00
|
|
|
|
* Quartz 调用目标:com.ruoyi.cms.cron.JobCron.importLatestExternalSnapshot()
|
2026-07-21 14:56:47 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public void importLatestExternalSnapshot(){
|
2026-07-21 16:17:07 +08:00
|
|
|
|
ExternalJobImportProperties properties = SpringUtils.getBean(ExternalJobImportProperties.class);
|
|
|
|
|
|
ExternalJobImportRunLog runLog = ExternalJobImportRunLog.open(properties.getRunLogDirectory());
|
|
|
|
|
|
LOGGER.info("外部岗位全量同步开始,runId={},独立日志={}", runLog.getRunId(), runLog.getFile());
|
|
|
|
|
|
try {
|
|
|
|
|
|
runLog.info("开始执行外部岗位 Excel 全量快照同步");
|
|
|
|
|
|
ExternalJobImportResult result = SpringUtils.getBean(IExternalJobImportService.class).importLatest();
|
|
|
|
|
|
runLog.info("执行完成;status=" + result.getStatus()
|
|
|
|
|
|
+ ";batchId=" + safe(result.getBatchId())
|
|
|
|
|
|
+ ";totalRows=" + result.getTotalRows()
|
|
|
|
|
|
+ ";validRows=" + result.getValidRows()
|
|
|
|
|
|
+ ";invalidRows=" + result.getInvalidRows()
|
|
|
|
|
|
+ ";duplicateRows=" + result.getDuplicateRows()
|
|
|
|
|
|
+ ";insertCount=" + result.getInsertCount()
|
|
|
|
|
|
+ ";updateCount=" + result.getUpdateCount()
|
|
|
|
|
|
+ ";keepCount=" + result.getKeepCount()
|
|
|
|
|
|
+ ";restoreCount=" + result.getRestoreCount()
|
|
|
|
|
|
+ ";deleteCount=" + result.getDeleteCount()
|
|
|
|
|
|
+ ";message=" + safe(result.getMessage()));
|
|
|
|
|
|
LOGGER.info("外部岗位全量同步结束,runId={},status={},batchId={}",
|
|
|
|
|
|
runLog.getRunId(), result.getStatus(), result.getBatchId());
|
|
|
|
|
|
} catch (RuntimeException ex) {
|
|
|
|
|
|
runLog.error("执行失败", ex);
|
|
|
|
|
|
LOGGER.error("外部岗位全量同步失败,runId={},独立日志={}", runLog.getRunId(), runLog.getFile(), ex);
|
|
|
|
|
|
throw ex;
|
|
|
|
|
|
} catch (Error error) {
|
|
|
|
|
|
runLog.error("执行发生 JVM 错误", error);
|
|
|
|
|
|
LOGGER.error("外部岗位全量同步发生 JVM 错误,runId={},独立日志={}", runLog.getRunId(), runLog.getFile(), error);
|
|
|
|
|
|
throw error;
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
runLog.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String safe(String value) {
|
|
|
|
|
|
return value == null ? "" : value.replace('\r', ' ').replace('\n', ' ');
|
2026-07-21 14:56:47 +08:00
|
|
|
|
}
|
2026-01-09 20:13:01 +08:00
|
|
|
|
}
|