Van333
2022-12-29 d8f66b834134f6b755fd3fb93bb91b56f9d31f6f
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
package api.controller;
 
import api.bean.*;
import api.result.Msg;
import api.service.*;
import com.github.pagehelper.PageInfo;
import com.google.common.util.concurrent.RateLimiter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.HashMap;
import java.util.Map;
 
 
@RestController
@RequestMapping()
public class PhotovoltaicController {
    @Autowired
    private AccessService accessService;
    @Autowired
    private HuinengMachineErrorService huinengMachineErrorService;
    @Autowired
    private PhotovoltaicEntityService photovoltaicEntityService;
    @Autowired
    private PhotovoltaicHeartDataService photovoltaicHeartDataService;
 
    RateLimiter rateLimiter = RateLimiter.create(10.0);
 
 
    /**
     * 光伏主机列表
     * */
    @RequestMapping(value = "/photovoltaic/list")
    public Msg photovoltaicList(@RequestBody ReqParams reqParams){
        rateLimiter.acquire(1);
        if(reqParams.getLimit() > 200){
            return Msg.error("limit exception!!!");
        }
 
        Long userId = accessService.getUserId(reqParams.getAccessToken());
 
        if(userId == null) {
            return Msg.error("server exception");
        }
 
        PageInfo<PhotovoltaicEntity> info = photovoltaicEntityService.list(reqParams.getPage(), reqParams.getLimit(), reqParams.getKey(), userId);
 
//        Map data = new HashMap();
//
//        data.put("total",info.getTotal());
//        data.put("list",info.getList());
 
        return Msg.ok().put("data",info);
 
    }
 
    /**
     * 光伏主机心跳包列表
     * */
    @RequestMapping(value = "/photovoltaicHeartData/list")
    public Msg photovoltaicHeartDataList(@RequestBody ReqParams reqParams){
        rateLimiter.acquire(1);
        if(reqParams.getLimit() > 200){
            return Msg.error("limit exception!!!");
        }
 
        Long userId = accessService.getUserId(reqParams.getAccessToken());
 
        if(userId == null) {
            return Msg.error("server exception");
        }
 
        Pages pages = new Pages();
 
        pages.setPage(reqParams.getPage());
        pages.setSize(reqParams.getLimit());
        pages.setPhotovoltaicId(reqParams.getPhotovoltaicId());
 
        PageInfo<PhotovoltaicHeartData> info = photovoltaicHeartDataService.list(pages, userId);
 
        Map data = new HashMap();
 
//        data.put("total",info.getTotal());
//        data.put("list",info.getList());
 
        return Msg.ok().put("data",info);
 
    }
 
    /**
     * 慧能机故障列表
     * */
    @RequestMapping(value = "/huinengMachineError/list")
    public Msg soilList(@RequestBody ReqParams reqParams){
        rateLimiter.acquire(1);
        if(reqParams.getLimit() > 200){
            return Msg.error("limit exception!!!");
        }
 
        Long userId = accessService.getUserId(reqParams.getAccessToken());
 
        if(userId == null) {
            return Msg.error("server exception");
        }
 
        Pages pages = new Pages();
 
        pages.setPage(reqParams.getPage());
        pages.setSize(reqParams.getLimit());
        pages.setPhotovoltaicId(reqParams.getPhotovoltaicId());
 
        PageInfo<HuinengMachineError> info = huinengMachineErrorService.list(pages, userId);
 
 
//        Map data = new HashMap();
 
//        data.put("total",info.getTotal());
//        data.put("list",info.getList());
 
        return Msg.ok().put("data",info);
 
    }
 
}