jinpengyong
2023-04-12 fc8fe626f222e024c1c4b45759ef0102174e5b9c
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
package com.moral.api.controller;
 
import com.moral.api.pojo.dto.historyFiveMinutely.DeviceAndFiveMinuteDataDTO;
import com.moral.api.pojo.form.historyFiveMinutely.QueryDeviceAndFiveMinuteDataForm;
import com.moral.api.pojo.vo.historyFiveMinutely.DeviceAndFiveMinuteDataVO;
import com.moral.api.service.HistoryFiveMinutelyService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
 
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * @ClassName HistoryFiveMinutely
 * @Description TODO
 * @Author 陈凯裕
 * @Date 2021/7/15 16:42
 * @Version TODO
 **/
 
@Slf4j
@Api(tags = {"五分钟数据控制器"})
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/historyFiveMinutely")
public class HistoryFiveMinutelyController {
 
    @Autowired
    HistoryFiveMinutelyService historyFiveMinutelyService;
 
    /**
    * @Description: 查询组织区域对应的设备以及对应因子的五分钟数据
            * @Param: [form]
            * @return: com.moral.constant.ResultMessage
            * @Author: 陈凯裕
            * @Date: 2022/3/10
            */
    @GetMapping("queryDeviceAndData")
    public ResultMessage queryDeviceAndData(QueryDeviceAndFiveMinuteDataForm form){
        //判断是否缺少参数
        if (!form.valid())
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
 
        //处理查询业务
        List<DeviceAndFiveMinuteDataDTO> dto = historyFiveMinutelyService.queryDeviceAndFiveMinuteData(form);
 
        //转换前端参数
        DeviceAndFiveMinuteDataVO vo = DeviceAndFiveMinuteDataVO.convert(dto);
 
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo);
    }
 
    /**
    * @Description: 查询弹窗五分钟数据接口
            * @Param: [mac]
            * @return: com.moral.constant.ResultMessage
            * @Author: 陈凯裕
            * @Date: 2022/3/10
            */
    @GetMapping("queryPopDataByMac")
    public ResultMessage queryPopDataByMac(HttpServletRequest request){
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        Map<String, Object> popDataByMac = historyFiveMinutelyService.getPopDataByMac(params);
        if (popDataByMac==null){
            return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg());
        }
        return  ResultMessage.ok(popDataByMac);
    }
}