feiyu02
2025-09-04 707b00a0ca6604c249a110b376ac1e44e408e624
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.flightfeather.uav.lightshare.web
 
import com.fasterxml.jackson.annotation.JsonFormat
import com.flightfeather.uav.lightshare.bean.AreaVo
import com.flightfeather.uav.lightshare.service.DataAnalysisService
import com.flightfeather.uav.socket.eunm.FactorType
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.format.annotation.DateTimeFormat
import org.springframework.web.bind.annotation.*
import java.time.LocalDateTime
import java.time.ZoneId
import java.util.*
 
/**
 * 走航数据分析
 * @date 2025/5/8
 * @author feiyu02
 */
@Api(tags = ["走航数据分析API接口"])
@RestController
@RequestMapping("air/analysis")
class DataAnalysisController(private val dataAnalysisService: DataAnalysisService) {
 
    @ApiOperation(value = "污染溯源分析")
    @GetMapping("/pollution/trace")
    fun pollutionTrace(
        @ApiParam("走航任务编号") @RequestParam missionCode: String,
//        @RequestParam("page", required = false) page: Int?,
//        @RequestParam("per_page", required = false) perPage: Int?,
    ) = resPack { dataAnalysisService.pollutionTrace(missionCode) }
 
    @ApiOperation(value = "获取历史污染溯源结果")
    @GetMapping("/pollution/trace/history")
    fun fetchHistory(
        @ApiParam("走航任务编号") @RequestParam missionCode: String,
    ) = resPack { dataAnalysisService.fetchHistory(missionCode) }
 
    @ApiOperation(value = "生成走航任务汇总统计")
    @PostMapping("/report/missionSummary")
    fun generateMissionSummary(
        @ApiParam("开始时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        startTime: LocalDateTime,
        @ApiParam("结束时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        endTime: LocalDateTime,
        @ApiParam("区域") @RequestBody areaVo: AreaVo,
    ) = resPack {
        dataAnalysisService.generateMissionSummary(
            Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()),
            Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant()),
            areaVo
        )
    }
 
    @ApiOperation(value = "生成走航任务清单")
    @PostMapping("/report/missionList")
    fun generateMissionList(
        @ApiParam("开始时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        startTime: LocalDateTime,
        @ApiParam("结束时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        endTime: LocalDateTime,
        @ApiParam("区域") @RequestBody areaVo: AreaVo,
    ) = resPack {
        dataAnalysisService.generateMissionList(
            Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()),
            Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant()),
            areaVo
        )
    }
 
    @ApiOperation(value = "生成走航任务详情")
    @PostMapping("/report/missionDetail")
    fun generateMissionDetail(
        @ApiParam("开始时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        startTime: LocalDateTime,
        @ApiParam("结束时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        endTime: LocalDateTime,
        @ApiParam("区域") @RequestBody areaVo: AreaVo,
    ) = resPack {
        dataAnalysisService.generateMissionDetail(
            Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()),
            Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant()),
            areaVo
        )
    }
 
    @ApiOperation(value = "走航典型隐患区域统计")
    @PostMapping("/report/clueByRiskArea")
    fun generateClueByRiskArea(
        @ApiParam("开始时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        startTime: LocalDateTime,
        @ApiParam("结束时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        endTime: LocalDateTime,
        @ApiParam("区域") @RequestBody areaVo: AreaVo,
    ) = resPack {
        dataAnalysisService.generateClueByRiskArea(
            Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()),
            Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant()),
            areaVo
        )
    }
 
    @ApiOperation(value = "叠加融合分析")
    @PostMapping("/report/gridFusion")
    fun generateGridFusion(
        @ApiParam("开始时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        startTime: LocalDateTime,
        @ApiParam("结束时间") @RequestParam
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        endTime: LocalDateTime,
        @ApiParam("需要统计的监测因子", example = "NO2, CO") @RequestParam
        factorTypes: String,
        @ApiParam("区域") @RequestBody areaVo: AreaVo,
    ) = resPack {
        dataAnalysisService.generateGridFusion(
            factorTypes.split(",").map { FactorType.valueOf(it) },
            Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()),
            Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant()),
            areaVo
        )
    }
}