cjl
10 hours ago bcc076d63c5c2ff473adb5ac15ea242559086000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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();
    }
}