package com.mosty.yjzl.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.yjzl.GetLastYjDto;
import com.mosty.base.model.dto.yjzl.TbYjxxDTO;
import com.mosty.base.model.dto.yjzl.YjConvertZlDto;
import com.mosty.base.model.entity.rh.RhMyhtWarn;
import com.mosty.base.model.query.afjcsj.VwSyrkJzgjGxListQuery;
import com.mosty.base.model.query.yjzl.*;
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.yjzl.TbYjxx;
import com.mosty.yjzl.service.TbYjxxService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.yaml.snakeyaml.util.UriEncoder;

import java.util.List;
import java.util.Map;

/**
 * 预警信息表(TbYjxx)表控制层
 *
 * @author zhangHaiJun
 * @since 2022-07-11 20:06:06
 */
@Api(tags = "预警信息相关接口")
@RestController
@RequestMapping("tbYjxx")
@AllArgsConstructor
public class TbYjxxController {

    private final TbYjxxService tbYjxxService;


    @ApiOperation("查询预警列表-分页")
    @PostMapping(value = "/getPageList")
    @JwtSysUser
    public ResponseResult<IPage<TbYjxx>> getPageList(@RequestBody TbYjxxQuery dto) {
        return ResponseResult.success(tbYjxxService.getPageList(dto));
    }

    @ApiOperation("查询预警列表-不分页")
    @GetMapping("/getList")
    @JwtSysUser
    public ResponseResult<List<TbYjxx>> getList(TbYjxxNoPageQuery dto) {
        return ResponseResult.success(tbYjxxService.getList(dto));
    }

    @ApiOperation("查询预警列表-根据预警内容查询")
    @GetMapping("/selectYjByNr")
    @JwtSysUser
    public ResponseResult<List<TbYjxxDTO>> selectYjByNr(@RequestParam("yjNr") String yjNr) {
        return ResponseResult.success(tbYjxxService.selectYjByNr(yjNr));
    }

    @ApiOperation("查询预警列表-热力图使用")
    @GetMapping("/getListHotMapEs")
    @JwtSysUser
    public ResponseResult<List<Map<String, Object>>> getListHotMapEs(TbYjxxNoPageQuery dto) {
        return ResponseResult.success(tbYjxxService.getListHotMapEs(dto));
    }


    @ApiOperation("查询预警列表-热力图使用")
    @GetMapping("/getListHotMap")
    @JwtSysUser
    public ResponseResult<List<Map<String, Object>>> getListHotMap(TbYjxxNoPageQuery dto) {
        return ResponseResult.success(tbYjxxService.getListHotMap(dto));
    }

    @ApiOperation("查询预警详情")
    @GetMapping("/getInfo/{id}")
    @JwtSysUser
    public ResponseResult<TbYjxx> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(tbYjxxService.getInfo(id));
    }


    @ApiOperation("大屏-巡组气泡框-预警轨迹")
    @GetMapping("/selectTrack")
    @JwtSysUser
    @Log(title = "大屏-巡组气泡框-预警轨迹", businessType = BusinessType.OTHER)
    public ResponseResult<IPage<TbYjxx>> selectTrack(TbYjxxYjgjQuery tbYjxx) {
        return ResponseResult.success(tbYjxxService.selectTrack(tbYjxx));
    }

    @ApiOperation("新增数据")
    @JwtSysUser
    @PostMapping("/insert")
    @Log(title = "预警新增", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> add(@RequestBody TbYjxx yjxx) {
        return ResponseResult.success(tbYjxxService.insert(yjxx));
    }

    @ApiOperation("查询预警列表-不分页")
    @GetMapping("/queryYjxx")
    @JwtSysUser
    public ResponseResult<TbYjxx> queryYjxx(TbYjxx dto) {
        return ResponseResult.success(tbYjxxService.queryYjxx(dto));
    }

    @ApiOperation("通过证件号码和车牌号查询人员的预警信息")
    @GetMapping("/getYjgj")
    @JwtSysUser
    public ResponseResult<IPage<TbYjxx>> getYjgj(VwSyrkJzgjGxListQuery dto) {
        return ResponseResult.success(tbYjxxService.getYjgj(dto));
    }

    @ApiOperation("APP端预警信息统计-预警级别")
    @GetMapping("/getYjxxTj")
    @JwtSysUser
    public ResponseResult<List<Map<String, Object>>> getYjxxTj(TbYjxxYjjbStatisticsQuery dto) {
        return ResponseResult.success(tbYjxxService.getYjxxTj(dto));
    }

    @ApiOperation("APP端预警信息统计-预警类型")
    @GetMapping("/getYjxxTjYjlx")
    @JwtSysUser
    public ResponseResult<List<Map<String, Object>>> getYjxxTjYjlx(String kssj, String jssj) {
        return ResponseResult.success(tbYjxxService.getYjxxTjYjlx(kssj, jssj));
    }

    @ApiOperation("APP端单人、单车预警统计")
    @GetMapping("/getStatistics")
    @JwtSysUser
    public ResponseResult<Map<String, Object>> getStatistics(TbYjxxStatisticsQuery dto) {
        return ResponseResult.success(tbYjxxService.getStatistics(dto));
    }

    @ApiOperation("APP各时段预警")
    @GetMapping("/gsdyj")
    @JwtSysUser
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1.今天 2.7天 3.30天 4.90天", required = true, dataType = "String"),
    })
    public ResponseResult<Object> gsdyj(String type) {
        return ResponseResult.success(tbYjxxService.gsdyj(type));
    }

    @ApiOperation("APP预警转为指令")
    @PostMapping(value = "/yjConvertZl")
    public ResponseResult<Void> yjConvertZl(@RequestBody YjConvertZlDto dto) {
        this.tbYjxxService.yjConvertZl(dto);
        return ResponseResult.success();
    }

    @ApiOperation("获取最新一条预警")
    @PostMapping(value = "/getLastYj")
    public ResponseResult<TbYjxx> getLastYj(@RequestBody GetLastYjDto dto) {
        return ResponseResult.success(this.tbYjxxService.getLastYj(dto));
    }

    @ApiOperation("修改预警信息是否发送指令")
    @PostMapping(value = "/updateYjxxSffszl/{id}")
    public ResponseResult<TbYjxx> updateYjxxSffszl(@PathVariable("id") String id) {
        this.tbYjxxService.updateYjxxSffszl(id);
        return ResponseResult.success();
    }

    @ApiOperation("查询预警信息列表（只查询又经纬度信息的）")
    @PostMapping(value = "/getYjxx30Day")
    public ResponseResult<List<TbYjxx>> getYjxx30Day(@RequestBody TbYjxxQuery dto) {
        return ResponseResult.success(this.tbYjxxService.getYjxx30Day(dto));
    }

}


