添加数据同步代码

This commit is contained in:
hzj
2024-01-10 16:05:09 +08:00
parent ff80efa279
commit 4dcb3af7ae
3 changed files with 8 additions and 1 deletions

View File

@@ -58,6 +58,8 @@ public class JobDetail {
)
@TableField(value = "UPDATE_TIME")
private LocalDateTime updateTime;
@TableField(value = "DURATION")
private Double duration;
@Override
public boolean equals(Object o) {

View File

@@ -11,6 +11,7 @@ import com.njcn.oracle.service.JobDetailService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -32,7 +33,8 @@ public class DataSyncServiceImpl implements DataSyncService {
@Override
@Async
public void dataSync(IReplenishMybatisService executor, String temp, LocalDate date) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
LocalDateTime localDateTime = date.atStartOfDay();
LocalDateTime tempStartTime = LocalDateTimeUtil.beginOfDay(localDateTime);
LocalDateTime tempEndTime = LocalDateTimeUtil.endOfDay(localDateTime);
@@ -69,7 +71,9 @@ public class DataSyncServiceImpl implements DataSyncService {
executor.insertBatchByDB(list);
}
stopWatch.stop();
jobDetail.setState(1);
jobDetail.setDuration(stopWatch.getTotalTimeSeconds());
jobDetail.setUpdateTime(LocalDateTime.now());
jobDetailService.updateByMultiId(jobDetail);
}catch (