package com.ningdatech.carapi.industry.controller;

import com.alibaba.fastjson.JSONObject;
import com.ningdatech.carapi.car.datascreen.model.dto.DataScreenParam;
import com.ningdatech.carapi.car.datascreen.model.vo.*;
import com.ningdatech.carapi.common.util.CodeUtil;
import com.ningdatech.carapi.industry.manage.DataScreenManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
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.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-10-22
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/industry/data-screen")
@Api(value = "industry", tags = "行业服务-大屏")
@RequiredArgsConstructor
public class DataScreenController {

    private final DataScreenManage dataScreenManage;


    @ApiOperation(value = "各区域车辆分布", notes = "各区域车辆分布")
    @GetMapping("/region")
    public List<RegionDistributionStatisticsVO> regionDistribution(@Valid @ModelAttribute DataScreenParam param) {
        CodeUtil.convertRegionCodeToId(param);
        return dataScreenManage.regionDistribution(param);
    }

    @ApiOperation(value = "全省当前驾驶员合格证数", notes = "全省当前驾驶员合格证数")
    @GetMapping("/tain-certificate")
    public Map<String, Object> tainCertificate(@Valid @ModelAttribute DataScreenParam param) {
        CodeUtil.convertRegionCodeToId(param);
        return dataScreenManage.tainCertificate(param);
    }

    @ApiOperation(value = "实验室从业资格证", notes = "实验室从业资格证")
    @GetMapping("/laboratory-qualification-certificate")
    public JSONObject laboratoryQualificationCertificate(@Valid @ModelAttribute DataScreenParam param) {
        CodeUtil.convertRegionCodeToId(param);
        return dataScreenManage.laboratoryQualificationCertificate(param);
    }

    @ApiOperation(value = "实验室验收合格证", notes = "实验室验收合格证")
    @GetMapping("/laboratory-acceptance-certificate")
    public JSONObject laboratoryAcceptanceCertificate(@Valid @ModelAttribute DataScreenParam param) {
        CodeUtil.convertRegionCodeToId(param);
        return dataScreenManage.laboratoryAcceptanceCertificate(param);
    }

    @ApiOperation(value = "砂浆企业备案证", notes = "砂浆企业备案证")
    @GetMapping("/record-certificate-mortar-enterprise")
    public JSONObject recordCertificateMortarEnterprise(@Valid @ModelAttribute DataScreenParam param) {
        CodeUtil.convertRegionCodeToId(param);
        return dataScreenManage.recordCertificateMortarEnterprise(param);
    }
}
