package com.usky.park.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.park.domain.EventEg;
import com.usky.park.service.EventEgService;
import com.usky.park.service.vo.EventEgStatisticVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 门禁历史通行记录表 前端控制器
 * </p>
 *
 * @author zyj
 * @since 2023-03-31
 */
@RestController
@RequestMapping("/eventEg")
public class EventEgController {
    @Autowired
    private EventEgService eventEgService;

    /**
     * 数据中心-门禁人员进出实时信息列表查询
     *
     * @param deviceName 设备名称
     * @param installAddress  设备安装位置
     * @param cardNo 卡号
     * @param orgName 所属组织
     * @param eventType 事件类型
     * @param pageNum 当前页
     * @param pageSize 每页条数
     * @return
     */
    @GetMapping("eventEgList")
    public ApiResult<CommonPage<EventEg>> eventEgList(@RequestParam(value = "deviceName",required = false) String deviceName,
                                                      @RequestParam(value = "installAddress",required = false) String installAddress,
                                                      @RequestParam(value = "cardNo",required = false) String cardNo,
                                                      @RequestParam(value = "orgName",required = false) String orgName,
                                                      @RequestParam(value = "eventType",required = false) Integer eventType,
                                                      @RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum,
                                                      @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize){
        return ApiResult.success(eventEgService.eventEgList(deviceName,installAddress,cardNo,orgName,eventType,pageNum,pageSize));
    }

    /**
     * 数据中心-单个门禁人员进出通行历史记录列表查询
     *
     * @param deviceId 设备Id
     * @param personName 通行人员名称
     * @param startDate 开始时间  格式 yyyy-MM-dd HH:mm:ss
     * @param endDate  结束时间  格式 yyyy-MM-dd HH:mm:ss
     * @param pageNum 当前页
     * @param pageSize 每页条数
     * @return
     */
    @GetMapping("eventEgOne")
    ApiResult<CommonPage<EventEg>> eventEgOne(@RequestParam(value = "deviceId") String deviceId,
                                              @RequestParam(value = "personName",required = false) String personName,
                                              @RequestParam(value = "startDate",required = false) String startDate,
                                              @RequestParam(value = "endDate",required = false) String endDate,
                                              @RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum,
                                              @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize){
        return ApiResult.success(eventEgService.eventEgOne(deviceId,personName,startDate,endDate,pageNum,pageSize));
    }

    /**
     * 数据中心-统计门禁今日进出人次查询
     * @param enterDeviceId 进设备Id
     * @param outDeviceId 出设备Id
     * @param startDate 开始时间  格式 yyyy-MM-dd HH:mm:ss
     * @param endDate  结束时间  格式 yyyy-MM-dd HH:mm:ss
     * @return
     */
    @GetMapping("eventEgStatistic")
    ApiResult<List<EventEgStatisticVO>> eventEgStatistic(@RequestParam(value = "enterDeviceId") List<String> enterDeviceId,
                                                         @RequestParam(value = "outDeviceId") List<String> outDeviceId,
                                                         @RequestParam(value = "startDate") String startDate,
                                                         @RequestParam(value = "endDate") String endDate){
        return ApiResult.success(eventEgService.eventEgStatistic(enterDeviceId,outDeviceId,startDate,endDate));
    }

}

