package com.engine.salary.wrapper;

import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.salaryacct.param.*;
import com.engine.salary.service.SalaryAcctExcelService;
import com.engine.salary.service.impl.SalaryAcctExcelServiceImpl;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;

/**
 * 薪资核算导出导出
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public class SalaryAcctExcelWrapper extends Service {

    private SalaryAcctExcelService getSalaryAcctExcelService(User user) {
        return (SalaryAcctExcelService) ServiceUtil.getService(SalaryAcctExcelServiceImpl.class, user);
    }
    /**
     * 薪资核算人员导出
     *
     * @param queryParam
     */
    public XSSFWorkbook exportSalaryAcctEmployee(SalaryAcctEmployeeQueryParam queryParam) {
        return getSalaryAcctExcelService(user).exportSalaryAcctEmployee(queryParam);
    }

    /**
     * 薪资核算环比减少人员导出
     *
     * @param queryParam
     * @return
     */
    public XSSFWorkbook exportReducedEmployee(SalaryAcctEmployeeQueryParam queryParam) {
        return getSalaryAcctExcelService(user).exportReducedEmployee(queryParam);
    }



    /**
     * 薪资核算环比增加人员导出
     *
     * @param queryParam
     * @return
     */
    public XSSFWorkbook exportAddedEmployee(SalaryAcctEmployeeQueryParam queryParam) {
        return getSalaryAcctExcelService(user).exportAddedEmployee(queryParam);
    }

    /**
     * 薪资核算结果导出
     *
     * @param queryParam
     * @return
     */
    public XSSFWorkbook exportSalaryAcctResult(SalaryAcctResultQueryParam queryParam) {
        return getSalaryAcctExcelService(user).exportSalaryAcctResult(queryParam);
    }

    /**
     * 下载薪资核算导入模板
     *
     * @param param
     * @return
     */
    public XSSFWorkbook exportImportTemplate(SalaryAcctImportTemplateParam param) {
        return getSalaryAcctExcelService(user).exportImportTemplate( param);
    }

    /**
     * 薪资核算线下对比结果导出
     *
     * @param queryParam
     * @return
     */
    public XSSFWorkbook exportComparisonResult(SalaryComparisonResultQueryParam queryParam) {
        return  getSalaryAcctExcelService(user).exportComparisonResult( queryParam);
    }

    /**
     * 薪资核算线下对比结果导入模板导出
     *
     * @param exportParam
     * @return
     */
    public XSSFWorkbook exportComparisonResultTemplate(SalaryComparisonResultExportParam exportParam) {
        return getSalaryAcctExcelService(user).exportComparisonResultTemplate(exportParam);
    }

//    /**
//     * 薪资核算结果校验异常导出
//     *
//     * @param exportParam
//     * @param simpleEmployee
//     * @param tenantKey
//     * @param eteamsId
//     * @return
//     */
//    public Map<String, Object> exportCheckResult(SalaryCheckResultExportParam exportParam,
//                                                 DataCollectionEmployee simpleEmployee, String tenantKey, String eteamsId) {
//        ExcelExportParam excelExportParam = new ExcelExportParam()
//                .setModule(EntityType.hrsa.name())
//                .setFunction("salaryCheckResultHandler");
//        LocalRunnable localRunnable = new LocalRunnable() {
//            @Override
//            public void execute() {
//                try {
//                    DSTenantKeyThreadVar.tenantKey.set(tenantKey);
//                    getSalaryAcctExcelService(user).exportCheckResult(excelExportParam, exportParam, simpleEmployee, tenantKey, eteamsId);
//                } finally {
//                    DSTenantKeyThreadVar.tenantKey.remove();
//                }
//            }
//        };
//        ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportCheckResult", localRunnable);
//        return JsonUtil.parseMap(excelExportParam, Object.class);
//    }
//
//    /**
//     * 薪资核算结果校验异常明细导出
//     *
//     * @param checkResultId
//     * @param simpleEmployee
//     * @param tenantKey
//     * @param eteamsId
//     * @return
//     */
//    public Map<String, Object> exportCheckResultDetail(Long checkResultId,
//                                                       DataCollectionEmployee simpleEmployee, String tenantKey, String eteamsId) {
//        ExcelExportParam excelExportParam = new ExcelExportParam()
//                .setModule(EntityType.hrsa.name())
//                .setFunction("salaryCheckResultDetailHandler");
//        LocalRunnable localRunnable = new LocalRunnable() {
//            @Override
//            public void execute() {
//                try {
//                    DSTenantKeyThreadVar.tenantKey.set(tenantKey);
//                    getSalaryAcctExcelService(user).exportCheckResultDetail(excelExportParam, checkResultId, simpleEmployee, tenantKey, eteamsId);
//                } finally {
//                    DSTenantKeyThreadVar.tenantKey.remove();
//                }
//            }
//        };
//        ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportCheckResultDetail", localRunnable);
//        return JsonUtil.parseMap(excelExportParam, Object.class);
//    }
}
