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.AlarmMgeDto;
import com.securitycontrol.entity.screen.dto.ConstructionQualityDto;
import com.securitycontrol.entity.screen.vo.AlarmMgeVo;
import com.securitycontrol.entity.screen.vo.ConstructionQualityVo;
import com.securitycontrol.screen.service.AlarmMgeService;
import com.securitycontrol.screen.service.ConstructionQualityService;
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/constructionQuality/")
@Slf4j
public class ConstructionQualityController extends BaseController {
    @Resource(name = "ConstructionQualityService")
    private ConstructionQualityService service;

    @RequestMapping(value = "/qualityInspection", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "施工质量-质量检测设备")
    public AjaxResult getQualityInspection(@RequestBody ConstructionQualityDto dto) {
        try {
            List<ConstructionQualityVo> list  = service.getQualityInspection(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @RequestMapping(value = "/detectionRecord", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "施工质量-检测记录对比")
    public AjaxResult getDetectionRecord(@RequestBody ConstructionQualityDto dto) {
        try {
            List<ConstructionQualityVo> list = service.getDetectionRecord(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @ApiOperation(value = "施工质量-告警内容")
    @GetMapping("getConstructionAlarm")
    @Log(title = "告警内容", menu = "告警内容->告警内容", grade = OperationType.QUERY_BUSINESS, details = "查询告警内容", type = "业务日志")
    public TableDataInfo getConstructionAlarm(ConstructionQualityDto dto) {
        try{
            startLayPage();
            List<ConstructionQualityVo> list = service.getConstructionAlarm(dto);
            return getDataTableLayui(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBadLayui(new ArrayList<>(),"请求出错了");
        }
    }

    @ApiOperation(value = "施工质量-施工质量列表")
    @GetMapping("getConstructionQualityList")
    @Log(title = "施工质量列表", menu = "施工质量列表->施工质量列表", grade = OperationType.QUERY_BUSINESS, details = "查询施工质量列表", type = "业务日志")
    public TableDataInfo getConstructionQualityList(ConstructionQualityDto dto) {
        try{
            startLayPage();
            List<ConstructionQualityVo> list = service.getConstructionQualityList(dto);
            return getDataTableLayui(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBadLayui(new ArrayList<>(),"请求出错了");
        }
    }

}
