package com.mosty.hczx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.hczx.TbHcBpcclInsertDto;
import com.mosty.base.model.dto.hczx.TbHcBpcryInsertDto;
import com.mosty.base.model.query.hczx.HcTjQuery;
import com.mosty.base.model.query.hczx.TbHcBpcclQuery;
import com.mosty.base.model.query.hczx.TbHcBpcryQuery;
import com.mosty.base.model.vo.hczx.TbHcBpcclVo;
import com.mosty.base.model.vo.hczx.TbHcBpcryVo;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import com.mosty.base.model.entity.hczx.TbHcBpccl;
import com.mosty.base.model.query.hczx.TbHcTodayBpcclQuery;
import com.mosty.hczx.service.TbHcBpcclService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author dw
 * @since 2022/8/2
 **/
@Api(tags = "核查中心-被盘查车辆接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbHcBpccl")
public class TbHcBpcclController {

    private final TbHcBpcclService tbHcBpcclService;

    @ApiOperation("大屏-数据统计区（左上侧)查询盘查车辆数量")
    @GetMapping("/selectCarCount")
    @JwtSysUser
    public ResponseResult<Integer> selectCarCount() {
        return ResponseResult.success(tbHcBpcclService.selectCarCount());
    }

    @ApiOperation("大屏-数据统计区（左上侧）-查询盘查车辆列表分页")
    @GetMapping("/selectCarList")
    @JwtSysUser
    public ResponseResult<IPage<TbHcBpcclVo>> selectCarList(TbHcTodayBpcclQuery dto) {
        return ResponseResult.success(tbHcBpcclService.selectCarList(dto));
    }

    @ApiOperation("APP_查询车辆信息")
    @PostMapping("/selectCl")
    @Log(title = "APP_查询车辆信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<TbHcBpcclVo> selectCl(@RequestBody TbHcBpcclQuery dto) {
        return ResponseResult.success(this.tbHcBpcclService.selectCl(dto));
    }

    @ApiOperation("保存被盘查车辆信息")
    @PostMapping("/saveBpccl")
    @Log(title = "保存被盘查车辆信息", businessType = BusinessType.UPDATE)
    @JwtSysUser
    public ResponseResult<Void> saveBpccl(@RequestBody TbHcBpcclInsertDto dto) {
        this.tbHcBpcclService.saveBpccl(dto);
        return ResponseResult.success();
    }

    @ApiOperation("查询两个小时内没有被人员绑定的车辆")
    @PostMapping("/getClOf2h")
    @JwtSysUser
    public ResponseResult<List<TbHcBpcclVo>> getClOf2h() {
        return ResponseResult.success(this.tbHcBpcclService.getClOf2h());
    }

    @ApiOperation("条件查询车辆盘查信息")
    @PostMapping("getClpcList")
    @Log(title = "条件查询人员盘查信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<IPage<TbHcBpcclVo>> getClpcList(@RequestBody TbHcBpcclQuery dto) {
        return ResponseResult.success(this.tbHcBpcclService.getClpcList(dto));
    }

    @ApiOperation("条件查询车辆盘查信息")
    @PostMapping("getClpcCount")
    @Log(title = "条件查询人员盘查信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<Map<String, Integer>> getClpcCount(@RequestBody TbHcBpcclQuery dto) {
        return ResponseResult.success(this.tbHcBpcclService.getClpcCount(dto));
    }

    @ApiOperation("大屏被盘查车辆统计")
    @JwtSysUser
    @PostMapping(value = "/bpcclTj")
    public ResponseResult<Map<String, Integer>> bpcclTj() {
        return ResponseResult.success(this.tbHcBpcclService.bpcclTj());
    }

    @ApiOperation("实际盘查车数")
    @JwtSysUser
    @PostMapping(value = "/getSjpcc")
    public ResponseResult<Integer> getSjpcc(@RequestParam("ssbmdm") String ssbmdm,
                                            @RequestParam("time") String time) {
        return ResponseResult.success(this.tbHcBpcclService.getSjpcc(ssbmdm, time));
    }


    @ApiOperation("盘查物品统计")
    @JwtSysUser
    @PostMapping(value = "/getPcWptj")
    public ResponseResult<Integer> getPcWptj(@RequestParam("ssbmdm") String ssbmdm,
                                           @RequestParam("time") String time) {
        return ResponseResult.success(this.tbHcBpcclService.getPcWptj(ssbmdm, time));
    }

    @ApiOperation("盘查统计")
    @JwtSysUser
    @PostMapping(value = "/getPctj")
    public ResponseResult<Object> getPctj(@RequestBody HcTjQuery query) {
        return ResponseResult.success(this.tbHcBpcclService.getPctj(query));
    }
}
