package com.ningdatech.carapi.company.controller;

import com.ningdatech.carapi.common.util.CodeUtil;
import com.ningdatech.carapi.company.entity.dto.ResCompanyTotalDTO;
import com.ningdatech.carapi.company.service.ICompanyLargeScreenService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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;

/**
 * @description: 企业管理大屏
 * @author: liushuai
 * @date: 2022/10/25 10:12
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/company-large-screen")
public class CompanyLargeScreenController {
    private final ICompanyLargeScreenService iCompanyLargeScreenService;

    @GetMapping("/statistics")
    @ApiOperation(value = "按区域统计数量",notes = "按区域统计数量")
    public List<ResCompanyTotalDTO> getCompanyCount(@RequestParam(value = "regionId") Long regionId) {
        regionId = CodeUtil.convertRegionCodeToId(regionId);
        return iCompanyLargeScreenService.getCompanyTotalByRegionId(regionId);
    }

    @GetMapping("/enterprise-type")
    @ApiOperation(value = "按企业类型统计数量",notes = "按企业类型统计数量")
    public List<ResCompanyTotalDTO> enterpriseType(@RequestParam(value = "regionId") Long regionId) {
        regionId = CodeUtil.convertRegionCodeToId(regionId);
        return iCompanyLargeScreenService.countEnterpriseType(regionId);
    }

    @GetMapping("/dead-accident")
    @ApiOperation(value = "半年内发生死亡事故",notes = "半年内发生死亡事故")
    public List<ResCompanyTotalDTO> deadAccident(@RequestParam(value = "regionId") Long regionId) {
        regionId = CodeUtil.convertRegionCodeToId(regionId);
        return iCompanyLargeScreenService.deadAccident(regionId);
    }

    @GetMapping("/mortar-quality")
    @ApiOperation(value = "砂浆质量通道",notes = "砂浆质量通道")
    public List<ResCompanyTotalDTO> mortarQuality(@RequestParam(value = "regionId") Long regionId) {
        regionId = CodeUtil.convertRegionCodeToId(regionId);
        return iCompanyLargeScreenService.mortarQuality(regionId);
    }
}
