package jnpf.personnels.service.impl;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jnpf.config.StringToDateConverter;
import jnpf.entity.StoreEntity;
import jnpf.model.enums.StaffWorkerStatus;
import jnpf.model.personnels.bo.FtbRosterImportConstants;
import jnpf.model.personnels.bo.FtbRosterImportHeadRuleBO;
import jnpf.model.personnels.bo.FtbRosterImportRedisBO;
import jnpf.model.personnels.po.FtbPersonnelsRegistrationFormField;
import jnpf.model.personnels.po.FtbPersonnelsRegistrationFormFieldOption;
import jnpf.model.personnels.po.FtbPersonnelsRegistrationFormType;
import jnpf.model.personnels.po.FtbPersonnelsStaffRoster;
import jnpf.model.personnels.vo.roster.FtbRosterAttributesVO;
import jnpf.model.personnels.vo.roster.FtbRosterCategoryVO;
import jnpf.model.personnels.vo.roster.FtbRosterPageVO;
import jnpf.permission.dto.CheckOrgPositionGradesBoundDTO;
import jnpf.personnels.mapper.FtbPersonnelsRegistrationFormFieldMapper;
import jnpf.personnels.mapper.FtbPersonnelsRegistrationFormFieldOptionMapper;
import jnpf.personnels.mapper.FtbPersonnelsRegistrationFormTypeMapper;
import jnpf.personnels.service.FtbPersonnelsBlacklistService;
import jnpf.personnels.service.FtbPersonnelsRosterValidService;
import jnpf.personnels.utils.CacheExcelUtils;
import jnpf.util.RedisUtil;
import jnpf.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service("FtbPersonnelsRosterValidServiceOld")
public class FtbPersonnelsRosterValidServiceImpl implements FtbPersonnelsRosterValidService {

    @Autowired
    private RedisUtil redisUtil;


    @Autowired
    private CacheExcelUtils cacheExcelUtils;

    @Autowired
    private FtbPersonnelsRegistrationFormTypeMapper ftbPersonnelsRegistrationFormTypeMapper;

    @Autowired
    private FtbPersonnelsRegistrationFormFieldMapper ftbPersonnelsRegistrationFormFieldMapper;

    @Autowired
    private FtbPersonnelsRegistrationFormFieldOptionMapper ftbPersonnelsRegistrationFormFieldOptionMapper;

    @Resource
    private FtbPersonnelsBlacklistService ftbPersonnelsBlacklistService;

