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.dto.PersonnelControlDto;
import com.securitycontrol.entity.screen.vo.ConstructionQualityVo;
import com.securitycontrol.entity.screen.vo.OperatingQualityVo;
import com.securitycontrol.entity.screen.vo.PersonnelControlVo;
import com.securitycontrol.screen.service.PersonnelControlService;
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/personnelControl/")
@Slf4j
public class PersonnelControlController extends BaseController {
    @Resource(name = "PersonnelControlService")
    private PersonnelControlService service;

    @ApiOperation(value = "人员管控-穿戴装备")
    @GetMapping("getWearEquipmentList")
    @Log(title = "穿戴装备列表", menu = "穿戴装备列表->穿戴装备列表", grade = OperationType.QUERY_BUSINESS, details = "查询穿戴装备列表列表", type = "业务日志")
    public TableDataInfo getWearEquipmentList(PersonnelControlDto dto) {
        try{
            startLayPage();
            List<PersonnelControlVo> list = service.getWearEquipmentList(dto);
            return getDataTableLayui(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBadLayui(new ArrayList<>(),"请求出错了");
        }
    }

    @ApiOperation(value = "人员管控-人员运动趋预警")
    @GetMapping("getPersonnelMovementList")
    @Log(title = "人员运动趋预警列表", menu = "人员运动趋预警列表->人员运动趋预警列表", grade = OperationType.QUERY_BUSINESS, details = "查询人员运动趋预警列表", type = "业务日志")
    public TableDataInfo getPersonnelMovementList(PersonnelControlDto dto) {
        try{
            startLayPage();
            List<PersonnelControlVo> list = service.getPersonnelMovementList(dto);
            return getDataTableLayui(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBadLayui(new ArrayList<>(),"请求出错了");
        }
    }

    @RequestMapping(value = "/getPersonnelList", method = RequestMethod.POST)
    @ApiOperation(value = "人员管控-人员列表")
    public AjaxResult getPersonnelList(@RequestBody PersonnelControlDto dto) {
        try {
            List<PersonnelControlVo> list  = service.getPersonnelList(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @RequestMapping(value = "/addNewFence", method = RequestMethod.POST)
    @ApiOperation(value = "人员管控-围栏新增")
    public AjaxResult addNewFence(@RequestBody PersonnelControlDto dto) {
        try {
            int list  = service.addNewFence(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @ApiOperation(value = "人员管控-围栏列表")
    @GetMapping("getNewFenceList")
    @Log(title = "围栏列表", menu = "围栏列表->围栏列表", grade = OperationType.QUERY_BUSINESS, details = "查询围栏列表", type = "业务日志")
    public TableDataInfo getNewFenceList(PersonnelControlDto dto) {
        try{
            startLayPage();
            List<PersonnelControlVo> list = service.getNewFenceList(dto);
            return getDataTableLayui(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBadLayui(new ArrayList<>(),"请求出错了");
        }
    }

    @RequestMapping(value = "/subcontractorSwitchListen", method = RequestMethod.POST)
    @ApiOperation(value = "人员管控-围栏状态")
    public AjaxResult subcontractorSwitchListen(@RequestBody PersonnelControlDto dto) {
            return service.subcontractorSwitchListen(dto);
    }

    @RequestMapping(value = "/delSubcontractorById", method = RequestMethod.POST)
    @ApiOperation(value = "人员管控-围栏删除")
    public AjaxResult delSubcontractorById(@RequestBody PersonnelControlDto dto) {
        return service.delSubcontractorById(dto);
    }

    @RequestMapping(value = "/getReplicaFence", method = RequestMethod.POST)
    @ApiOperation(value = "人员管控-复现围栏")
    public AjaxResult getReplicaFence(@RequestBody PersonnelControlDto dto) {
        try {
            List<PersonnelControlVo> list  = service.getReplicaFence(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @RequestMapping(value = "/personnelCoordinatePoint", method = RequestMethod.POST)
    @ApiOperation(value = "人员管控-人员坐标点")
    public AjaxResult personnelCoordinatePoint(@RequestBody PersonnelControlDto dto) {
        try {
            List<PersonnelControlVo> list  = service.personnelCoordinatePoint(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    @RequestMapping(value = "/PersonnelHistoricalCoordinates", method = RequestMethod.POST)
    @ApiOperation(value = "人员管控-人员坐标点")
    public AjaxResult PersonnelHistoricalCoordinates(@RequestBody PersonnelControlDto dto) {
        try {
            List<PersonnelControlVo> list  = service.PersonnelHistoricalCoordinates(dto);
            return AjaxResult.success(list);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }


}
