|
|
@@ -2,6 +2,8 @@ package org.ruoyi.chat.task;
|
|
|
|
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.ruoyi.chat.service.MedicalRecordQc123Service;
|
|
|
import org.ruoyi.chat.service.chat.PatientRecordService;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
@@ -11,27 +13,32 @@ import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Component
|
|
|
@EnableScheduling
|
|
|
public class PatientDataTask {
|
|
|
|
|
|
@Resource
|
|
|
private PatientRecordService patientRecordService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MedicalRecordQc123Service medicalRecordQc123Service;
|
|
|
+
|
|
|
@Scheduled(cron = "0 30 0 * * ?")
|
|
|
public void savePatientData() {
|
|
|
// 这里实现你的数据获取逻辑
|
|
|
- System.out.println("开始获取数据: " + new Date());
|
|
|
+ log.info("获取数据开始");
|
|
|
try {
|
|
|
LocalDate today = LocalDate.now();
|
|
|
LocalDate previousDay = today.minusDays(1);
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
String previousDayStr = previousDay.format(formatter);
|
|
|
- String startDate = previousDayStr + " 00:00:00";
|
|
|
- String endDate = previousDayStr + " 23:59:59";
|
|
|
- getPatientData(startDate,endDate);
|
|
|
+ String startDate = previousDayStr + " 00:00:00";
|
|
|
+ String endDate = previousDayStr + " 23:59:59";
|
|
|
+ getPatientData(startDate, endDate);
|
|
|
} catch (Exception e) {
|
|
|
// 异常处理
|
|
|
- System.err.println("数据获取失败: " + e.getMessage());
|
|
|
+ log.error("数据获取失败: " + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -39,9 +46,20 @@ public class PatientDataTask {
|
|
|
|
|
|
// 调用服务层,传入参数
|
|
|
patientRecordService.fetchAndSavePatientData(startDate, endDate);
|
|
|
+ }
|
|
|
|
|
|
- // 实现具体的数据获取逻辑
|
|
|
- // 例如:调用API、查询数据库等
|
|
|
+ @Scheduled(cron = "2 30 0 * * ?")
|
|
|
+ public void qcPatientData() {
|
|
|
+ // 这里实现你的数据获取逻辑
|
|
|
+ log.info("开始获取数据: " + new Date());
|
|
|
+ try {
|
|
|
+ int qcCount = medicalRecordQc123Service.processAllUncontrolledRecords();
|
|
|
+ log.info("质控条数为: "+ qcCount);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 异常处理
|
|
|
+ log.error("数据获取失败: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|