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.FtbPersonnelChangesService;
import jnpf.personnels.utils.PersonnelDataAnalysisUtil;
import lombok.extern.slf4j.Slf4j;
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 java.io.IOException;
import java.util.List;

/**
 * web人事异动分析模块
 * @author wangchunxiang
 * @date 2025/04/08
 */
@RestController
@Slf4j
@RequestMapping("/web/change-analysis")
public class FtbPersonnelChangesController {

    @Resource
    private FtbPersonnelChangesService ftbPersonnelChangesService;

    /**
     * 人事异动调店人数同比环比
     */
    @PostMapping("/get-reg-shop-adjustment")
    public ActionResult<FtbPersonnlesBrainShopAdjustmentVO> getBrainDrainCorrectRateShopAdjustment(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        FtbPersonnlesBrainShopAdjustmentVO result = ftbPersonnelChangesService.getBrainDrainCorrectRateShopAdjustment(dto);
        return ActionResult.success(result);
    }

    /**
     * 人事异动调岗人数同比环比
     */
    @PostMapping("/get-reg-transfer-post")
    public ActionResult<FtbPersonnlesBrainShopAdjustmentVO> getBrainDrainCorrectRateTransferPost(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        FtbPersonnlesBrainShopAdjustmentVO result = ftbPersonnelChangesService.getBrainDrainCorrectRateTransferPost(dto);
        return ActionResult.success(result);
    }

    /**
     * 人事异动调店人数 门店维度,部门维度，岗位维度
     */
    @PostMapping("/get-regularization-store-dimension-shop-adjustment")
    public ActionResult<List<FtbPersonnelsPeopleTransferRatioVO>> getRegularizationStoreDimensionShopAdjustment(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        List<FtbPersonnelsPeopleTransferRatioVO> result = ftbPersonnelChangesService.getRegularizationStoreDimensionShopAdjustment(dto);
        return ActionResult.success(result);
    }

    /**
     * 人事异动调岗人数 门店维度,部门维度，岗位维度
     */
    @PostMapping("/get-regularization-store-dimension-transfer-post")
    public ActionResult<List<FtbPersonnelsPeopleTransferRatioVO>> getRegularizationStoreDimensionTransferPost(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        List<FtbPersonnelsPeopleTransferRatioVO> result = ftbPersonnelChangesService.getRegularizationStoreDimensionTransferPost(dto);
        return ActionResult.success(result);
    }

    /**
     * 调店人数分布列表
     */
    @PostMapping("/shop-adjustment-details")
    public ActionResult<PersonnelDataAnalysisListVO> shopAdjustmentDetails(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        PageListVO<FtbPersonnelsShopAdjustmentDetailsVO> result = ftbPersonnelChangesService.shopAdjustmentDetails(dto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, FtbPersonnelsShopAdjustmentDetailsVO.class));
    }

    /**
     * 调店人数分布列表导出
     */
    @PostMapping("/shop-adjustment-details-export")
    public void shopAdjustmentDetailsExport(@RequestBody FtbPersonnlesAnalysisDTO dto) throws IOException {
        ftbPersonnelChangesService.shopAdjustmentDetailsExport(dto);
    }

    /**
     * 调岗人数分布列表
     */
    @PostMapping("/post-adjustment-details")
    public ActionResult<PersonnelDataAnalysisListVO> postAdjustmentDetails(@RequestBody FtbPersonnlesAnalysisDTO dto) {
        PageListVO<FtbPersonnelsPostAdjustmentDetailsVO> result = ftbPersonnelChangesService.postAdjustmentDetails(dto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, FtbPersonnelsPostAdjustmentDetailsVO.class));
    }

    /**
     * 调岗人数分布列表导出
     */
    @PostMapping("/post-adjustment-details-export")
    public void postAdjustmentDetailsExport(@RequestBody FtbPersonnlesAnalysisDTO dto) throws IOException {
        ftbPersonnelChangesService.postAdjustmentDetailsExport(dto);
    }

}
