package com.sundot.airport.web.controller.item;

import com.sundot.airport.common.core.controller.BaseController;
import com.sundot.airport.common.core.domain.AjaxResult;
import com.sundot.airport.item.service.IHkLargeScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
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.Date;

/**
 * 运行数据大屏 Controller（第二大屏，独立于查获大屏）
 * 基础路径：/hk/screen
 *
 * 模块一：运行数据
 *   GET /operationSummary       — 5个数字卡片汇总
 *   GET /t1PassengerTrend       — T1旅检折线图（A区/B区）
 *   GET /t2PassengerTrend       — T2旅检折线图（国内旅检/国际旅检）
 *   GET /luggageCheckTrend      — 行检折线图（T1行检/T2行检）
 *   GET /cargoTrend             — 货物折线图（国内货站/国际货站）
 *   GET /vehicleCheckTrend      — 车辆折线图（南侧车检/北侧车检）
 *
 * 模块二：查获/收缴数据
 *   GET /seizureCategory        — 查获数据分类环形图
 *   GET /brigadeSeizureCompare  — 大队查获对比（白班/夜班 × 大队）
 *   GET /powerBankSummary       — 不合规充电宝环形图
 *   GET /pendingConfiscate      — 待检区收缴物品环形图
 */
@RestController
@RequestMapping("/hk/screen")
public class HkLargeScreenController extends BaseController {

    @Autowired
    private IHkLargeScreenService service;

    // ===== 模块一：运行数据 =====

    /**
     * 运行数据汇总（旅检总人数、行检总数、国内/国际货站总数、车辆总数）
     */
    @GetMapping("/operationSummary")
    public AjaxResult operationSummary(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getOperationSummary(startDate, endDate));
    }

    /**
     * T1旅检过检人数趋势（A区 / B区）
     */
    @GetMapping("/t1PassengerTrend")
    public AjaxResult t1PassengerTrend(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getT1PassengerTrend(startDate, endDate));
    }

    /**
     * T2旅检过检人数趋势（国内旅检 / 国际旅检）
     */
    @GetMapping("/t2PassengerTrend")
    public AjaxResult t2PassengerTrend(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getT2PassengerTrend(startDate, endDate));
    }

    /**
     * 行检过检数趋势（T1行检 / T2行检）
     */
    @GetMapping("/luggageCheckTrend")
    public AjaxResult luggageCheckTrend(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getLuggageCheckTrend(startDate, endDate));
    }

    /**
     * 货物过检数趋势（国内货站 / 国际货站）
     */
    @GetMapping("/cargoTrend")
    public AjaxResult cargoTrend(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getCargoTrend(startDate, endDate));
    }

    /**
     * 车辆过检数趋势（南侧车检 / 北侧车检）
     */
    @GetMapping("/vehicleCheckTrend")
    public AjaxResult vehicleCheckTrend(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getVehicleCheckTrend(startDate, endDate));
    }

    // ===== 模块二：查获/收缴数据 =====

    /**
     * 查获数据分类环形图
     * 返回：[{name:"火种", total:xxx}, {name:"刀具", total:xxx}, ...]
     */
    @GetMapping("/seizureCategory")
    public AjaxResult seizureCategory(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getSeizureCategoryList(startDate, endDate));
    }

    /**
     * 大队查获数对比柱状图（白班/夜班 × 一/二/三大队）
     * 同一份数据支持：总量对比、T1区对比、T2区对比 三个图
     * 返回：[{shift:"白班", brigade:"一大队", t1Total:xxx, t2Total:xxx, grandTotal:xxx}, ...]
     */
    @GetMapping("/brigadeSeizureCompare")
    public AjaxResult brigadeSeizureCompare(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getBrigadeSeizureCompare(startDate, endDate));
    }

    /**
     * 不合规充电宝功能数据环形图（邮寄/暂存/自弃/两楼总数等）
     */
    @GetMapping("/powerBankSummary")
    public AjaxResult powerBankSummary(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getPowerBankSummary(startDate, endDate));
    }

    /**
     * 待检区收缴禁带物品环形图（火种/液态物品/其他）
     */
    @GetMapping("/pendingConfiscate")
    public AjaxResult pendingConfiscate(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return success(service.getPendingConfiscateSummary(startDate, endDate));
    }
}