    @Override
    public Map<Integer, FtbRosterImportHeadRuleBO> headerVerification(String sheetName, Map<Integer, String> head) {
        // 登记表配置
        LambdaQueryWrapper<FtbPersonnelsRegistrationFormType> formTypeLambdaQueryWrapper = Wrappers.lambdaQuery();
        formTypeLambdaQueryWrapper.eq(FtbPersonnelsRegistrationFormType::getEnabledMark, 0);
        formTypeLambdaQueryWrapper.eq(FtbPersonnelsRegistrationFormType::getName, sheetName);
        formTypeLambdaQueryWrapper.eq(FtbPersonnelsRegistrationFormType::getStatus, 0);
        formTypeLambdaQueryWrapper.last("limit 1");
        FtbPersonnelsRegistrationFormType ftbPersonnelsRegistrationFormType = ftbPersonnelsRegistrationFormTypeMapper.selectOne(formTypeLambdaQueryWrapper);
        // 登记表属性
        List<FtbPersonnelsRegistrationFormField> registrationFormFields = ftbPersonnelsRegistrationFormFieldMapper.selectList(
                FtbRosterImportConstants.getRegistrationFormFieldQueryWrapper(ftbPersonnelsRegistrationFormType.getId()));
        // 额外项姓名和手机号码
        FtbRosterImportConstants.nameAndMobileNumberAdded(registrationFormFields, ftbPersonnelsRegistrationFormType.getName());
        if (head.size() != registrationFormFields.size()) {
            throw new RuntimeException("文件中sheet名为" + sheetName + "存在表头不匹配，请重新下载最新模板导入");
        }
        Map<Integer, FtbRosterImportHeadRuleBO> result = new HashMap<>(head.size());
        head.forEach((k, v) -> {
            FtbRosterImportHeadRuleBO ftbRosterImportHeadRuleBO = new FtbRosterImportHeadRuleBO();
            FtbPersonnelsRegistrationFormField ftbPersonnelsRegistrationFormField = registrationFormFields.stream().filter(f -> {
                if (v.contains("*")) {
                    return f.getName().equals(v.substring(v.indexOf("*") + 1));
                }
                return f.getName().equals(v);
            }).findFirst().orElse(null);
            if (ftbPersonnelsRegistrationFormField == null) {
                throw new RuntimeException("文件中sheet名为" + sheetName + "存在表头(" + v + ")不匹配，请重新下载最新模板导入");
            }
            ftbRosterImportHeadRuleBO.setHeadName(v);
            ftbRosterImportHeadRuleBO.setVerificationRule(ftbPersonnelsRegistrationFormField.getRules());
            ftbRosterImportHeadRuleBO.setRequired(ftbPersonnelsRegistrationFormField.getIsNeedFill() == 1);
            // 校验字符仅限单行文本和多行文本
            if (Objects.nonNull(ftbPersonnelsRegistrationFormField.getType()) &&
                    (ftbPersonnelsRegistrationFormField.getType() == 0 || ftbPersonnelsRegistrationFormField.getType() == 1)) {
                ftbRosterImportHeadRuleBO.setVerificationCharacter(ftbPersonnelsRegistrationFormField.getLimits());
            }
            ftbRosterImportHeadRuleBO.setOptionType(ftbPersonnelsRegistrationFormField.getOptionType());
            ftbRosterImportHeadRuleBO.setFormTypeId(StringUtils.hasText(ftbPersonnelsRegistrationFormField.getId()) ?
                    ftbPersonnelsRegistrationFormType.getId() : null);
            ftbRosterImportHeadRuleBO.setFormFieldId(ftbPersonnelsRegistrationFormField.getId());
            // 日期
            if (Objects.nonNull(ftbPersonnelsRegistrationFormField.getType()) && ftbPersonnelsRegistrationFormField.getType() == 4) {
                ftbRosterImportHeadRuleBO.setOptionType(100);
            }
            // 兼容自定义登记表字段单选和多选未设置选项情况
            if (Objects.nonNull(ftbPersonnelsRegistrationFormField.getType()) &&
                    ftbPersonnelsRegistrationFormField.getSystemType() == 1 &&
                    (ftbPersonnelsRegistrationFormField.getType() == 2 || ftbPersonnelsRegistrationFormField.getType() == 3)) {
                ftbRosterImportHeadRuleBO.setOptionType(1);
            }
            // 选项表中选项
            if (Objects.nonNull(ftbPersonnelsRegistrationFormField.getType()) &&
                    (ftbPersonnelsRegistrationFormField.getOptionType() == 1 ||
                            ftbPersonnelsRegistrationFormField.getType() == 2 || ftbPersonnelsRegistrationFormField.getType() == 3)) {
                LambdaQueryWrapper<FtbPersonnelsRegistrationFormFieldOption> formFieldOptionLambdaQueryWrapper = Wrappers.lambdaQuery();
                formFieldOptionLambdaQueryWrapper.select(FtbPersonnelsRegistrationFormFieldOption::getId, FtbPersonnelsRegistrationFormFieldOption::getName);
                formFieldOptionLambdaQueryWrapper.eq(FtbPersonnelsRegistrationFormFieldOption::getEnabledMark, 0);
                formFieldOptionLambdaQueryWrapper.eq(FtbPersonnelsRegistrationFormFieldOption::getFormFieldId, ftbPersonnelsRegistrationFormField.getId());
                List<FtbPersonnelsRegistrationFormFieldOption> ftbPersonnelsRegistrationFormFieldOptions = ftbPersonnelsRegistrationFormFieldOptionMapper.selectList(formFieldOptionLambdaQueryWrapper);
                ftbRosterImportHeadRuleBO.setVerificationOptions(
                        ftbPersonnelsRegistrationFormFieldOptions.stream()
                                .collect(Collectors.toMap(
                                        FtbPersonnelsRegistrationFormFieldOption::getName,
                                        FtbPersonnelsRegistrationFormFieldOption::getId,
                                        (s, a) -> a)));
            }
            result.put(k, ftbRosterImportHeadRuleBO);
        });
        return result;
    }

