package com.yuchen.saas.park.service.controller.covid19;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.prevention.ScanPageQueryDTO;
import com.yuchen.saas.park.api.dto.prevention.ScanPreventionDTO;
import com.yuchen.saas.park.api.request.ScanPageQueryRequest;
import com.yuchen.saas.park.api.response.ScanPreventionResponse;
import com.yuchen.saas.park.api.vo.park.prevention.*;
import com.yuchen.saas.park.service.service.ScanPreventionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 颜艺波
 * @date 2022/6/16 16:25
 * @Description
 */
@RestController
@RequestMapping("/scan/prevention")
@Api(value = "扫码防疫信息", tags = "扫码防疫信息")
public class ScanPreventionController {

    @Autowired
    private ScanPreventionService scanPreventionService;

    @GetMapping("/latestDataQuery/{parkId}")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "防疫最新数据查询", notes = "防疫最新数据查询")
    public R<List<ScanPreventionVO>> latestDataQuery(@PathVariable("parkId") Long parkId) {

        return R.data(scanPreventionService.latestDataQuery(parkId));
    }

    @GetMapping("/pageQuery")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "防疫数据分页查询", notes = "防疫数据分页查询")
    public R<IPage<ScanPreventionVO>> pageQuery(ScanPageQueryDTO scanPageQueryDTO, Query query) {

        return R.data(scanPreventionService.pageQuery(scanPageQueryDTO, query));
    }

    @GetMapping("/healthCodeToday/{parkId}")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "今日健康码分布", notes = "今日健康码分布")
    public R<HealthCodeTodayVO> healthCodeToday(@PathVariable("parkId") Long parkId) {

        return R.data(scanPreventionService.healthCodeToday(parkId));
    }

    @GetMapping("/temperatureToday/{parkId}")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "今日体温分布", notes = "今日体温分布")
    public R<TemperatureTodayVO> temperatureToday(@PathVariable("parkId") Long parkId) {

        return R.data(scanPreventionService.temperatureToday(parkId));
    }

    @GetMapping("/vaccineStatisticsToday/{parkId}")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "今日疫苗统计", notes = "今日疫苗统计")
    public R<List<CoordinateVO>> vaccineStatisticsToday(@PathVariable("parkId") Long parkId) {

        return R.data(scanPreventionService.vaccineStatisticsToday(parkId));
    }

    @GetMapping("/preventionStatistic/{parkId}")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "防疫检测统计", notes = "防疫检测统计")
    public R<PreventionStatisticVO> preventionStatistic(@PathVariable("parkId")Long parkId) {

        return R.data(scanPreventionService.preventionStatistic(parkId));
    }

    @PostMapping("/add")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增数据", notes = "新增数据")
    public R<Boolean> add(@RequestBody ScanPreventionDTO scanPreventionDTO) {

       // scanPreventionDTO.setScanTime(System.currentTimeMillis());
       // scanPreventionDTO.setNucleicAcidAssayLastTime(System.currentTimeMillis() - 20 * 60 * 1000);
       // scanPreventionDTO.setInoculationLastTime(System.currentTimeMillis() - 3 * 24 * 60 * 60 * 1000);
        return R.data(scanPreventionService.add(scanPreventionDTO));
    }

    @GetMapping("/list/page")
    @ApiOperation(value = "防疫数据分页查询", notes = "防疫数据分页查询")
    public R<IPage<ScanPreventionResponse>> listPage(ScanPageQueryRequest scanPageQueryRequest, Query query) {
        return scanPreventionService.listPage(scanPageQueryRequest,query);
    }

    @GetMapping("/healthCode/history/statistical")
    @ApiOperation(value = "今日健康码分布", notes = "今日健康码分布")
    public R<HealthCodeTodayVO> healthCodeHistory() {
        return R.data(scanPreventionService.healthCodeHistory(null));
    }
}
