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);
|
|
}
|
|
}
|