package com.securitycontrol.inter.controller;

import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.inter.service.BdServiceImpl;
import com.securitycontrol.inter.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 告警管理
 * @author lsun
 */
@RestController
@RequestMapping("/dataCenter/")
@Slf4j
public class BdController  {


    @Autowired
    private BdServiceImpl service;
    /**
     * 项目信息获取
     * @param param
     * @return
     */
    @PostMapping("getProjectByName")
    public AjaxResult  getProjectByName(@RequestBody InterfaceParamVo param){
            try{
                List<ProjectVo> list=service.getProjectByName(param);
                return  AjaxResult.success(list);
            }catch (Exception e){
                log.error(e.toString(),e);
            }
            return  AjaxResult.success(new ArrayList<>());
    }


    /**
     * 单项信息获取
     * @param param
     * @return
     */
    @PostMapping("getPrjsinInfoByPrjNo")
    public AjaxResult getPepsinInfoByPrcNo(@RequestBody InterfaceParamVo param){
        try{
            List<SingleProVo> list=service.getPepsinInfoByPrcNo(param);
            return  AjaxResult.success(list);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return  AjaxResult.success(new ArrayList<>());
    }


    /**
     * 标段信息信息获取
     * @param param
     * @return
     */
    @PostMapping("getSGTenderListBySinList")
    public AjaxResult getSGTenderListBySinList(@RequestBody InterfaceParamVo param){
        try{
            List<BidProjectVo> list=service.getSGTenderListBySinList(param);
            return  AjaxResult.success(list);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return  AjaxResult.success(new ArrayList<>());
    }

    /**
     * 人员信息获取
     * @param param
     * @return
     */
    @PostMapping("getPeopleInfo")
    public AjaxResult getPeopleInfo(@RequestBody InterfaceParamVo param){
        try{
            List<UserInfoVo> list=service.getPeopleInfo(param);
            return  AjaxResult.success(list);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return  AjaxResult.success(new ArrayList<>());
    }

    /**
     * 边带设备绑定信息
     * @param param
     * @return
     */
    @PostMapping("gatewayDeviceBind")
    public AjaxResult gatewayDeviceBind(@RequestBody InterfaceParamVo param){
        try{
            return service.gatewayDeviceBind(param);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return   AjaxResult.success(0);
    }
    /**
     * 删除设备
     * @param param
     * @return
     */
    @PostMapping("deviceDel")
    public AjaxResult deviceDel(@RequestBody InterfaceParamVo param){
        try{
            return service.deviceDel(param);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return   AjaxResult.success(0);
    }

    /**
     * 新增边带子设备
     * @param param
     * @return
     */
    @PostMapping("deviceAdd")
    public AjaxResult deviceAdd(@RequestBody DeviceInfoVo param){
        try{
            return service.deviceAdd(param);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return   AjaxResult.success(DevResultVo.error(param.getDeviceId(),"系统错误"));
    }


    /**
     * 设备状态信息上报
     * @param param
     * @return
     */
    @PostMapping("deviceStatus")
    public AjaxResult deviceStatus(@RequestBody DeviceInfoVo param){
        try{
            return service.deviceStatus(param);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return   AjaxResult.success(0);
    }
    /**
     * 设备告警信息上班
     * @param param
     * @return
     */
    @PostMapping("devWarn")
    public AjaxResult devWarn(@RequestBody WarnInfoVo param){
        try{
             return service.devWarn(param);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return   AjaxResult.success(0);
    }

    /**
     * 设备采集信息上班
     * @param param
     * @return
     */
    @PostMapping("devInfo")
    public AjaxResult devInfo(@RequestBody DeviceInfoVo param){
        try{
            return service.devInfo(param);
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return   AjaxResult.success(0);
    }



}
