package com.bonus.app.controller;

import com.bonus.app.entity.DeviceWarnEntity;
import com.bonus.app.entity.PeopleInfoEntity;
import com.bonus.app.entity.StayPersonEntity;
import com.bonus.app.service.IStayPersonService;
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.core.web.page.TableDataInfo;
import com.bonus.common.entity.bracelet.vo.ProjectVo;
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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 现场人员管理模块
 * APP
 */
@RestController
@RequestMapping("/stayPerson/")
@Slf4j
public class StayPersonController extends BaseController{


    @Autowired
    private IStayPersonService service;

    /**
     * 查询现场人员列表
     * @param vo
     * @return
     */
    @GetMapping("getStayPersonList")
    @SysLog(title = "现场人员管理", businessType = OperaType.QUERY,  module = "基础管理->现场人员管理", details = "查询现场人员列表")
    public AjaxResult getStayPersonList(ProjectVo vo) {
        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<StayPersonEntity> pageInfo = service.getStayPersonList(vo);
        return AjaxResult.success(pageInfo.getList());

    }

//    /**
//     * 切换时获取工程列表
//     * @param proId
//     * @return
//     */
//    @GetMapping("getProjectList/{proId}")
//    @SysLog(title = "现场人员管理", businessType = OperaType.QUERY,  module = "基础管理->现场人员管理", details = "切换时获取工程列表")
//    public AjaxResult getProjectList(@PathVariable Long proId) {
//        return service.getProjectList(proId);
//    }

    /**
     * 修改安全帽、马甲编号
     * @param vo
     * @return
     */
    @PostMapping("editCodeInfoList")
    @SysLog(title = "现场人员管理", businessType = OperaType.QUERY,  module = "基础管理->现场人员管理", details = "修改安全帽、马甲编号")
    public AjaxResult editCodeInfoList(@RequestBody ProjectVo vo) {
        return service.editCodeInfoList(vo);
    }

    /**
     * 单个人员进行人脸验证
     * @param vo
     * @return
     */
    @PostMapping("singleRecognition")
    @SysLog(title = "现场人员管理", businessType = OperaType.QUERY,  module = "基础管理->现场人员管理", details = "单个人员进行人脸验证")
    public AjaxResult singleRecognition(@RequestBody PeopleInfoEntity vo) { return service.singleRecognition(vo); }

    /**
     * 所有人员进行人脸验证
     * @param data
     * @return
     */
    @GetMapping("allRecognition")
    @SysLog(title = "现场人员管理", businessType = OperaType.QUERY,  module = "基础管理->现场人员管理", details = "所有人员进行人脸验证")
    public AjaxResult allRecognition(ProjectVo data) {
        return service.allRecognition(data);
    }
}
