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

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

import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputGroupResVO;
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.OperationStationHourlyThroughput;
import com.sundot.airport.ledger.service.IOperationStationHourlyThroughputService;
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/operationStationHourlyThroughput")
public class OperationStationHourlyThroughputController extends BaseController {
    @Autowired
    private IOperationStationHourlyThroughputService operationStationHourlyThroughputService;

    /**
     * 查询站级时间段别总过检列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationStationHourlyThroughput:list')")
    @GetMapping("/list")
    public TableDataInfo list(OperationStationHourlyThroughput operationStationHourlyThroughput) {
        startPage();
        List<OperationStationHourlyThroughput> list = operationStationHourlyThroughputService.selectOperationStationHourlyThroughputList(operationStationHourlyThroughput);
        return getDataTable(list);
    }

    /**
     * 导出站级时间段别总过检列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationStationHourlyThroughput:export')")
    @Log(title = "站级时间段别总过检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OperationStationHourlyThroughput operationStationHourlyThroughput) {
        List<OperationStationHourlyThroughput> list = operationStationHourlyThroughputService.selectOperationStationHourlyThroughputList(operationStationHourlyThroughput);
        ExcelUtil<OperationStationHourlyThroughput> util = new ExcelUtil<OperationStationHourlyThroughput>(OperationStationHourlyThroughput.class);
        util.exportExcel(response, list, "站级时间段别总过检数据");
    }

    /**
     * 获取站级时间段别总过检详细信息
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationStationHourlyThroughput:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(operationStationHourlyThroughputService.getById(id));
    }

    /**
     * 新增站级时间段别总过检
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationStationHourlyThroughput:add')")
    @Log(title = "站级时间段别总过检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperationStationHourlyThroughput operationStationHourlyThroughput) {
        operationStationHourlyThroughput.setCreateBy(getUsername());
        return toAjax(operationStationHourlyThroughputService.insertOperationStationHourlyThroughput(operationStationHourlyThroughput));
    }

    /**
     * 修改站级时间段别总过检
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationStationHourlyThroughput:edit')")
    @Log(title = "站级时间段别总过检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperationStationHourlyThroughput operationStationHourlyThroughput) {
        operationStationHourlyThroughput.setUpdateBy(getUsername());
        return toAjax(operationStationHourlyThroughputService.updateOperationStationHourlyThroughput(operationStationHourlyThroughput));
    }

    /**
     * 删除站级时间段别总过检
     */
    @PreAuthorize("@ss.hasPermi('ledger:operationStationHourlyThroughput:remove')")
    @Log(title = "站级时间段别总过检", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(operationStationHourlyThroughputService.deleteOperationStationHourlyThroughputByIds(ids));
    }

    /**
     * 功能描述：统计站级时间段人流量
     *
     * @return AjaxResult
     * @method countLanePeakThroughput
     * @author PanHu Sun
     * @date 2026/5/19 15:21
     */
    @GetMapping("/countStationHourlyThroughput")
    public AjaxResult countStationHourlyThroughput() {
        List<StationHourlyThroughputGroupResVO> StationHourlyThroughputList = operationStationHourlyThroughputService.countStationHourlyThroughput();
        return success(StationHourlyThroughputList);
    }
}
