package com.ningdatech.carapi.archives.controller;

import java.util.List;

import javax.validation.Valid;

import org.springframework.validation.annotation.Validated;
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 com.ningdatech.carapi.archives.aop.AuditVehicle;
import com.ningdatech.carapi.archives.manage.ArchivesManage;
import com.ningdatech.carapi.qrcode.model.vo.GetOnVehicleVO;
import com.ningdatech.carapi.safe.model.vo.NdVehicleAccidentAnalysisVO;
import com.ningdatech.carapi.safe.model.vo.NdVehicleAccidentDeadVO;
import com.ningdatech.carapi.safe.model.vo.NdVehicleAccidentVO;
import com.ningdatech.carapi.safe.model.vo.NdVehicleViolationVO;
import com.ningdatech.carapi.sys.entity.dto.OperatorQueryDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @Classname ArchivesController
 * @Description
 * @Date 2022/11/1 14:16
 * @Created by PoffyZhang
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/archives/vehicle")
@Api(value = "archives", tags = "车辆管理-档案管理")
@RequiredArgsConstructor
public class ArchivesController {

    private final ArchivesManage archivesManage;

    /**
     * 查询车辆的运营商档案
     *
     * @param carPlate 车牌号
     * @return 查询运营商
     */
    @ApiOperation(value = "运营商信息档案", notes = "运营商信息档案")
    @GetMapping("/operator-detail")
    @AuditVehicle
    public OperatorQueryDTO getOperatorDetails(@Valid @RequestParam String carPlate) {
        return archivesManage.getOperatorDetails(carPlate);
    }

    /**
     * 查询车辆违章记录档案
     *
     * @param carPlate,violationType
     * @return
     */
    @ApiOperation(value = "查询车辆违章记录档案", notes = "查询车辆违章记录档案")
    @GetMapping("/violation")
    @AuditVehicle
    public List<NdVehicleViolationVO> getViolation(@Valid @RequestParam String carPlate, @Valid @RequestParam Integer violationType) {
        return archivesManage.getViolation(carPlate,violationType);
    }

    /**
     * 查询车辆事故记录档案
     * @param carPlate,violationType
     * @return
     */
    @ApiOperation(value = "查询车辆事故记录档案", notes = "查询车辆事故记录档案")
    @GetMapping("/accident-vehicle")
    @AuditVehicle
    public List<NdVehicleAccidentVO> getAccidentVehicle(@Valid @RequestParam String carPlate) {
        return archivesManage.getAccidentVehicle(carPlate);
    }

    /**
     * 查询车辆死亡事故记录档案
     *
     * @param carPlate,violationType
     * @return
     */
    @ApiOperation(value = "查询车辆死亡事故记录档案", notes = "查询车辆死亡事故记录档案")
    @GetMapping("/accident-dead")
    @AuditVehicle
    public List<NdVehicleAccidentDeadVO> getAccidentDead(@Valid @RequestParam String carPlate) {
        return archivesManage.getAccidentDead(carPlate);
    }

    /**
     * 查询车辆事故分析记录档案
     *
     * @param carPlate,violationType
     * @return
     */
    @ApiOperation(value = "查询车辆事故分析记录档案", notes = "查询车辆事故分析记录档案")
    @GetMapping("/accident-analysis")
    @AuditVehicle
    public List<NdVehicleAccidentAnalysisVO> getAccidentAnalysis(@Valid @RequestParam String carPlate) {
        return archivesManage.getAccidentAnalysis(carPlate);
    }

    /**
     * 查询车辆上车记录
     *
     * @param carPlate,violationType
     * @return
     */
    @ApiOperation(value = "查询车辆上车记录", notes = "查询车辆上车记录")
    @GetMapping("/get-on-car-list")
    @AuditVehicle
    public List<GetOnVehicleVO> getOnCar(@Valid @RequestParam String carPlate) {
        return archivesManage.getOnCar(carPlate);
    }

    /**
     * 查询车辆上车记录
     *
     * @param driverId
     * @return
     */
    @ApiOperation(value = "查询车辆上车记录-驾驶员ID", notes = "查询车辆上车记录")
    @GetMapping("/get-driver-on-car-list")
    public List<GetOnVehicleVO> getOnCarDriver(@Valid @RequestParam String driverId) {
        return archivesManage.getOnCarDriver(driverId);
    }
}
