You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.9 KiB
Java
51 lines
1.9 KiB
Java
package com.docus.demo.job;
|
|
|
|
import com.docus.demo.dto.SyncBasicDataDto;
|
|
import com.docus.demo.facade.ISyncBasicDataService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.temporal.TemporalAdjusters;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
/**
|
|
* @author YongBin Wen
|
|
* @date 2025/4/23 0023 17:13
|
|
*/
|
|
@Component
|
|
@Slf4j
|
|
public class GzFirstHospBasicSyncJob {
|
|
|
|
@Autowired
|
|
private ISyncBasicDataService syncBasicDataService;
|
|
private AtomicBoolean isRunning = new AtomicBoolean(false);
|
|
|
|
@Scheduled(cron = "0 0 0/12 * * ?")
|
|
public void syncOneMonthData() {
|
|
if (isRunning.compareAndSet(false, true)) {
|
|
LocalDate today = LocalDate.now();
|
|
LocalDate firstDayOfLastMonth = today.minusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
|
|
SyncBasicDataDto dto = new SyncBasicDataDto();
|
|
dto.setStartDate(firstDayOfLastMonth.toString());
|
|
dto.setEndDate(today.toString());
|
|
dto.setLimit(1000);
|
|
log.info("广州市第一人民医院,同步省厅基础数据,日期:{} —— {}", firstDayOfLastMonth, today);
|
|
try {
|
|
syncBasicDataService.syncBasicData(dto);
|
|
log.info("广州市第一人民医院,同步省厅基础数据,日期:" + firstDayOfLastMonth + "—— " + today + ",同步完成!");
|
|
} catch (Exception ex) {
|
|
log.info("广州市第一人民医院,同步省厅基础数据,日期:" + firstDayOfLastMonth + "—— " + today + ",出现异常:" + ex.getMessage(), ex);
|
|
} finally {
|
|
isRunning.set(false);
|
|
}
|
|
} else {
|
|
log.warn("广州市第一人民医院,同步省厅基础数据正在调度!");
|
|
}
|
|
|
|
}
|
|
|
|
}
|