    @Override
    public void dataValidation(AnalysisContext context, Map<Integer, FtbRosterImportHeadRuleBO> head, Map<Integer, String> data,
                               FtbRosterCategoryVO normalData, FtbRosterCategoryVO errorData) {
        StringBuilder errorBuilder = new StringBuilder();
        FtbRosterPageVO ftbRosterPageVO = new FtbRosterPageVO();
        ftbRosterPageVO.setRowMark(context.readRowHolder().getRowIndex());
        List<FtbRosterAttributesVO> ftbRosterAttributesVOS = new ArrayList<>();
        data.forEach((k, v) -> {
            FtbRosterAttributesVO ftbRosterAttributesVO = new FtbRosterAttributesVO();
            ftbRosterAttributesVO.setLineMark(context.readRowHolder().getRowIndex());
            ftbRosterAttributesVO.setColumnLabel(k);
            ftbRosterAttributesVO.setAttributeValue(v);
            FtbRosterImportHeadRuleBO ftbRosterImportHeadRuleBO = head.get(k);
            // 数据超出表头
            if (ftbRosterImportHeadRuleBO == null) {
                errorBuilder.append("所填数据无对应表头标题;");
                return;
            }
            ftbRosterAttributesVO.setAttributeName(ftbRosterImportHeadRuleBO.getHeadName());
            ftbRosterAttributesVO.setFormTypeId(ftbRosterImportHeadRuleBO.getFormTypeId());
            ftbRosterAttributesVO.setFormFieldId(ftbRosterImportHeadRuleBO.getFormFieldId());
            // 必填项没必填
            if (ftbRosterImportHeadRuleBO.getRequired() && StrUtil.isBlank(v)) {
                errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName()).append("字段内容必填;");
                ftbRosterAttributesVOS.add(ftbRosterAttributesVO);
                return;
            }
            if (StrUtil.isBlank(v)) {
                ftbRosterAttributesVOS.add(ftbRosterAttributesVO);
                return;
            }
            // 校验字符
            if (Objects.nonNull(ftbRosterImportHeadRuleBO.getVerificationCharacter()) &&
                    ftbRosterImportHeadRuleBO.getVerificationCharacter() > 0
                    && v.length() > ftbRosterImportHeadRuleBO.getVerificationCharacter()) {
                errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                        .append("字段内容不能超过")
                        .append(ftbRosterImportHeadRuleBO.getVerificationCharacter())
                        .append("字符;");
            }
            // 校验规则
            if (StrUtil.isNotBlank(ftbRosterImportHeadRuleBO.getVerificationRule())) {
                boolean regularCheck = Pattern.matches(ftbRosterImportHeadRuleBO.getVerificationRule(), v);
                if (!regularCheck) {
                    errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                            .append("字段内容格式有误;");
                }
            }
            // 校验匹配选项 1、选项表中选项  2、省市区选项  3、组织选项 4、岗位选项 5、职等选项 6、门店选项 7、直接主管选项
            if (Objects.nonNull(ftbRosterImportHeadRuleBO.getOptionType()) && ftbRosterImportHeadRuleBO.getOptionType() == 1) {
                // 区分单选和多选
                String multipleSelectionContent = Stream.of(v.split(StringPool.COMMA)).map(a -> {
                    if (!ftbRosterImportHeadRuleBO.getVerificationOptions().containsKey(a)) {
                        errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                                .append("字段内容").append(a).append("不在系统选项范围内;");
                    }
                    return ftbRosterImportHeadRuleBO.getVerificationOptions().get(a);
                }).filter(StrUtil::isNotBlank).collect(Collectors.joining(StringPool.COMMA));
                ftbRosterAttributesVO.setAttributeValueId(multipleSelectionContent);
            }
            // 日期校验
            if (Objects.nonNull(ftbRosterImportHeadRuleBO.getOptionType()) && ftbRosterImportHeadRuleBO.getOptionType() == 100) {
                String date = StringToDateConverter.dateFormatCheck(v);
                if (StrUtil.isBlank(date)) {
                    errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                            .append("字段内容格式有误;");
                } else {
                    ftbRosterAttributesVO.setAttributeValue(date);
                }
            }
            // 合同类型
            if (Objects.nonNull(ftbRosterImportHeadRuleBO.getOptionType()) && ftbRosterImportHeadRuleBO.getOptionType() == 8) {
                String contractTypeName = cacheExcelUtils.doContractTypeName(v);
                if (StrUtil.isBlank(contractTypeName)) {
                    errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                            .append("字段").append(v).append("不在系统内;");
                } else {
                    ftbRosterAttributesVO.setAttributeValueId(contractTypeName);
                }
            }

            // 手机号码和姓名校验
            if ("*手机号码".equals(ftbRosterImportHeadRuleBO.getHeadName())) {
//                if (cacheExcelUtils.doCheckPhone(v)) {
//                    errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
//                            .append("字段").append(v).append("在系统内已经存在;");
//                }

                // 手机号,离职黑名单校验
                if (ftbPersonnelsBlacklistService.hasItBeenBlacklisted(v)) {
                    errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                            .append("字段").append(v).append("已被拉入黑名单;");
                }

                // 校验手机号是否重复
                normalData.getFtbRosterPageVOS().stream()
                        .flatMap(a -> a.getFtbRosterAttributesVOS().stream())
                        .filter(FtbRosterImportConstants.phonePredicate)
                        .filter(c -> Objects.equals(v, c.getAttributeValue())).findFirst()
                        .ifPresent(rosterAttributesVO -> errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                                .append("字段").append(v).append("在第").append(rosterAttributesVO.getLineMark()).append("行存在重复;"));
            }
            // 门店校验
            if (Objects.nonNull(ftbRosterImportHeadRuleBO.getOptionType()) && ftbRosterImportHeadRuleBO.getOptionType() == 6) {
                StoreEntity storeEntity = cacheExcelUtils.doStoreEntity(v);
                if (storeEntity == null) {
                    errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                            .append("字段").append(v).append("不在系统内;");
                } else {
                    ftbRosterAttributesVO.setAttributeValueId(storeEntity.getId());
                }
            }
            // 角色校验
            if (Objects.nonNull(ftbRosterImportHeadRuleBO.getOptionType()) && ftbRosterImportHeadRuleBO.getOptionType() == 9) {
                FtbRosterAttributesVO organizationPredicate = ftbRosterAttributesVOS.stream().filter(FtbRosterImportConstants.organizationPredicate).findFirst().orElse(null);
                if (organizationPredicate != null) {
                    String roleIds = cacheExcelUtils.doCheckRoleInfoVO(organizationPredicate.getAttributeValue(), v);
                    if (!StringUtils.hasText(roleIds)) {
                        errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                                .append("字段").append(v).append("不在系统内;不存在组织和角色绑定关系");
                    } else {
                        ftbRosterAttributesVO.setAttributeValueId(roleIds);
                    }
                }
            }
            // 考勤组校验
            if (Objects.nonNull(ftbRosterImportHeadRuleBO.getOptionType()) && ftbRosterImportHeadRuleBO.getOptionType() == 10) {
                FtbRosterAttributesVO organizationPredicate = ftbRosterAttributesVOS.stream().filter(FtbRosterImportConstants.organizationPredicate).findFirst().orElse(null);
                if (organizationPredicate != null) {
                    String attendanceGroupId = cacheExcelUtils.doCheckAttendanceGroup(organizationPredicate.getAttributeValue(), v);
                    if (!StringUtils.hasText(attendanceGroupId)) {
                        errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                                .append("字段").append(v).append("不在系统内;不存在组织和考勤组绑定关系");
                    } else {
                        ftbRosterAttributesVO.setAttributeValueId(attendanceGroupId);
                    }
                }
            }
            // 直属主管校验
            if ("入职直属主管ID".equals(ftbRosterImportHeadRuleBO.getHeadName())) {
                FtbPersonnelsStaffRoster ftbPersonnelsStaffRoster = cacheExcelUtils.doVerificationByDirectSupervisor(v);
                if (ftbPersonnelsStaffRoster == null) {
                    errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                            .append("字段").append(v).append("不在系统内;");
                } else {
                    // 手机号
                    FtbRosterAttributesVO phoneFtbRosterAttributesVO = normalData.getFtbRosterPageVOS().stream()
                            .flatMap(a -> a.getFtbRosterAttributesVOS().stream())
                            .filter(FtbRosterImportConstants.phonePredicate)
                            .findFirst()
                            .orElseGet(FtbRosterAttributesVO::new);
                    // 直属主管校验
                    if (StaffWorkerStatus.PRE_TRIAL.getCode().equals(ftbPersonnelsStaffRoster.getWorkerStatus())) {
                        errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                                .append("字段").append(v).append("，该用户处于试岗期");
                    } else if (StaffWorkerStatus.RESIGNED.getCode().equals(ftbPersonnelsStaffRoster.getWorkerStatus())) {
                        errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                                .append("字段").append(v).append("，该用户处于已经离职");
                    } else if (ftbPersonnelsStaffRoster.getPhone().equals(phoneFtbRosterAttributesVO.getAttributeValue())) {
                        errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
                                .append("字段").append(v).append("，直属主管不能是自己");
                    }
                    FtbRosterAttributesVO organizationPredicate = ftbRosterAttributesVOS.stream().filter(FtbRosterImportConstants.organizationPredicate).findFirst().orElse(null);
                    if (organizationPredicate != null) {
//                        String nameAndUserId = cacheExcelUtils.checkOrgNameAndUserId(organizationPredicate.getAttributeValue(), ftbPersonnelsStaffRoster.getUserId());
//                        if (StrUtil.isBlank(nameAndUserId)) {
//                            errorBuilder.append(ftbRosterImportHeadRuleBO.getHeadName())
//                                    .append("字段").append(v).append("不在系统内;");
//                        } else {
//                            for (FtbRosterAttributesVO rosterAttributesVO : ftbRosterAttributesVOS) {
//                                if ("入职直属主管".equals(rosterAttributesVO.getAttributeName())) {
//                                    rosterAttributesVO.setAttributeValueId(nameAndUserId);
//                                    break;
//                                }
//                            }
//                        }
                    }
                }
            }
            ftbRosterAttributesVOS.add(ftbRosterAttributesVO);
        });
        if ("工作信息".equals(context.readSheetHolder().getSheetName())) {
            if (StrUtil.isBlank(errorBuilder.toString())) {
                FtbRosterAttributesVO organizationPredicate = ftbRosterAttributesVOS.stream().filter(FtbRosterImportConstants.organizationPredicate).findFirst().orElse(null);
                FtbRosterAttributesVO postPredicate = ftbRosterAttributesVOS.stream().filter(FtbRosterImportConstants.postPredicate).findFirst().orElse(null);
                FtbRosterAttributesVO gradePredicate = ftbRosterAttributesVOS.stream().filter(FtbRosterImportConstants.gradePredicate).findFirst().orElse(null);
                if (Objects.nonNull(organizationPredicate) && Objects.nonNull(postPredicate) && Objects.nonNull(gradePredicate)) {
                    CheckOrgPositionGradesBoundDTO checkOrgPositionGradesBoundDTO = new CheckOrgPositionGradesBoundDTO();
                    checkOrgPositionGradesBoundDTO.setOrgName(organizationPredicate.getAttributeValue());
                    checkOrgPositionGradesBoundDTO.setPositionName(postPredicate.getAttributeValue());
                    checkOrgPositionGradesBoundDTO.setPositionGradesName(gradePredicate.getAttributeValue());
//                    CheckOrgPositionGradesBoundDTO resultCheck = cacheExcelUtils.doCheckOrgPositionGradesBoundDTO(checkOrgPositionGradesBoundDTO);
//                    // 所属组织-岗位-职等校验
//                    if (Objects.isNull(resultCheck)) {
//                        errorBuilder.append("所填写的组织名称、岗位名称、职等名称之间不存在绑定关系;");
//                    } else {
//                        // 校验用户组织权限适用范围，返回null则为超级管理员
//                        List<String> organizationIdDataPermissions = cacheExcelUtils.doPersonnelOrganizationIdDataPermissions();
//                        if (Objects.nonNull(organizationIdDataPermissions) && !organizationIdDataPermissions.contains(resultCheck.getOrgId())) {
//                            errorBuilder.append("导入组织与当前登录人所选权限组织不匹配;");
//                        }
//                        for (FtbRosterAttributesVO rosterAttributesVO : ftbRosterAttributesVOS) {
//                            if (FtbRosterImportConstants.organizationPredicate.test(rosterAttributesVO)) {
//                                rosterAttributesVO.setAttributeValueId(resultCheck.getOrgId());
//                            }
//                            if (FtbRosterImportConstants.postPredicate.test(rosterAttributesVO)) {
//                                rosterAttributesVO.setAttributeValueId(resultCheck.getPositionId());
//                            }
//                            if (FtbRosterImportConstants.gradePredicate.test(rosterAttributesVO)) {
//                                rosterAttributesVO.setAttributeValueId(resultCheck.getPositionGradesId());
//                            }
//                        }
//                    }
                }
                // 实际入职日期校验是否大于今天
                FtbRosterAttributesVO actualDateOfJoining = ftbRosterAttributesVOS.stream().filter(FtbRosterImportConstants.actualDateOfJoining).findFirst().orElse(null);
                if (Objects.nonNull(actualDateOfJoining)) {
                    String actualDateOfJoiningAttributeValue = actualDateOfJoining.getAttributeValue();
                    Date date = StringToDateConverter.dateFormatParser(actualDateOfJoiningAttributeValue);
                    if (date.after(new Date())) {
                        errorBuilder.append("实际入职日期不能大于当前日期;");
                    }
                }
            }
        }
        // 有错误信息
        String errorMsg = errorBuilder.toString();
        if (StrUtil.isNotBlank(errorMsg)) {
            // 手动加错误，逆向导出
            FtbRosterAttributesVO ftbRosterAttributesVO = new FtbRosterAttributesVO();
            ftbRosterAttributesVO.setLineMark(context.readRowHolder().getRowIndex());
            ftbRosterAttributesVO.setColumnLabel(errorData.getHead().size() + 1);
            ftbRosterAttributesVO.setAttributeName(FtbRosterImportConstants.ERROR_REMARKS);
            ftbRosterAttributesVO.setAttributeValue(errorMsg);
            ftbRosterAttributesVOS.add(ftbRosterAttributesVO);
            ftbRosterPageVO.setFtbRosterAttributesVOS(ftbRosterAttributesVOS);
            errorData.getFtbRosterPageVOS().add(ftbRosterPageVO);
        } else {
            ftbRosterPageVO.setFtbRosterAttributesVOS(ftbRosterAttributesVOS);
            normalData.getFtbRosterPageVOS().add(ftbRosterPageVO);
        }
    }

    @Override
    public void saveDataToRedis(AnalysisContext context, FtbRosterCategoryVO normalData, FtbRosterCategoryVO errorData) {
        String loginUserId = UserProvider.getLoginUserId();
        String redisKey = String.format(FtbRosterImportConstants.ROSTER_IMPORT_SHEET_REDIS_VARIABLES, loginUserId);
        redisUtil.insertHash(redisKey, context.readSheetHolder().getSheetName(), JSON.toJSONString(new FtbRosterImportRedisBO(normalData, errorData)));
        // 30分钟自动过期
        redisUtil.expire(redisKey, 30 * 60);
    }

}
