添加自动补招数据外部接口
This commit is contained in:
@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
@@ -67,7 +68,13 @@ public class DataRecallController extends BaseController {
|
|||||||
List<String> guidList = new ArrayList<>();
|
List<String> guidList = new ArrayList<>();
|
||||||
List<String> runMonitorIds = new ArrayList<>();
|
List<String> runMonitorIds = new ArrayList<>();
|
||||||
List<RecallMessage.RecallDTO> recallDTOList = new ArrayList<>();
|
List<RecallMessage.RecallDTO> recallDTOList = new ArrayList<>();
|
||||||
|
Duration duration = Duration.between(param.getReCallStartTime(), param.getReCallEndTime());
|
||||||
|
// 获取剩余的分钟数,如果要精确到分钟可以这样做
|
||||||
|
long minutes = duration.toMinutes() ;
|
||||||
|
if(minutes>60){
|
||||||
|
throw new BusinessException("全量补招时间区间不能超过一个小时");
|
||||||
|
|
||||||
|
}
|
||||||
if(CollectionUtils.isEmpty(param.getMonitorId())){
|
if(CollectionUtils.isEmpty(param.getMonitorId())){
|
||||||
throw new BusinessException("请选择监测点");
|
throw new BusinessException("请选择监测点");
|
||||||
}else {
|
}else {
|
||||||
@@ -251,6 +258,23 @@ public class DataRecallController extends BaseController {
|
|||||||
return start.format(formatter) + "~" + end.format(formatter);
|
return start.format(formatter) + "~" + end.format(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 创建两个LocalDateTime对象
|
||||||
|
LocalDateTime dateTime1 = LocalDateTime.of(2023, 1, 1, 10, 0); // 例如:2023年1月1日 10:00
|
||||||
|
LocalDateTime dateTime2 = LocalDateTime.of(2023, 1, 2, 15, 30); // 例如:2023年1月1日 15:30
|
||||||
|
|
||||||
|
// 使用Duration计算两个时间之间的差异
|
||||||
|
Duration duration = Duration.between(dateTime1, dateTime2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 获取剩余的分钟数,如果要精确到分钟可以这样做
|
||||||
|
long minutes = duration.toMinutes() ;
|
||||||
|
|
||||||
|
// 输出结果
|
||||||
|
System.out.println("时间差(分钟): " + minutes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
package com.njcn.dataProcess.job;
|
|
||||||
|
|
||||||
import com.njcn.dataProcess.controller.DataRecallController;
|
|
||||||
import com.njcn.message.message.RecallMessage;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.temporal.ChronoUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description:
|
|
||||||
* Date: 2025/07/24 下午 2:22【需求编号】
|
|
||||||
*
|
|
||||||
* @author clam
|
|
||||||
* @version V1.0.0
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@EnableScheduling
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
|
||||||
public class DataRecallJob {
|
|
||||||
private final DataRecallController dataRecallController;
|
|
||||||
@Scheduled(cron="0 50 14 * * ?")
|
|
||||||
public void executeHours() {
|
|
||||||
RecallMessage param = new RecallMessage();
|
|
||||||
param.setReCallStartTime(LocalDate.now().minusDays(1));
|
|
||||||
param.setReCallEndTime(LocalDate.now());
|
|
||||||
dataRecallController.recall(param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user