lizijie
2021-09-28 88da913f6722db2335abf676d4a3343efacd0a42
screen-api/src/main/java/com/moral/api/controller/GovMonitorPointController.java
@@ -1,18 +1,22 @@
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 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
 * @ClassName
@@ -31,19 +35,70 @@
    @Autowired
    GovMonitorPointService govMonitorPointService;
    @Resource
    private OrganizationMapper organizationMapper;
    /**
     * @Description: 查询国控站接口
     * @Param: [regionCode]
     * @Description: 查询国控站以及数据接口接口
     * @Param: [regionCode,sensorCode]
     * @return: com.moral.constant.ResultMessage
     * @Author: 陈凯裕
     * @Date: 2021/9/9
     */
    @GetMapping("queryStateControlStation")
    public ResultMessage queryStateControlStation(Integer regionCode) {
    public ResultMessage queryStateControlStation(Integer regionCode,String sensorCode) {
        List<GovMonitorPoint> govMonitorPoints = govMonitorPointService.queryGovMonitorPointAndDataByRegionCode(regionCode);
        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 = "queryGovMonitorPointHoutlyDatyByGuidsAndOrgid", method = RequestMethod.GET)
    @ResponseBody
    public ResultMessage queryGovMonitorPointHoutlyDatyByGuidsAndOrgid(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);
    }
}