package jnpf.personnels.controller.web.analysis;

import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.model.personnels.dto.analysis.FtbPersonnlesAnalysisDTO;
import jnpf.model.personnels.vo.analysis.*;
import jnpf.personnels.service.FtbPersonnelsBrainDrainService;
import jnpf.personnels.utils.PersonnelDataAnalysisUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * web统计人才流失
 * @Author: peng.hao
 * @create: 2025/4/8
 */
@RestController
@RequestMapping("/web/brain-drain")
public class FtbPersonnelsBrainDrainController {

    @Resource
    private FtbPersonnelsBrainDrainService ftbPersonnelsBrainDrainService;

    /**
     * 人事异动转正人数同比环比
     */
    @PostMapping("/get-reg-comparison")
    public ActionResult<FtbPersonnlesBrainDrainVO> getBrainDrainCorrectRateComparison(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        return ActionResult.success(ftbPersonnelsBrainDrainService.getBrainDrainCorrectRateComparison(dto));
    }

    /**
     * 人事异动新人率人数同比环比
     */
    @PostMapping("/get-reg-NewcomerRate")
    public ActionResult<FtbPersonnlesBrainDrainVO> getBrainDrainCorrectRateNewcomerRate(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        return ActionResult.success(ftbPersonnelsBrainDrainService.getBrainDrainCorrectRateNewcomerRate(dto));
    }
    /**
     * 人事异动入职人数 门店维度，部门维度，岗位维度
     */
    @PostMapping("/get-onboarding-store-dimension")
    public ActionResult<List<FtbPersonnelsPeopleInfoRatioVO>> getOnboardingStoreDimension(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        return ActionResult.success(ftbPersonnelsBrainDrainService.getOnboardingStoreDimension(dto));
    }

    /**
     * 人事异动转正人数 门店维度，部门维度，岗位维度
     */
    @PostMapping("/get-regularization-store-dimension")
    public ActionResult<List<FtbPersonnelsPeopleInfoRatioVO>> getRegularizationStoreDimension(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        return ActionResult.success(ftbPersonnelsBrainDrainService.getRegularizationStoreDimension(dto));
    }

    /**
     * 人事异动离职人数 门店维度，部门维度，岗位维度
     */
    @PostMapping("/get-turnover-store-dimension")
    public ActionResult<List<FtbPersonnelsPeopleInfoRatioVO>> getTurnoverStoreDimension(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        return ActionResult.success(ftbPersonnelsBrainDrainService.getTurnoverStoreDimension(dto));
    }

    /**
     * 人事异动新人率 岗位维度、门店维度、部门维度 进行展示
     */
    @PostMapping("/get-new-hire-rate-dimension")
    public ActionResult<List<FtbPersonnelsPeopleInfoRatioVO>> getNewHireRateDimension(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        return ActionResult.success(ftbPersonnelsBrainDrainService.getNewHireRateDimension(dto));
    }



    /**
     * 入职明细
     */
    @PostMapping("/get-onboarding-detail")
    public ActionResult<PersonnelDataAnalysisListVO> getOnboardingDetail(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        PageListVO<FtbPersonnelsOnboardingDetailVO> result = ftbPersonnelsBrainDrainService.getOnboardingDetail(dto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, FtbPersonnelsOnboardingDetailVO.class));
    }

    /**
     * 入职明细导出
     */
    @PostMapping("/get-onboarding-detail-export")
    public void getOnboardingDetailExprot(@RequestBody FtbPersonnlesAnalysisDTO dto, HttpServletResponse response) {
        ftbPersonnelsBrainDrainService.getOnboardingDetailExport(dto, response);
    }

    /**
     * 转正明细
     */
    @PostMapping("/get-regularization-detail")
    public ActionResult<PersonnelDataAnalysisListVO> getRegularizationDetail(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        PageListVO<FtbPersonnelsRegularizationDetailVO> result = ftbPersonnelsBrainDrainService.getRegularizationDetail(dto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, FtbPersonnelsRegularizationDetailVO.class));
    }

    /**
     * 转正明细导出
     */
    @PostMapping("/get-regularization-detail-export")
    public void getRegularizationDetailExprot(@RequestBody FtbPersonnlesAnalysisDTO dto, HttpServletResponse response) {
        ftbPersonnelsBrainDrainService.getRegularizationDetailExport(dto, response);
    }
    /**
     * 新人率占比明细
     */
    @PostMapping("/get-new-hire-rate-detail")
    public ActionResult<PersonnelDataAnalysisListVO> getNewHireRateDetail(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        PageListVO<FtbPersonnelsNewHireRateDetailVO> result = ftbPersonnelsBrainDrainService.getNewHireRateDetail(dto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, FtbPersonnelsNewHireRateDetailVO.class));
    }

    /**
     * 新人率占比明细导出
     */
    @PostMapping("/get-new-hire-rate-detail-export")
    public void getNewHireRateDetailExport(@RequestBody FtbPersonnlesAnalysisDTO dto, HttpServletResponse response) {
        ftbPersonnelsBrainDrainService.getNewHireRateDetailExport(dto, response);
    }

}
