yuan
3 天以前 d2ab6f7153e604bac7bc4ad58f27f368b65d8a1e
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
package com.ruoyi.http.controller;
 
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.http.service.StatisticEleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@Tag(name = "能耗电表统计")
@RequestMapping("/statisticEle")
@RequiredArgsConstructor
public class StatisticEleController extends BaseController {
 
    private final StatisticEleService statisticEleService;
 
    @GetMapping("/list")
    @Operation(summary = "能耗数据-列表查询(本地库)")
    @Log(title = "能耗数据-列表查询", businessType = BusinessType.OTHER)
    public AjaxResult list(
            @RequestParam(defaultValue = "hour") String dimension,
            @RequestParam String startTime,
            @RequestParam String endTime,
            @RequestParam(defaultValue = "1") Integer ignoreRadio) {
        return AjaxResult.success(statisticEleService.listRecords(dimension, startTime, endTime, ignoreRadio));
    }
 
    @GetMapping("/summary")
    @Operation(summary = "能耗数据-汇总统计(本地库)")
    @Log(title = "能耗数据-汇总统计", businessType = BusinessType.OTHER)
    public AjaxResult summary(
            @RequestParam(defaultValue = "hour") String dimension,
            @RequestParam String startTime,
            @RequestParam String endTime) {
        return AjaxResult.success(statisticEleService.getSummary(dimension, startTime, endTime));
    }
 
    @GetMapping("/analytics")
    @Operation(summary = "能耗数据-综合分析")
    public AjaxResult analytics(
            @RequestParam(defaultValue = "day") String dimension,
            @RequestParam String startTime,
            @RequestParam String endTime,
            @RequestParam(required = false) String trendGranularity) {
        return AjaxResult.success(statisticEleService.getAnalytics(dimension, startTime, endTime, trendGranularity));
    }
 
    @GetMapping("/yesterday")
    @Operation(summary = "昨日用电量汇总")
    public AjaxResult yesterday() {
        return AjaxResult.success(statisticEleService.getYesterdaySummary());
    }
 
    @GetMapping("/syncStatus")
    @Operation(summary = "能耗数据-同步状态")
    public AjaxResult syncStatus() {
        return AjaxResult.success(statisticEleService.getSyncStatus());
    }
 
    @GetMapping("/raw")
    @Operation(summary = "能耗数据-原始接口(调试用,慎用)")
    @Log(title = "能耗数据-原始接口", businessType = BusinessType.OTHER)
    public AjaxResult raw(
            @RequestParam(defaultValue = "hour") String dimension,
            @RequestParam String startTime,
            @RequestParam String endTime) {
        return AjaxResult.success(statisticEleService.fetchRawData(dimension, startTime, endTime));
    }
 
    @PostMapping("/export")
    @Operation(summary = "能耗数据-导出")
    @Log(title = "能耗数据-导出", businessType = BusinessType.EXPORT)
    public void export(
            @RequestParam(defaultValue = "hour") String dimension,
            @RequestParam String startTime,
            @RequestParam String endTime,
            HttpServletResponse response) {
        statisticEleService.exportRecords(dimension, startTime, endTime, response);
    }
}