package com.mosty.hczx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.hczx.TbHcBpcryInsertDto;
import com.mosty.base.model.entity.hczx.TbHcBpcry;
import com.mosty.base.model.query.hczx.HcTjQuery;
import com.mosty.base.model.query.hczx.RyClTjQuery;
import com.mosty.base.model.query.hczx.TbHcBpcryQuery;
import com.mosty.base.model.query.hczx.TbHcTodayBpcryQuery;
import com.mosty.base.model.vo.hczx.RyZpSearchVo;
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.hczx.service.TbHcBpcryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.websocket.server.PathParam;
import java.util.List;
import java.util.Map;

/**
 * @author dw
 * @since 2022/8/2
 * 核查中心-被盘查人员接口
 **/
@Api(tags = "核查中心-被盘查人员接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbHcBpcry")
public class TbHcBpcryController {

    private final TbHcBpcryService tbHcBpcryService;

    @ApiOperation("大屏-数据统计区（左上侧）-查询盘查人员数量")
    @GetMapping("/selectCrewCount")
    @JwtSysUser
    public ResponseResult<Integer> selectCrewCount(@PathParam("ssbmdm") String ssbmdm, @PathParam("isChild") String isChild) {
        return ResponseResult.success(tbHcBpcryService.selectCrewCount(ssbmdm, isChild));
    }

    @ApiOperation("大屏-数据统计区（左上侧）-查询盘查人员列表分页")
    @GetMapping("/selectCrewList")
    @JwtSysUser
    public ResponseResult<IPage<TbHcBpcryVo>> selectCrewList(TbHcTodayBpcryQuery dto) {
        return ResponseResult.success(tbHcBpcryService.selectCrewList(dto));
    }

    @ApiOperation("APP_查询人员信息")
    @PostMapping("/selectRy")
    @Log(title = "APP_查询人员信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<TbHcBpcryVo> selectRy(@RequestBody TbHcBpcryQuery dto) {
        return ResponseResult.success(tbHcBpcryService.selectRy(dto));
    }

    @ApiOperation("APP_查询内网人员信息")
    @PostMapping("/selectNwRy")
    @Log(title = "APP_查询内网人员信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<TbHcBpcryVo> selectNwRy(@RequestBody TbHcBpcryQuery dto) {
        return ResponseResult.success(tbHcBpcryService.selectNwRy(dto));
    }

    @ApiOperation("查询人员标签代码")
    @GetMapping("/getRyBq")
    @JwtSysUser
    public ResponseResult<Map<String, Object>> getRyBq(String id) {
        return ResponseResult.success(tbHcBpcryService.getRyBq(id));
    }

    @ApiOperation("查询人员标签代码根据身份证查询")
    @GetMapping("/getRyBqBySfzh")
    @JwtSysUser
    public ResponseResult<Map<String, Object>> getRyBqBySfzh(String sfzh) {
        return ResponseResult.success(tbHcBpcryService.getRyBqBySfzh(sfzh));
    }

    @ApiOperation("保存被盘查人员信息Nfc")
    @PostMapping("/saveBpcryNfc")
    @Log(title = "保存被盘查人员信息Nfc", businessType = BusinessType.UPDATE)
    @JwtSysUser
    public ResponseResult<TbHcBpcryVo> saveBpcryNfc(@RequestBody TbHcBpcry bpcry) {
        return ResponseResult.success(this.tbHcBpcryService.saveBpcryNfc(bpcry));
    }

    @ApiOperation("保存被盘查人员信息")
    @PostMapping("/saveBpcry")
    @Log(title = "保存被盘查人员信息", businessType = BusinessType.UPDATE)
    @JwtSysUser
    public ResponseResult<Void> saveBpcry(@RequestBody TbHcBpcryInsertDto dto) {
        this.tbHcBpcryService.saveBpcry(dto);
        return ResponseResult.success();
    }

