package com.bonus.bracelet.controller;

import com.bonus.bracelet.service.IConsControlService;
import com.bonus.common.core.constant.BusinessConstants;
import com.bonus.common.core.text.Convert;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.entity.app.vo.DevWarnVo;
import com.bonus.common.entity.app.vo.JdConfigVo;
import com.bonus.common.entity.bracelet.BraceletParamsDto;
import com.bonus.common.entity.bracelet.vo.CheckConfigVo;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @className:ConsControlController
 * @author:cwchen
 * @date:2024-08-08-9:56
 * @version:1.0
 * @description:施工管控
 */
@RestController
@RequestMapping("/consControl/")
@Slf4j
public class ConsControlController extends BaseController {

    @Resource(name = "IConsControlService")
    private IConsControlService service;

    @GetMapping("getBallDeviceLists")
    @SysLog(title = "施工管控", businessType = OperaType.QUERY, logType = 0, module = "施工管控->实时监控", details = "实时监控")
    public AjaxResult getBallDeviceLists(BraceletParamsDto dto){
        return service.getBallDeviceLists(dto);
    }

    /**
     * 球机违章识别
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/8 17:58
     */
    @GetMapping("getBallWarnLists")
    public AjaxResult getBallWarnLists(BraceletParamsDto dto){
        return service.getBallWarnLists(dto);
    }

    /**
     * 预警信息
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/9 9:42
     */
    @GetMapping("getWarnLists")
    public AjaxResult getWarnLists(BraceletParamsDto dto){
        Integer pageNum = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_SIZE), 10);
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<WarnInfoVo> pageInfo = service.getWarnLists(dto);
        return AjaxResult.success(pageInfo.getList());
    }

    /**
     * 人员管控-人员树
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/9 10:34
     */
    @GetMapping("getPersonsTree")
    @SysLog(title = "施工管控", businessType = OperaType.QUERY, logType = 0, module = "施工管控->人员管控", details = "人员管控")
    public AjaxResult getPersonsTree(BraceletParamsDto dto){
        return service.getPersonsTree(dto);
    }

    /**
     * 今日施工班组/施工人数/安全帽信息
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/9 13:12
     */
    @GetMapping("getWorkInfo")
    public AjaxResult getWorkInfo(BraceletParamsDto dto){
        return service.getWorkInfo(dto);
    }

    /**
     * 获取整个班组人员/班组临时人员的定位/杆塔的定位以及施工范围的半径
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/9 14:36
     */
    @GetMapping("getPersonsInfo")
    public AjaxResult getPersonsInfo(BraceletParamsDto dto){
        return service.getPersonsInfo(dto);
    }

    /**
     * 根据杆塔获取班组人员/临时人员-已绑定手环
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/10 13:09
     */
    @GetMapping("getTeamPersonByTower")
    public AjaxResult getTeamPersonByTower(BraceletParamsDto dto){
        return service.getTeamPersonByTower(dto);
    }

    @PostMapping("spotCheck")
    @SysLog(title = "施工管控", businessType = OperaType.QUERY, logType = 0, module = "施工管控->人员管控", details = "手环人脸验证抽检")
    public AjaxResult spotCheck(@RequestBody BraceletParamsDto dto){
        return service.spotCheck(dto);
    }

    @PostMapping("checkConfig")
    @SysLog(title = "施工管控", businessType = OperaType.INSERT, logType = 0, module = "施工管控->人员管控", details = "自动验证配置")
    public AjaxResult checkConfig(@Validated @RequestBody CheckConfigVo vo){
        return service.checkConfig(vo);
    }

    /**
     * 获取自动验证配置
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/10 15:37
     */
    @GetMapping("getCheckConfig")
    public AjaxResult getCheckConfig(BraceletParamsDto dto){
        return service.getCheckConfig(dto);
    }

    /**
     * 人员详情
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/15 16:49
     */
    @GetMapping("getPersonDetail")
    public AjaxResult getPersonDetail(BraceletParamsDto dto){
        return service.getPersonDetail(dto);
    }

    /**
     * 人员历史轨迹
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/16 9:48
     */
    @GetMapping("getHistoryGj")
    public AjaxResult getHistoryGj(BraceletParamsDto dto){
        return service.getHistoryGj(dto);
    }

    @GetMapping("getDzWarnList")
    @SysLog(title = "施工管控", businessType = OperaType.QUERY, logType = 0, module = "施工管控->吊装管控", details = "吊装管控")
    public AjaxResult getDzWarnList(BraceletParamsDto dto){
        return service.getDzWarnList(dto);
    }

    /**
     * 近电感应设备预警信息
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/16 17:56
     */
    @GetMapping("getJdWarnList")
    public AjaxResult getJdWarnList(BraceletParamsDto dto){
        Integer pageNum = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_SIZE), 10);
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<DevWarnVo> pageInfo = service.getJdWarnList(dto);
        return AjaxResult.success(pageInfo.getList());
    }

    /**
     * 查询近电感应设备
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/18 13:33
     */
    @GetMapping("getJdList")
    public AjaxResult getJdList(BraceletParamsDto dto){
        return service.getJdList(dto);
    }

    /**
     * 添加近电感应设备配置
     * @param vo
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/18 17:31
     */
    @PostMapping("configJdDevice")
    public AjaxResult configJdDevice(@Validated @RequestBody JdConfigVo vo){
        return service.configJdDevice(vo);
    }

    /**
     * 查询近电感应设备配置
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/18 18:02
     */
    @GetMapping("getConfigJdDevice")
    public AjaxResult getConfigJdDevice(BraceletParamsDto dto){
        return service.getConfigJdDevice(dto);
    }

    /**
     * 根据文件ID获取照片
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/22 10:01
     */
    @PostMapping("getPhotosById")
    public AjaxResult getPhotosById(@RequestBody BraceletParamsDto dto) {
        return service.getPhotosById(dto);
    }
}
