jinpengyong
2021-08-04 a740220c647a1bd4dd83f0751e5e1a73fb00226f
screen-api/src/main/java/com/moral/api/controller/WebController.java
@@ -7,6 +7,8 @@
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -26,9 +28,10 @@
/**
 * web端接口
 * @author  moral
 * @version  v1.0
 * */
 *
 * @author moral
 * @version v1.0
 */
@Slf4j
@Api(tags = {"web端接口"})
@RestController
@@ -53,7 +56,7 @@
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     * */
     */
    @GetMapping("getHourlyAqi")
    @ApiOperation(value = "获取一小时AQI", notes = "获取一小时AQI")
    @ApiImplicitParams(value = {
@@ -72,7 +75,7 @@
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     * */
     */
    @GetMapping("getMonthAvg")
    @ApiOperation(value = "获取某设备某因子本月均值", notes = "获取某设备某因子本月均值")
    @ApiImplicitParams(value = {
@@ -92,7 +95,7 @@
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     * */
     */
    @GetMapping("getWindData")
    @ApiOperation(value = "获取风场数据", notes = "获取风场数据")
    @ApiImplicitParams(value = {
@@ -111,40 +114,38 @@
    }
    /**
     * @param request 请求信息
     * @param params 请求信息
     * @return 返回请求成功后的对象信息
     * */
    @GetMapping("getMacSensors")
    @ApiOperation(value = "根据mac获取对应所有因子", notes = "根据mac获取对应所有因子")
     */
    @PostMapping("getMacSensors")
    @ApiOperation(value = "根据多个mac获取公有因子", notes = "根据多个mac获取公有因子")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String")
            @ApiImplicitParam(name = "macs", value = "设备mac,多个逗号隔开", required = true, paramType = "query", dataType = "List")
    })
    public ResultMessage getMacSensors(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac")) {
    public ResultMessage getMacSensors(@RequestBody Map<String,Object> params) {
        if (!params.containsKey("macs")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> response = deviceService.getSensorsByMac(params.get("mac").toString());
        Map<String, Object> response = deviceService.getSensorsByMac(params);
        return ResultMessage.ok(response);
    }
    /**
     * @param request 请求信息
     * @param params 请求信息
     * @return 返回请求成功后的对象信息
     * */
    @GetMapping("getTrendChartData")
    @ApiOperation(value = "获取监测因子趋势图数据", notes = "获取监测因子趋势图数据")
     */
    @PostMapping("getTrendChartData")
    @ApiOperation(value = "多设备单监测因子趋势图", notes = "多设备单监测因子趋势图.")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "sensorCode", value = "因子code", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "数据类型,日(day),月(month),年(year)", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "数据时间", required = true, paramType = "query", dataType = "String")
            @ApiImplicitParam(name = "macs", value = "设备mac,多个逗号隔开", required = true, paramType = "body", dataType = "list"),
            @ApiImplicitParam(name = "sensorCode", value = "因子code", required = true, paramType = "body", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "数据类型,日(day),月(month),年(year)", required = true, paramType = "body", dataType = "String"),
            @ApiImplicitParam(name = "times", value = "数据时间,日(2021-07-29),月(2021-07),年(2021),多个逗号隔开", required = true, paramType = "body", dataType = "List")
    })
    public ResultMessage getTrendChartData(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac") || !params.containsKey("sensorCode") || !params.containsKey("type") || !params.containsKey("time")) {
    public ResultMessage getTrendChartData(@RequestBody Map<String,Object> params) {
        if (!params.containsKey("macs") || !params.containsKey("sensorCode") || !params.containsKey("type") || !params.containsKey("times")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<Map<String, Object>> response = deviceService.getTrendChartData(params);
@@ -154,7 +155,7 @@
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     * */
     */
    @GetMapping("getMapPath")
    @ApiOperation(value = "获取当前用户地图权限", notes = "获取当前用户地图权限")
    @ApiImplicitParams(value = {