50 lines
1.3 KiB
Java
50 lines
1.3 KiB
Java
package com.ruoyi.task.reconciliationDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import com.ruoyi.dashboard.service.DashboardService;
|
|
import com.ruoyi.ss.reconciliationDate.domain.ReconciliationDate;
|
|
import com.ruoyi.ss.reconciliationDate.service.ReconciliationDateService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@Component
|
|
@Slf4j
|
|
public class ReconciliationDateTask {
|
|
|
|
|
|
@Autowired
|
|
private DashboardService dashboardService;
|
|
|
|
@Autowired
|
|
private ReconciliationDateService reconciliationDateService;
|
|
|
|
|
|
public void recordReconciliationDate() {
|
|
// 获取昨日日期
|
|
LocalDate now = LocalDate.now();
|
|
LocalDate startDay = now.minusDays(1);
|
|
|
|
while (now.isAfter(startDay)) {
|
|
// 获取昨日对账数据
|
|
ReconciliationDate po = dashboardService.selectReconciliationDateByDate(startDay);
|
|
if (po == null) {
|
|
log.error("{}对账数据不存在", startDay);
|
|
return;
|
|
}
|
|
|
|
// 保存对账数据
|
|
int insert = reconciliationDateService.insertReconciliationDate(po);
|
|
if (insert != 1) {
|
|
log.error("保存对账数据失败,{}", po);
|
|
}
|
|
|
|
startDay = startDay.plusDays(1);
|
|
}
|
|
}
|
|
|
|
}
|