package com.ningdatech.carapi.homepage.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.car.vehicle.model.dto.VehicleAuditPageQuery;
import com.ningdatech.carapi.car.vehicle.manage.VehicleManage;
import com.ningdatech.carapi.car.vehicle.model.vo.VehicleBaseVO;
import com.ningdatech.carapi.car.datascreen.model.dto.DataScreenParam;
import com.ningdatech.carapi.car.position.manage.PositionMonitorManage;
import com.ningdatech.carapi.car.position.model.vo.ResRealTimeMonitorVehicleGisListVO;
import com.ningdatech.carapi.driver.manage.DriverArchivesManage;
import com.ningdatech.carapi.driver.model.po.ReqDriverTrainingRegistrationListPO;
import com.ningdatech.carapi.driver.model.vo.ResDriverTrainingRegistrationListVO;
import com.ningdatech.carapi.homepage.entity.dto.HomepageAbnormalBehaviorPageParamDTO;
import com.ningdatech.carapi.homepage.entity.vo.HomepageDriverAbnormalBehaviorVo;
import com.ningdatech.carapi.homepage.entity.vo.HomepageVo;
import com.ningdatech.carapi.homepage.manage.HomepageManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

/**
 * @author CMM
 * @description 首页AI工作台
 * @since 2022/11/10 10:05
 */
@RestController
@Api(tags = "首页AI工作台")
@RequestMapping("/api/homepage/workbench")
@RequiredArgsConstructor
public class AiWorkbenchController {

    private final HomepageManage homepageManage;
    private final PositionMonitorManage positionMonitorManage;
    private final VehicleManage vehicleManage;
    private final DriverArchivesManage driverArchivesManage;

    @ApiOperation("首页数据显示")
    @GetMapping
    public HomepageVo onlineVehicleStatistics(@Valid @ModelAttribute DataScreenParam param) {
        return homepageManage.queryVehicleStatistics(param);
    }

    @GetMapping("/monitorVehicleGisList")
    @ApiOperation("首页GPS地图车辆分布显示")
    public List<ResRealTimeMonitorVehicleGisListVO> queryMonitorVehicleGisList(@Valid @ModelAttribute DataScreenParam param) {
        return positionMonitorManage.realTimeMonitorVehicleGisList(param);
    }

    @GetMapping("/toBeAuditList")
    @ApiOperation("首页工作台车辆待审核列表")
    public PageVo<VehicleBaseVO> queryToBeAudit(@Valid @ModelAttribute VehicleAuditPageQuery vehicleAuditPageQuery) {
        return vehicleManage.queryToBeAudit(vehicleAuditPageQuery);
    }

    @GetMapping("/training/registration/un-deal/list")
    @ApiOperation("首页工作台驾驶员待审核列表")
    public PageVo<ResDriverTrainingRegistrationListVO> queryDriverTrainingRegistrationUnDealList
            (@Valid @ModelAttribute ReqDriverTrainingRegistrationListPO po) {
        List<String> metaApplyStatusList = new ArrayList<>();
        metaApplyStatusList.add("FIRST_TRIAL_UNDER_REVIEW");
        metaApplyStatusList.add("REEXAMINATION_UNDER_REVIEW");
        po.setMetaApplyStatusList(metaApplyStatusList);
        return driverArchivesManage.driverTrainingRegistrationUnDealList(po);
    }

    @GetMapping("/abnormalBehavior")
    @ApiOperation("首页工作台驾驶员异常行为数据及列表")
    public HomepageDriverAbnormalBehaviorVo abnormalBehaviorList(@Valid @ModelAttribute HomepageAbnormalBehaviorPageParamDTO param) {
        return homepageManage.abnormalBehaviorList(param);
    }
}
