package com.securitycontrol.screen.controller;

import com.securitycontrol.common.core.web.controller.BaseController;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.core.web.page.TableDataInfo;
import com.securitycontrol.common.log.annotation.Log;
import com.securitycontrol.common.log.enums.OperationType;
import com.securitycontrol.entity.screen.dto.ConstructionQualityDto;
import com.securitycontrol.entity.screen.dto.OperatingQualityDto;
import com.securitycontrol.entity.screen.vo.ConstructionQualityVo;
import com.securitycontrol.entity.screen.vo.OperatingQualityVo;
import com.securitycontrol.screen.service.OperatingService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 作业环境
 * @author jjLv
 */
@RestController
@RequestMapping("/largeScreen/operatingEnvironment/")
@Slf4j
public class OperatingController extends BaseController {
    @Resource(name = "OperatingService")
    private OperatingService service;

    @RequestMapping(value = "/RealTimeMonitoring", method = RequestMethod.POST)
    @ApiOperation(value = "作业环境-实时监测")
    public AjaxResult getRealTimeMonitoring(@RequestBody OperatingQualityDto dto) {
        try {
            List<OperatingQualityVo> list  = service.getRealTimeMonitoring(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @RequestMapping(value = "/FiniteSpace", method = RequestMethod.POST)
    @ApiOperation(value = "作业环境-有限空间检测设备查询")
    public AjaxResult getFiniteSpace(@RequestBody OperatingQualityDto dto) {
        try {
            List<OperatingQualityVo> list  = service.getFiniteSpace(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @RequestMapping(value = "/getFiniteSpaceEnvironment", method = RequestMethod.POST)
    @ApiOperation(value = "作业环境-有限空间检测环境")
    public AjaxResult getFiniteSpaceEnvironment(@RequestBody OperatingQualityDto dto) {
        try {
            List<OperatingQualityVo> list  = service.getFiniteSpaceEnvironment(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @RequestMapping(value = "/SlopeDisplacement", method = RequestMethod.POST)
    @ApiOperation(value = "作业环境-边坡位移监测设备查询")
    public AjaxResult getSlopeDisplacement(@RequestBody OperatingQualityDto dto) {
        try {
            List<OperatingQualityVo> list  = service.getSlopeDisplacement(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @ApiOperation(value = "作业环境-边坡位移监测列表")
    @GetMapping("getSlopeDisplacementList")
    @Log(title = "边坡位移监测列表", menu = "边坡位移监测列表->边坡位移监测列表", grade = OperationType.QUERY_BUSINESS, details = "查询边坡位移监测列表", type = "业务日志")
    public TableDataInfo getSlopeDisplacementList(ConstructionQualityDto dto) {
        try{
            startLayPage();
            List<ConstructionQualityVo> list = service.getSlopeDisplacementList(dto);
            return getDataTableLayui(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBadLayui(new ArrayList<>(),"请求出错了");
        }
    }

    @RequestMapping(value = "/getGPSInstallation", method = RequestMethod.POST)
    @ApiOperation(value = "作业环境-GPS安装检测设备查询")
    public AjaxResult getGPSInstallation(@RequestBody OperatingQualityDto dto) {
        try {
            List<OperatingQualityVo> list  = service.getGPSInstallation(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @RequestMapping(value = "/GPSInstallationEnvironment", method = RequestMethod.POST)
    @ApiOperation(value = "作业环境-GPS安装检测环境查询")
    public AjaxResult getGPSInstallationEnvironment(@RequestBody OperatingQualityDto dto) {
        try {
            List<OperatingQualityVo> list  = service.getGPSInstallationEnvironment(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }


}
