cjl
2023-11-15 d117d3af15dddc4f07baffa8b5bf6b727c05de7c
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
package com.moral.api.controller;
 
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.moral.api.entity.GovMonitorPoint;
import com.moral.api.entity.Organization;
import com.moral.api.mapper.OrganizationMapper;
import com.moral.api.service.GovMonitorPointService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
 
import java.util.List;
import java.util.Map;
 
/**
 * @ClassName
 * @Description TODO
 * @Author 陈凯裕
 * @Date 2021/9/24 9:07
 * @Version TODO
 **/
@Slf4j
@Api(tags = {"国控站"})
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/govMonitorPoint")
public class GovMonitorPointController {
 
    @Autowired
    GovMonitorPointService govMonitorPointService;
 
    @Resource
    private OrganizationMapper organizationMapper;
 
 
    /**
     * @Description: 查询国控站以及数据接口接口
     * @Param: [regionCode, sensorCode]
     * @return: com.moral.constant.ResultMessage
     * @Author: 陈凯裕
     * @Date: 2021/9/9
     */
    @GetMapping("queryStateControlStation")
    public ResultMessage queryStateControlStation(Integer regionCode, String sensorCode) {
 
        List<GovMonitorPoint> govMonitorPoints = govMonitorPointService.queryGovMonitorPointAndDataByRegionCode(regionCode, sensorCode);
 
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), govMonitorPoints);
    }
 
    /**
     * @Description: 通过组织id获取政府站点
     * @Param: [request]
     * @return: com.moral.constant.ResultMessage
     * @Author: lizijie
     * @Date: 2021/9/26 9:42
     **/
    @RequestMapping(value = "getGovMonitorPointsByOrgId", method = RequestMethod.GET)
    @ResponseBody
    public ResultMessage getGovMonitorPointsByOrgId(HttpServletRequest request) {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        Object orgid = parameters.get("organization_id");
        if (ObjectUtils.isEmpty(orgid)) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Organization organization = organizationMapper.selectById(Integer.parseInt(orgid.toString()));
        if (ObjectUtils.isEmpty(organization)) {
            return ResultMessage.fail(ResponseCodeEnum.ORGANIZATION_NOT_EXIST.getCode(), ResponseCodeEnum.ORGANIZATION_NOT_EXIST.getMsg());
        }
        List<GovMonitorPoint> govMonitorPoints = govMonitorPointService.selectGovMonitorPointsByOrgid(parameters);
        return ResultMessage.ok(govMonitorPoints);
    }
 
    /**
     * @Description: 通过guid和组织id获取绑定该站点设备的平均数据
     * @Param: [request]
     * @return: com.moral.constant.ResultMessage
     * @Author: lizijie
     * @Date: 2021/9/26 10:06
     **/
    @RequestMapping(value = "queryGovMonitorPointHourlyDataByGuidsAndOrgid", method = RequestMethod.GET)
    @ResponseBody
    public ResultMessage queryGovMonitorPointHourlyDataByGuidsAndOrgid(HttpServletRequest request) {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        Object orgid = parameters.get("organization_id");
        Object guids = parameters.get("guids");
        Object date = parameters.get("date");
        if (ObjectUtils.isEmpty(orgid) || ObjectUtils.isEmpty(guids) || ObjectUtils.isEmpty(date)) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Organization organization = organizationMapper.selectById(Integer.parseInt(orgid.toString()));
        if (ObjectUtils.isEmpty(organization)) {
            return ResultMessage.fail(ResponseCodeEnum.ORGANIZATION_NOT_EXIST.getCode(), ResponseCodeEnum.ORGANIZATION_NOT_EXIST.getMsg());
        }
        Map<String, Object> resultMap = govMonitorPointService.queryGovMonitorPointHoutlyDatyByGuidsAndOrgid(parameters);
        return ResultMessage.ok(resultMap);
    }
 
    @ApiOperation(value = "根据组织id获取国控站信息", notes = "根据组织id获取国控站信息")
    @GetMapping(value = "getGovMonitorPointsByOrganizationId")
    public ResultMessage delete(Integer organizationId) {
        if (ObjectUtils.isEmpty(organizationId)) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<Map<String, Object>> response = govMonitorPointService.getGovMonitorPointsByOrganizationId(organizationId);
        return ResultMessage.ok(response);
    }
}