package com.usky.fire.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.fire.domain.DemMicroStation;
import com.usky.fire.domain.DemVehicle;
import com.usky.fire.service.DemMicroStationService;
import com.usky.fire.service.DemOnDutyService;
import com.usky.fire.service.DemVehicleService;
import com.usky.fire.service.po.UnitBeOnDutyPO;
import org.springframework.beans.factory.annotation.Autowired;
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.List;

/**
 * <p>
 * 值班表 前端控制器
 * </p>
 *
 * @author JCB
 * @since 2022-11-28
 */
@RestController
@RequestMapping("/unitBeOnDuty")
public class UnitBeOnDutyController {

    @Autowired
    private DemOnDutyService demOnDutyService;

    @Autowired
    private DemMicroStationService demMicroStationService;

    @Autowired
    private DemVehicleService demVehicleService;

    /**
     * 消防救援站点-支队值班情况
     *
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param name      值班人员姓名
     * @return
     */
    @GetMapping("/list")
    public ApiResult<List<List<UnitBeOnDutyPO>>> list(@RequestParam(value = "startTime", required = false) String startTime,
                                                      @RequestParam(value = "endTime", required = false) String endTime,
                                                      @RequestParam(value = "name", required = false) String name) {
        return ApiResult.success(demOnDutyService.list(startTime, endTime, name));
    }

    /**
     * 消防救援站点-各站点执勤实力1
     *
     * @param current 当前页
     * @param size    每页条数
     * @param stationName    消防站名称
     * @return
     */
    @GetMapping("/page")
    public ApiResult<CommonPage<DemMicroStation>> page(@RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
                                                       @RequestParam(value = "size", required = false, defaultValue = "10") Integer size,
                                                       @RequestParam(value = "stationName", required = false) String stationName) {
        return ApiResult.success(demMicroStationService.page(current, size, stationName));
    }

    /**
     * 消防救援站点-各站点执勤实力2
     *
     * @param zdCode 所属消防机构
     * @param licensePlate 车牌号码
     * @return
     */
    @GetMapping("vehiclelist")
    public ApiResult<List<DemVehicle>> vehiclelist(@RequestParam(value = "zdCode",required = false) String zdCode,
                                                   @RequestParam(value = "licensePlate",required = false) String licensePlate) {
        return ApiResult.success(demVehicleService.list(zdCode, licensePlate));
    }

}

