package com.moral.api.controller;
|
|
import com.moral.api.service.RadarHourlySummaryService;
|
import com.moral.constant.ResultMessage;
|
import io.swagger.annotations.Api;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.time.LocalDateTime;
|
import java.time.format.DateTimeFormatter;
|
|
/**
|
* @ClassName RadarProcessController
|
* @Description TODO
|
* @Author @cjl
|
* @Date 2026-09-08 14:12
|
* @Version 1.0
|
*/
|
@Slf4j
|
@Api(tags = {"雷达"})
|
@RestController
|
@RequestMapping("/radar")
|
public class RadarProcessController {
|
|
@Autowired
|
private RadarHourlySummaryService hourlySummaryService;
|
|
/**
|
* 处理上一完整小时
|
* GET /radar/process-last
|
*/
|
@GetMapping("/process-last")
|
public ResultMessage processLastHour() {
|
hourlySummaryService.processLastHour();
|
return new ResultMessage();
|
|
}
|
|
/**
|
* 处理指定小时
|
* GET /radar/process?hour=2026-09-08 09:00:00
|
*/
|
@GetMapping("/process")
|
public ResultMessage processHour() {
|
String startStr = "2026-05-31 23:00:00";
|
String endStr = "2026-09-08 14:00:00";
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
LocalDateTime startTime = LocalDateTime.parse(startStr, formatter);
|
LocalDateTime endTime = LocalDateTime.parse(endStr, formatter);
|
LocalDateTime current = startTime;
|
while (!current.isAfter(endTime)) {
|
// 将当前时间格式化为字符串并加入列表
|
hourlySummaryService.processHour(current.format(formatter));
|
// 时间增加 1 小时
|
current = current.plusHours(1);
|
}
|
|
return new ResultMessage();
|
}
|
|
@GetMapping("/process1")
|
public ResultMessage processHour1() {
|
String startStr = "2026-09-01 00:00:00";
|
hourlySummaryService.processHour(startStr);
|
return new ResultMessage();
|
}
|
}
|