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

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sundot.airport.ledger.domain.vo.CountQueryReqVO;
import com.sundot.airport.ledger.domain.vo.LaneThroughputResVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sundot.airport.common.annotation.Log;
import com.sundot.airport.common.core.controller.BaseController;
import com.sundot.airport.common.core.domain.AjaxResult;
import com.sundot.airport.common.enums.BusinessType;
import com.sundot.airport.ledger.domain.OperationLanePeakThroughput;
import com.sundot.airport.ledger.service.IOperationLanePeakThroughputService;
import com.sundot.airport.common.utils.poi.ExcelUtil;
import com.sundot.airport.common.core.page.TableDataInfo;

/**
 * 通道日别高峰时段过检Controller
 *
 * @author ruoyi
 * @date 2026-05-18
 */
@RestController
@RequestMapping("/ledger/operationLanePeakThroughput")
public class OperationLanePeakThroughputController extends BaseController {
    @Autowired
    private IOperationLanePeakThroughputService operationLanePeakThroughputService;

    /**
     * 查询通道日别高峰时段过检列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationLanePeakThroughput:list')")
    @GetMapping("/list")
    public TableDataInfo list(OperationLanePeakThroughput operationLanePeakThroughput) {
        startPage();
        List<OperationLanePeakThroughput> list = operationLanePeakThroughputService.selectOperationLanePeakThroughputList(operationLanePeakThroughput);
        return getDataTable(list);
    }

    /**
     * 导出通道日别高峰时段过检列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationLanePeakThroughput:export')")
    @Log(title = "通道日别高峰时段过检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OperationLanePeakThroughput operationLanePeakThroughput) {
        List<OperationLanePeakThroughput> list = operationLanePeakThroughputService.selectOperationLanePeakThroughputList(operationLanePeakThroughput);
        ExcelUtil<OperationLanePeakThroughput> util = new ExcelUtil<OperationLanePeakThroughput>(OperationLanePeakThroughput.class);
        util.exportExcel(response, list, "通道日别高峰时段过检数据");
    }

    /**
     * 获取通道日别高峰时段过检详细信息
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationLanePeakThroughput:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(operationLanePeakThroughputService.getById(id));
    }

    /**
     * 新增通道日别高峰时段过检
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationLanePeakThroughput:add')")
    @Log(title = "通道日别高峰时段过检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperationLanePeakThroughput operationLanePeakThroughput) {
        operationLanePeakThroughput.setCreateBy(getUsername());
        return toAjax(operationLanePeakThroughputService.insertOperationLanePeakThroughput(operationLanePeakThroughput));
    }

    /**
     * 修改通道日别高峰时段过检
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationLanePeakThroughput:edit')")
    @Log(title = "通道日别高峰时段过检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperationLanePeakThroughput operationLanePeakThroughput) {
        operationLanePeakThroughput.setUpdateBy(getUsername());
        return toAjax(operationLanePeakThroughputService.updateOperationLanePeakThroughput(operationLanePeakThroughput));
    }

    /**
     * 删除通道日别高峰时段过检
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationLanePeakThroughput:remove')")
    @Log(title = "通道日别高峰时段过检", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(operationLanePeakThroughputService.deleteOperationLanePeakThroughputByIds(ids));
    }

    /**
     * 功能描述：统计通道日级别高峰时段过检率（小组/班组/部门级别）
     *
     * @param LaneThroughputReq 筛选条件
     * @return AjaxResult
     * @method countLanePeakThroughput
     * @author PanHu Sun
     * @date 2026/5/19 15:21
     */
    @PostMapping("/countLanePeakThroughput")
    public AjaxResult countLanePeakThroughput(@RequestBody CountQueryReqVO LaneThroughputReq) {
        List<LaneThroughputResVO> lanePeakThroughputList = operationLanePeakThroughputService.countLanePeakThroughput(LaneThroughputReq);
        return success(lanePeakThroughputList);
    }
}
