package com.qianhe.zqbf.controller;

import com.qianhe.common.core.controller.BaseController;
import com.qianhe.common.core.domain.AjaxResult;
import com.qianhe.common.core.page.TableDataInfo;
import com.qianhe.common.exception.BusinessException;
import com.qianhe.zqbf.domain.ZqczTjfxQuery;
import com.qianhe.zqbf.service.ZqbfXmzTjfxService;
import lombok.extern.slf4j.Slf4j;
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.RestController;

@Slf4j
@RestController
@RequestMapping("/zqbf/tjfx")
public class ZqbfXmzTjfxController extends BaseController {
    @Autowired
    private ZqbfXmzTjfxService zqbfXmzTjfxService;

    /**
     * 管理区上报数量
     */
    @GetMapping("/glqsbsl")
    public AjaxResult glqsbsl(ZqczTjfxQuery zqczTjfxQuery) {
        try {
            return success(zqbfXmzTjfxService.glqsbsl(zqczTjfxQuery));
        } catch (BusinessException e) {
            log.warn("最强帮扶-统计分析-管理区上报数量-查询失败：" + e.getMessage());
            return warn(e.getMessage());
        } catch (Exception e) {
            log.error(e.getMessage());
            return error(e.getMessage());
        }
    }

    /**
     * 帮扶项目统计占比
     */
    @GetMapping("/bfxmtjzb")
    public AjaxResult bfxmtjzb(ZqczTjfxQuery zqczTjfxQuery){
        try {
            return success(zqbfXmzTjfxService.bfxmtjzb(zqczTjfxQuery));
        } catch (BusinessException e) {
            log.warn("最强帮扶-统计分析-帮扶项目统计占比-查询失败：" + e.getMessage());
            return warn(e.getMessage());
        } catch (Exception e) {
            log.error(e.getMessage());
            return error(e.getMessage());
        }
    }

    /**
     * 帮扶项目统计排名
     */
    @GetMapping("/bfxmtjpm")
    public AjaxResult bfxmtjpm(ZqczTjfxQuery zqczTjfxQuery){
        try {
            return success(zqbfXmzTjfxService.bfxmtjpm(zqczTjfxQuery));
        } catch (BusinessException e) {
            log.warn("最强帮扶-统计分析-帮扶项目统计排名-查询失败：" + e.getMessage());
            return warn(e.getMessage());
        } catch (Exception e) {
            log.error(e.getMessage());
            return error(e.getMessage());
        }
    }
    /**
     * 帮扶专家统计排名
     */
    @GetMapping("/bfzjtjpm")
    public TableDataInfo bfzjtjpm(ZqczTjfxQuery zqczTjfxQuery){
        startPage();
        return getDataTable(zqbfXmzTjfxService.bfzjtjpm(zqczTjfxQuery));
    }

    /**
     * 帮扶专家统计排名 Echarts
     */
    @GetMapping("/bfzjtjpm_echarts")
    public AjaxResult bfzjtjpm_echarts(ZqczTjfxQuery zqczTjfxQuery){
        try {
            return success(zqbfXmzTjfxService.bfzjtjpm_echarts(zqczTjfxQuery));
        } catch (BusinessException e) {
            log.warn("最强帮扶-统计分析-帮扶项目统计排名-查询失败：" + e.getMessage());
            return warn(e.getMessage());
        } catch (Exception e) {
            log.error(e.getMessage());
            return error(e.getMessage());
        }
    }
}
