package com.yanzhu.jh.project.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.yanzhu.jh.project.domain.SurProject;
import com.yanzhu.jh.project.domain.vo.ProjectViewExport;
import com.yanzhu.jh.project.service.IProjectViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * ProjectViewController
 * 项目统计
 * @author JiangYuQi
 * @date 2023-07-29
 */
@RestController
@RequestMapping("/statistics/project")
public class ProjectViewController extends BaseBuildNodeController{

    @Autowired
    IProjectViewService projectViewService;

    @GetMapping("/selectStatisticsProjectList")
    public TableDataInfo selectStatisticsProjectList(SurProject surProject)
    {
        List<ProjectViewExport> list = projectViewService.selectStatisticsProjectList(surProject);
        return getDataTable(list);
    }

    /**
     * 导出项目管理列表
     */
    @Log(title = "项目数据汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/exportView")
    public void exportView(HttpServletResponse response, SurProject surProject)
    {
        List<ProjectViewExport> list = projectViewService.selectStatisticsProjectList(surProject);
        ExcelUtil<ProjectViewExport> util = new ExcelUtil<ProjectViewExport>(ProjectViewExport.class);
        util.exportExcel(response, list, "项目数据汇总");
    }

}
