jinpengyong
2021-08-19 c98bb582d6a313940310a5e05bc80bafe386e3a2
screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java
@@ -4,11 +4,17 @@
import com.moral.api.pojo.form.device.MonitorPointQueryForm;
import com.moral.api.pojo.vo.monitorPoint.MonitorPointsVO;
import com.moral.api.pojo.vo.monitorPoint.StateControllerStationVO;
import com.moral.api.service.HistoryFiveMinutelyService;
import com.moral.api.service.MonitorPointService;
import com.moral.api.service.OrganizationService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
@@ -17,6 +23,9 @@
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/**
 * @ClassName DeviceController
@@ -35,8 +44,11 @@
    @Autowired
    MonitorPointService monitorPointService;
    @Autowired
    private HistoryFiveMinutelyService historyFiveMinutelyService;
    @GetMapping("queryMonitorPoints")
    public ResultMessage queryMonitorPointsAndDevices(MonitorPointQueryForm form){
    public ResultMessage queryMonitorPointsAndDevices(MonitorPointQueryForm form) {
        //判断是否缺少参数
        if (!form.valid())
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
@@ -51,15 +63,35 @@
    }
    @GetMapping("queryStateControlStation")
    public ResultMessage queryStateControlStation(Integer regionCode){
    public ResultMessage queryStateControlStation(Integer regionCode) {
        List<MonitorPoint> monitorPoints = monitorPointService.queryStateControlStationByRegionCode(regionCode);
        //转换前端所需参数
        StateControllerStationVO vo = StateControllerStationVO.convert(monitorPoints);
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo);
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo);
    }
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     */
    @GetMapping("getWindData")
    @ApiOperation(value = "获取风场数据", notes = "获取风场数据")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "monitorPointIds", value = "站点id", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage getWindData(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("monitorPointIds")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        String[] monitorPointIds = params.remove("monitorPointIds").toString().split(",");
        params.put("monitorPointIds", monitorPointIds);
        List<Object> response = historyFiveMinutelyService.getAreaWindData(params);
        return ResultMessage.ok(response);
    }
}