package jnpf.cultivate.controller.web.position;

import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.cultivate.service.FtbCultivatePositionAssessmentService;
import jnpf.model.cultivate.CultivatePage;
import jnpf.model.cultivate.dto.position.FtbCultivatePositionOrgStatisticesDTO;
import jnpf.model.cultivate.vo.position.FtbCultivatePositionAssessmentOrgStatisticVO;
import jnpf.model.cultivate.vo.position.web.FtbCultivatePositionAssessmentListVO;
import jnpf.model.cultivate.vo.position.web.FtbCultivatePositionAssessmentVO;
import jnpf.util.excel.EasyExcelUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * web岗位考核统计
 * @Author: peng.hao
 * @create: 2024/7/22:15:59
 *
 */
@RestController
@RequestMapping("/position-assessment")
public class FtbCultivatePositionAssessmentController {

    @Resource
    FtbCultivatePositionAssessmentService service;


    /**
     * 组织维度统计
     *
     * @param statisticDTO
     * @return
     */
    @PostMapping("/org-list-statistics")
    public ActionResult<PageListVO<FtbCultivatePositionAssessmentOrgStatisticVO>> organizationListStatistics(
            @RequestBody FtbCultivatePositionOrgStatisticesDTO statisticDTO) {
        PageListVO<FtbCultivatePositionAssessmentOrgStatisticVO>  listVO = service.organizationListStatistics(statisticDTO);
        return ActionResult.success(listVO);
    }

    /**
     * 组织维度统计-导出
     *
     * @param statisticDTO
     */
    @PostMapping("/org-list-statistics/export")
    public void exportOrganizationListStatistics(@RequestBody FtbCultivatePositionOrgStatisticesDTO statisticDTO, HttpServletResponse response) throws IOException {
        statisticDTO.setPageSize(999999);
        PageListVO<FtbCultivatePositionAssessmentOrgStatisticVO>  listVO = service.organizationListStatistics(statisticDTO);
        EasyExcelUtils.exportExcel(response, "组织维度统计", listVO.getList(), FtbCultivatePositionAssessmentOrgStatisticVO.class);
    }

    /**
     * 岗位考核详情
     * @param orgId 组织id
     * @param positionId 岗位id
     * @return
     */
    @GetMapping("/job-assessment-list")
    public ActionResult<FtbCultivatePositionAssessmentVO> jobAssessmentList(@RequestParam("orgId") String orgId,
                                                                                            @RequestParam("positionId") String positionId,
                                                                                            CultivatePage page){
        FtbCultivatePositionAssessmentVO listVO = service.jobAssessmentList(orgId, positionId, page);
        return ActionResult.success(listVO);
    }
    /**
     * 岗位考核详情导出
     * @param orgId 组织id
     * @param positionId 岗位id
     * @return
     */
    @GetMapping("/job-assessment-list/export")
    public void exportJobAssessmentList(@RequestParam("orgId") String orgId,
                                        @RequestParam("positionId") String positionId,
                                        CultivatePage page,
                                        HttpServletResponse response) throws IOException {
        page.setPageSize(999999);
        FtbCultivatePositionAssessmentVO listVO = service.jobAssessmentList(orgId, positionId, page);
        EasyExcelUtils.exportExcel(response, "岗位考核详情列表", listVO.getList().getList(), FtbCultivatePositionAssessmentListVO.class);
    }
}