    @ApiOperation("根据人像查询人员列表信息")
    @PostMapping("/getRyListByZp")
    @Log(title = "根据人像查询人员列表信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<List<RyZpSearchVo>> getRyListByZp(@RequestParam(name = "file") MultipartFile file) {
        return ResponseResult.success(this.tbHcBpcryService.getRyListByZp(file));
    }

    @ApiOperation("根据人像查询人员列表信息-base64")
    @PostMapping("/getRyListByBase64")
    @Log(title = "根据人像查询人员列表信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<List<RyZpSearchVo>> getRyListByBase64(@RequestParam(name = "base64Str") String base64Str) {
        return ResponseResult.success(this.tbHcBpcryService.getRyListByBase64(base64Str));
    }

    @ApiOperation("根据手机号查询人员信息")
    @PostMapping("/getRyListBySjhm/{mobile}")
    @Log(title = "根据手机号查询人员信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<List<Map>> getRyListBySjhm(@PathVariable("mobile") String mobile) {
        return ResponseResult.success(this.tbHcBpcryService.getRyListBySjhm(mobile));
    }

    @ApiOperation("条件查询人员盘查信息")
    @PostMapping("getRypcList")
    @Log(title = "条件查询人员盘查信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<IPage<TbHcBpcryVo>> getRypcList(@RequestBody TbHcBpcryQuery dto) {
        return ResponseResult.success(this.tbHcBpcryService.getRypcList(dto));
    }

    @ApiOperation("条件查询人员盘查信息统计")
    @PostMapping("getRypcCount")
    @Log(title = "条件查询人员盘查信息", businessType = BusinessType.OTHER)
    @JwtSysUser
    public ResponseResult<Map<String, Integer>> getRypcCount(@RequestBody TbHcBpcryQuery dto) {
        return ResponseResult.success(this.tbHcBpcryService.getRypcCount(dto));
    }

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

    @ApiOperation("查询人员盘查列表--计算")
    @PostMapping("getRyList")
    @JwtSysUser
    public ResponseResult<List<TbHcBpcryVo>> getRyList() {
        return ResponseResult.success(this.tbHcBpcryService.getRyOf2h());
    }

    @ApiOperation("泸州态势统计-各区县盘查工作")
    @PostMapping("/getGqxpc")
    @JwtSysUser
    public ResponseResult<Map<String, Object>> getXfscAndLcTj(RyClTjQuery dto) {
        return ResponseResult.success(this.tbHcBpcryService.getGqxpc(dto));
    }
    @ApiOperation("大屏被盘查人员统计")
    @JwtSysUser
    @PostMapping(value = "/bpcryTj")
    public ResponseResult<Map<String, Integer>> bpcryTj() {
        return ResponseResult.success(this.tbHcBpcryService.bpcryTj());
    }

    @ApiOperation("巡防战果统计")
    @JwtSysUser
    @PostMapping(value = "/xfzgtj")
    @Log(title = "巡防战果统计", businessType = BusinessType.OTHER)
    public ResponseResult<IPage<Map<String, Object>>> xfzgtj(@RequestBody HcTjQuery query) {
        return ResponseResult.success(this.tbHcBpcryService.xfzgtj(query));
    }

    @ApiOperation("巡防战果统计All")
    @JwtSysUser
    @PostMapping(value = "/xfzgtjAll")
    @Log(title = "巡防战果统计All", businessType = BusinessType.OTHER)
    public ResponseResult<Map<String, Object>> xfzgtjAll(@RequestBody HcTjQuery query) {
        return ResponseResult.success(this.tbHcBpcryService.xfzgtjAll(query));
    }

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


    @ApiOperation("方正获取战果统计")
//    @JwtSysUser
    @PostMapping(value = "/getZgtj")
//    @Log(title = "方正获取战果统计", businessType = BusinessType.OTHER)
    public ResponseResult<Map<String, List<Map<String, Object>>>> getZgtj(@Validated @RequestBody HcTjQuery query) {
        return ResponseResult.success(this.tbHcBpcryService.getZgtj(query));
    }


}
