package com.engine.recruit.service.impl;

import com.engine.core.impl.Service;
import com.engine.recruit.conn.*;
import com.engine.recruit.constant.RecruitConstant;
import com.engine.recruit.entity.card.*;
import com.engine.recruit.entity.card.process.*;
import com.engine.recruit.entity.record.ApplicantRecordPo;
import com.engine.recruit.enums.ApplicantOperateEnum;
import com.engine.recruit.enums.ApplicationStatusEnum;
import com.engine.recruit.enums.RecordOperateEnum;
import com.engine.recruit.exception.CustomizeRunTimeException;
import com.engine.recruit.service.ApplicantResumeService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.IOUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.file.ImageFileManager;
import weaver.formmode.recruit.modeexpand.util.RecruitModeUtil;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;

import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author:dxfeng
 * @createTime: 2023/09/20
 * @version: 1.0
 */
public class ApplicantResumeServiceImpl extends Service implements ApplicantResumeService {

    @Override
    public Map<String, Object> getApplicantsName(String ids) {
        Map<String, Object> returnMap = new HashMap<>(1);
        RecordSet rs = new RecordSet();
        String[] split = ids.split(",");
        List<Map<String, Object>> list = new ArrayList<>();
        for (String id : split) {
            rs.executeQuery("select xm from uf_jcl_yppc where id = ?", id);
            if (rs.next()) {
                Map<String, Object> rowMap = new HashMap<>();
                rowMap.put("id", id);
                rowMap.put("name", rs.getString("xm"));
                list.add(rowMap);
            }
        }
        returnMap.put("rows", list);
        return returnMap;
    }

    @Override
    public Map<String, Object> getInterviewInfoById(String id) {
        Map<String, Object> returnMap = new HashMap<>(16);
        String sql = "select a.ypz,b.xm,a.ypzw,b.tdsj,b.sjhm,b.dzyx,a.msfs,a.mshj ,a.msc,a.msg ,a.ptmsg,a.msrq,a.msdd ,a.msfkr from uf_jcl_ms a inner join uf_jcl_yppc b on a.ypz = b.id where a.id = ?";
        RecordSet rs = new RecordSet();
        rs.executeQuery(sql, id);
        if (rs.next()) {
            // 应聘者
            returnMap.put("ypz", createApplicantBrowserMap(rs.getString("ypz"), rs.getString("xm")));
            // 应聘职位
            returnMap.put("ypzw", createAppliedPositionBrowserMap(rs.getString("ypzw")));
            // 投递时间
            returnMap.put("tdsj", createApplicantBrowserMap(rs.getString("tdsj")));
            // 手机号码
            returnMap.put("sjhm", createApplicantBrowserMap(rs.getString("sjhm")));
            // 电子邮箱
            returnMap.put("dzyx", createApplicantBrowserMap(rs.getString("dzyx")));
            // 面试方式
            returnMap.put("msfs", createApplicantBrowserMap(rs.getString("msfs")));
            // 面试环节
            returnMap.put("mshj", createApplicantBrowserMap(rs.getString("mshj")));
            // 面试轮次
            returnMap.put("msc", createApplicantBrowserMap(rs.getString("msc")));
            // 面试官
            returnMap.put("msg", createResourceBrowserMap(rs.getString("msg")));
            // 陪同面试官
            returnMap.put("ptmsg", createResourceBrowserMap(rs.getString("ptmsg")));
            // 面试日期
            returnMap.put("msrq", createApplicantBrowserMap(rs.getString("msrq")));
            // 面试地址
            returnMap.put("msdd", createApplicantBrowserMap(rs.getString("msdd")));
        }
        return returnMap;
    }

    @Override
    public Map<String, Object> getDisplayLayoutId(Map<String, Object> params) {
        Map<String, Object> returnMap = new HashMap<>();
        String layoutId = Util.null2String(params.get("layoutid"));
        String modeId = Util.null2String(params.get("modeId"));
        returnMap.put("layoutId", layoutId);
        RecordSet rs = new RecordSet();
        rs.executeQuery("select layoutname from modehtmllayout where modeid = ? and id = ?", modeId, layoutId);
        if (rs.next()) {
            String layoutName = rs.getString("layoutname");
            // 获取相同名称的显示布局ID
            rs.executeQuery("select id from modehtmllayout where type = 0 and modeid = ? and layoutname =?", modeId, layoutName);
            if (rs.next()) {
                returnMap.put("layoutId", rs.getString("id"));
            }
        }
        return returnMap;
    }

    @Override
    public Map<String, Object> getTabCount(Map<String, Object> params) {
        Map<String, Object> returnMap = new HashMap<>();
        String billId = Util.null2String(params.get("billid"));
        List<Integer> countList = new ArrayList<>();
        RecordSet rs = new RecordSet();
        // 部门筛选反馈
        rs.executeQuery("select count(id) as num from uf_jcl_bmsxfk where ypz = ?", billId);
        if (rs.next()) {
            countList.add(rs.getInt("num"));
        }
        // 笔试
        rs.executeQuery("select count(id) as num from uf_jcl_bs where ypz = ?", billId);
        if (rs.next()) {
            countList.add(rs.getInt("num"));
        }
        // 面试
        rs.executeQuery("select count(id) as num from uf_jcl_ms where ypz = ?", billId);
        if (rs.next()) {
            countList.add(rs.getInt("num"));
        }
        // 背调
        rs.executeQuery("select count(id) as num from uf_jcl_bd where ypz = ?", billId);
        if (rs.next()) {
            countList.add(rs.getInt("num"));
        }
        // 薪酬谈判
        rs.executeQuery("select count(id) as num from uf_jcl_xctp where ypz = ?", billId);
        if (rs.next()) {
            countList.add(rs.getInt("num"));
        }
        // 历史投递记录
        rs.executeQuery("select xm,sjhm from uf_jcl_yppc where id = ?", billId);
        if (rs.next()) {
            rs.executeQuery("select count(id) as num from uf_jcl_yppc where xm=? and sjhm =?", rs.getString("xm"), rs.getString("sjhm"));
            if (rs.next()) {
                countList.add(rs.getInt("num"));
            }
        } else {
            countList.add(0);
        }


        returnMap.put("countList", countList);
        return returnMap;
    }

    @Override
    public Map<String, Object> updateApplicantsInfo(Map<String, Object> params) {
        Map<String, Object> returnMap = new HashMap<>();
        String operateType = Util.null2String(params.get("operateType"));
        RecordSet rs = new RecordSet();
        if (ApplicantOperateEnum.ELIMINATE.getOperateType().equals(operateType)) {
            // 淘汰
            String ids = Util.null2String(params.get("ids"));
            rs.executeUpdate("update uf_jcl_yppc set zt = ? where id in (" + ids + ")", ApplicationStatusEnum.OBSOLETE.getValue());

            // 插入应聘过程
            String dateTime = DateUtil.getDateTime();
            for (String s : ids.split(",")) {
                ApplicantRecordPo recordPo = ApplicantRecordPo.builder()
                        .billId(s)
                        .operateTime(dateTime)
                        .user(user)
                        .recordOperateType(RecordOperateEnum.ELIMINATE)
                        .build();
                recordPo.execute();
            }

            returnMap.put("msg", "操作成功");
        } else if (ApplicantOperateEnum.TRANSFER.getOperateType().equals(operateType)) {
            // 转移阶段
            String dqypjd = Util.null2String(params.get("dqypjd"));
            String billid = Util.null2String(params.get("billid"));
            Map<String, Object> otherParam = new HashMap<>();
            otherParam.put("sourceStep", ApplicantCommonInfo.getCurrentStep(billid).getDescription());
            // 查询当前阶段的阶段类型
            rs.executeQuery("select jdlx from uf_jcl_zpjdsz where id = ?", dqypjd);
            if (rs.next()) {
                String jdlx = rs.getString("jdlx");
                rs.executeUpdate("update uf_jcl_yppc set zpjd = ?,dqypjd = ? where id = ?", dqypjd, jdlx, billid);
                returnMap.put("msg", "操作成功");
            } else {
                throw new CustomizeRunTimeException("转移阶段失败");
            }
            rs.executeQuery("select ypzw,zplc from uf_jcl_yppc where id = ?", billid);
            if(rs.next()) {
                StepMsgCommonInfo.sendMsg(String.valueOf(billid), Util.null2String(rs.getString("ypzw")), Util.null2String(rs.getString("zplc")), dqypjd, user);
            }


            otherParam.put("targetStep", ApplicantCommonInfo.getCurrentStep(billid).getDescription());

            // 插入应聘过程
            ApplicantRecordPo recordPo = ApplicantRecordPo.builder()
                    .billId(billid)
                    .operateTime(DateUtil.getDateTime())
                    .user(user)
                    .recordOperateType(RecordOperateEnum.TRANSFER_STAGE)
                    .otherParam(otherParam)
                    .build();
            recordPo.execute();
        } else if (ApplicantOperateEnum.ASSIGN.getOperateType().equals(operateType)) {
            // 分配职位
            String billid = Util.null2String(params.get("billid"));
            if (StringUtils.isNotBlank(billid)) {
                // 兼容V1版本，分配职位操作
                String ypzw = Util.null2String(params.get("ypzw"));
                if (StringUtils.isBlank(ypzw)) {
                    throw new CustomizeRunTimeException("应聘职位不可为空");
                }
                String flowId = PositionCommonInfo.getRecruitFlowId(ypzw);
                Map<String, String> initialStage = ApplicantCommonInfo.getInitialStage(flowId);
                String zpjd = "";
                String dqypjd = "";
                if (null != initialStage) {
                    zpjd = initialStage.get("zpjd");
                    dqypjd = initialStage.get("jdlx");
                }
                rs.executeUpdate("update uf_jcl_yppc set ypzw = ? , zplc = ? , zpjd = ? , dqypjd = ?, zt = 1 where id = ?", ypzw, flowId, zpjd, dqypjd, billid);
                StepMsgCommonInfo.sendMsg(billid, Util.null2String(ypzw), Util.null2String(flowId), Util.null2String(zpjd), user);
            } else {
                String ids = Util.null2String(params.get("ids"));
                // 校验所选
                rs.executeQuery("select id from uf_jcl_yppc where zt != 0 and id in(" + ids + ")");
                if (rs.next()) {
                    throw new CustomizeRunTimeException("操作失败，当前存在非待分配简历数据，请刷新后重试");
                }
                String ypzw = Util.null2String(params.get("ypzw"));
                String zplc = Util.null2String(params.get("zplc"));
                String zpjd = Util.null2String(params.get("zpjd"));
                String dqypjd = Util.null2String(params.get("dqypjd"));
                if (StringUtils.isBlank(ypzw)) {
                    throw new CustomizeRunTimeException("应聘职位不可为空");
                }
                if (StringUtils.isBlank(zplc)) {
                    throw new CustomizeRunTimeException("未获取到招聘流程，请检查招聘职位配置");
                }
                if (StringUtils.isBlank(zpjd)) {
                    throw new CustomizeRunTimeException("未获取到招聘阶段，请检查招聘流程配置");
                }
                if (StringUtils.isBlank(dqypjd)) {
                    throw new CustomizeRunTimeException("当前应聘阶段获取失败");
                }
                rs.executeUpdate("update uf_jcl_yppc set ypzw = ? , zplc = ? , zpjd = ? , dqypjd = ?, zt = 1 where id  in(" + ids + ")", ypzw, zplc, zpjd, dqypjd);
                for (String s : ids.split(",")) {
                    StepMsgCommonInfo.sendMsg(s, Util.null2String(ypzw), Util.null2String(zplc), Util.null2String(zpjd), user);
                }
            }
            returnMap.put("msg", "操作成功");
        } else if (ApplicantOperateEnum.ARCHIVE.getOperateType().equals(operateType)) {
            // 归档人才库
            String gdyy = Util.null2String(params.get("gdyy"));
            String gdxxyy = Util.null2String(params.get("gdxxyy"));
            String ids = Util.null2String(params.get("ids"));
            if (StringUtils.isNotBlank(ids)) {
                String[] split = ids.split(",");
                String dateTime = DateUtil.getDateTime();
                for (String id : split) {
                    rs.executeUpdate("update uf_jcl_yppc set gdyy = ?,gdxxyy = ? where id = ? ", gdyy, gdxxyy, id);
                    // 建模推送建模
                    archiveTalentPool(id, false, "");
                    // 更新应聘状态为已归档
                    rs.executeUpdate("update uf_jcl_yppc set zt = ? where id = ? ", ApplicationStatusEnum.ARCHIVED.getValue(), id);

                    // 插入应聘过程
                    Map<String, Object> otherParam = new HashMap<>();
                    otherParam.put("gdyy", gdyy);
                    otherParam.put("gdxxyy", gdxxyy);

                    ApplicantRecordPo recordPo = ApplicantRecordPo.builder()
                            .billId(id)
                            .operateTime(dateTime)
                            .user(user)
                            .recordOperateType(RecordOperateEnum.ARCHIVE_TALENT_POOL)
                            .otherParam(otherParam)
                            .build();
                    recordPo.execute();
                }
            } else {
                throw new CustomizeRunTimeException("请至少选择一条数据");
            }
        } else if (ApplicantOperateEnum.REFERRAL.getOperateType().equals(operateType)) {
            // 转推其他职位
            String sourceId = Util.null2String(params.get("sourceId"));
            String ypzw = Util.null2String(params.get("ypzw"));

            rs.executeQuery("select * from uf_jcl_yppc where id = ?", sourceId);
            Map<String, Object> mainDataMap = RecruitRecordSet.getSingleRecordMap(rs);

            // 转推其他职位的时候，如果选择的职位存在候选中的
            // 提示：该职位已在应聘中，无需重复应聘
            String xm = Util.null2String(mainDataMap.get("xm"));
            String sjhm = Util.null2String(mainDataMap.get("sjhm"));
            if (StringUtils.isNotBlank(sjhm)) {
                rs.executeQuery("select id from uf_jcl_yppc where formmodeid is not null and xm = ? and sjhm = ? and ypzw = ? and zt = 1 ", xm, sjhm, ypzw);
            } else {
                rs.executeQuery("select id from uf_jcl_yppc where formmodeid is not null and xm = ? and (sjhm is null or sjhm = '') and ypzw = ? and zt = 1 ", xm, ypzw);
            }
            if (rs.next()) {
                throw new CustomizeRunTimeException("该职位已在应聘中，无需重复应聘");
            }

            // 构建新数据
            mainDataMap.put("ypzw", ypzw);

            String flowId = PositionCommonInfo.getRecruitFlowId(ypzw);
            Map<String, String> initialStage = ApplicantCommonInfo.getInitialStage(flowId);
            if (null != initialStage) {
                String zpjd = initialStage.get("zpjd");
                String dqypjd = initialStage.get("jdlx");
                if (StringUtils.isNotBlank(zpjd) && StringUtils.isNotBlank(dqypjd)) {
                    mainDataMap.put("zplc", flowId);
                    mainDataMap.put("zpjd", zpjd);
                    mainDataMap.put("dqypjd", dqypjd);
                }
            } else {
                throw new CustomizeRunTimeException("未获取到关联招聘流程的招聘阶段，请检查流程配置");
            }

            // 投递时间
            mainDataMap.put("tdsj", DateUtil.getDateTime());
            mainDataMap.put("zt", ApplicationStatusEnum.CANDIDATE.getValue());
            RecruitRecordSet.buildModeInsertFields(mainDataMap, user.getUID());
            String uuid = UUID.randomUUID().toString();
            mainDataMap.put("modeuuid", uuid);
            // 移除不需要插入的字段
            mainDataMap.remove("id");
            mainDataMap.remove("requestId");
            mainDataMap.remove("form_biz_id");

            // 插入数据
            RecruitRecordSet.insertData(mainDataMap, "uf_jcl_yppc");
            // 权限重构
            rs.executeQuery("select id,formmodeid from uf_jcl_yppc where modeuuid='" + uuid + "'");
            if (rs.next()) {
                //建模数据的id
                int targetId = Util.getIntValue(rs.getString("id"));
                int formModeId = Util.getIntValue(rs.getString("formmodeid"));
                ModeRightInfo modeRightInfo = new ModeRightInfo();
                modeRightInfo.setNewRight(true);
                //新建的时候添加共享
                modeRightInfo.editModeDataShare(user.getUID(), formModeId, targetId);

                // 阶段提醒
                StepMsgCommonInfo.sendMsg(String.valueOf(targetId), Util.null2String(ypzw), Util.null2String(flowId), Util.null2String(mainDataMap.get("zpjd")), user);

                // 复制明细表数据
                rs.executeUpdate("insert into uf_jcl_yppc_dt1 (mainid,xxmc,xl,zy,kssj,jssj) select ?,xxmc,xl,zy,kssj,jssj from uf_jcl_yppc_dt1 where mainid = ?", targetId, sourceId);
                rs.executeUpdate("insert into uf_jcl_yppc_dt2 (mainid,gsmc,kssj,jssj,gw,sqyxk,lzyy,gzzz) select ?,gsmc,kssj,jssj,gw,sqyxk,lzyy,gzzz from uf_jcl_yppc_dt2 where mainid = ?", targetId, sourceId);
                rs.executeUpdate("insert into uf_jcl_yppc_dt3 (mainid,xmmc,kssj,jssj,drjs,xmms) select ?,xmmc,kssj,jssj,drjs,xmms from uf_jcl_yppc_dt3 where mainid = ?", targetId, sourceId);
                rs.executeUpdate("insert into uf_jcl_yppc_dt4 (mainid,yylx,zwcd) select ?,yylx,zwcd from uf_jcl_yppc_dt4 where mainid = ?", targetId, sourceId);
            }


        }
        return returnMap;
    }


    @Override
    public Map<String, Object> checkRepeatResume(Map<String, Object> param) {
        String name = Util.null2String(param.get("xm"));
        String mobile = Util.null2String(param.get("sjhm"));
        String positionId = Util.null2String(param.get("ypzw"));
        String billId = Util.null2String(param.get("billid"));
        Map<String, Object> returnMap = new HashMap<>();
        // 判断是否黑名单
        boolean joinBlackList = CheckRepeatResume.joinBlackList(name, mobile);
        if (joinBlackList) {
            throw new CustomizeRunTimeException("保存失败，当前录入应聘者为黑名单人员");
        }
        List<Map<String, Object>> repeatPositionResumeList = CheckRepeatResume.getRepeatPositionResumeList(name, mobile, positionId, billId);
        if (CollectionUtils.isNotEmpty(repeatPositionResumeList)) {
            if (StringUtils.isBlank(positionId)) {
                throw new CustomizeRunTimeException("保存失败，该人员已有待分配状态数据");
            }
            throw new CustomizeRunTimeException("保存失败，该人员已有相同的应聘中的职位");
        }
        return returnMap;
    }

    @Override
    public Map<String, Object> getResumeCardInfo(Map<String, Object> param) {
        String idsString = Util.null2String(param.get("idsString"));
        List<ResumeCardInfo> resumeCardInfos = new ArrayList<>();
        if (StringUtils.isNotBlank(idsString)) {
            String[] ids = idsString.split(",");
            for (String id : ids) {
                RecordSet rs = new RecordSet();
                rs.executeQuery("select id, xm, jlzp, ypzw, xb, nl, zgxl, gzjy, tdsj, jlly, dqypjd from uf_jcl_yppc where id = ?", id);
                RecruitDataMap<Object> map = RecruitRecordSet.getSingleRecordMap(rs);
                ResumeCardInfo resumeCardInfo = new ResumeCardInfo();
                // 基本信息构建
                resumeCardInfo.setId(map.getInt("id"));
                resumeCardInfo.setLastName(map.getString("xm"));
                resumeCardInfo.setApplicantUrl(RecruitConstant.APPLICANT_URL + "?billId=" + id);
                resumeCardInfo.setCurrentStage(map.getString("dqypjd"));
                String jlzp = map.getString("jlzp");
                if (StringUtils.isNotBlank(jlzp)) {
                    try {
                        int imageFieldByDocId = ApplicantCommonInfo.getImageFieldByDocId(jlzp);
                        ImageFileManager manager = new ImageFileManager();
                        manager.getImageFileInfoById(imageFieldByDocId);
                        InputStream inputStream = manager.getInputStream();
                        // 转base64
                        String base64 = Base64.getEncoder().encodeToString(IOUtils.toByteArray(inputStream));
                        resumeCardInfo.setImage("data:image/png;base64," + base64);
                    } catch (Exception e) {
                        rs.writeLog("简历头像转换失败", e);
                    }
                } else {
                    resumeCardInfo.setImage("/images/recruit/applicant.png");
                }
                resumeCardInfo.setJobTitle(ApplicantCommonInfo.getApplicantPosition(map.getString("ypzw")));
                resumeCardInfo.setSex(map.getString("xb"));
                resumeCardInfo.setAge(map.getString("nl"));
                resumeCardInfo.setEducation(map.getString("zgxl"));
                resumeCardInfo.setWorkYear(ApplicantCommonInfo.getRecruitCommonBrowserValue(map.getString("gzjy")));
                resumeCardInfo.setSubmissionTime(map.getString("tdsj"));
                resumeCardInfo.setSubmissionFrom(ApplicantCommonInfo.getRecruitCommonBrowserValue(map.getString("jlly")));
                // 标签构建
                List<Tags> tags = new ArrayList<>();
                List<Map<String, Object>> modeTabs = ApplicantResumeServiceImpl.getModeTabs(id, rs);
                if (CollectionUtils.isNotEmpty(modeTabs)) {
                    for (Map<String, Object> modeTab : modeTabs) {
                        Tags tag = new Tags();
                        tag.setTitle(Util.null2String(modeTab.get("tabname")));
                        tag.setColor(Util.null2String(modeTab.get("color")));
                        tag.setBgColor(Util.null2String(modeTab.get("bgcolor")));
                        tag.setBdColor(Util.null2String(modeTab.get("bdcolor")));
                        tags.add(tag);
                    }
                }
                resumeCardInfo.setTags(tags);

                // 教育经历  默认取最新的一段，若无，则显示“暂无学习经历”
                List<EduInfo> eduInfoList = new ArrayList<>();
                rs.executeQuery("select * from uf_jcl_yppc_dt1 where mainid =? order by kssj desc", id);
                RecruitDataMap<Object> eduInfoMap = RecruitRecordSet.getSingleRecordMap(rs);
                if (!eduInfoMap.isEmpty()) {
                    EduInfo eduInfo = new EduInfo();
                    String kssj = eduInfoMap.getString("kssj");
                    String jssj = eduInfoMap.getString("jssj");
                    eduInfo.setStart(kssj);
                    eduInfo.setEnd(jssj);
                    eduInfo.setProfessional(eduInfoMap.getString("zy"));
                    eduInfo.setSchool(eduInfoMap.getString("xxmc"));
                    eduInfoList.add(eduInfo);
                }
                resumeCardInfo.setEduInfo(eduInfoList);

                // 工作经历 默认取最新的两段，时间倒序，若无，则显示“暂无工作经历”，增加工作时间计算（结束时间-开始时间，显示年月）
                List<WorkInfo> workInfoList = new ArrayList<>();
                rs.executeQuery("select * from uf_jcl_yppc_dt2 where mainid =? order by kssj desc", id);
                while (rs.next() && workInfoList.size() < 2) {
                    WorkInfo workInfo = new WorkInfo();
                    workInfo.setStart(rs.getString("kssj"));
                    workInfo.setEnd(rs.getString("jssj"));
                    workInfo.setCompany(rs.getString("gsmc"));
                    workInfo.setJob(rs.getString("gw"));
                    workInfoList.add(workInfo);
                }

                resumeCardInfo.setWorkInfo(workInfoList);

                // 招聘过程
                List<RecruitProcess> recruitProcessList = new ArrayList<>();
                // 若未发起反馈则不展示，若有且均为待反馈的，则显示待反馈，反馈人；若存在已反馈记录的，则显示，反馈结果，反馈人【取最新反馈的结果】；若存在多条则取最新的【创建时间】
                buildScreenProcess(id, rs, recruitProcessList);
                // 最近笔试：若未发起，则不显示，若有记录但是无分数和结果的，显示“暂无得分结果”；若有结果则显示“得分、结果”；若存在多条，则显示最新的数据；若存在多条则取最新的【笔试时间】
                buildWrittenProcess(id, rs, recruitProcessList);
                // 最近面试：若未发起，则不显示，若有记录但是是“待面试”，显示“面试时间、待面试、面试官”；若有结果则显示“面试时间、结果、面试官”；若存在多条，则显示最新的数据；若存在多条则取最新的【面试时间】
                buildInterviewProcess(id, rs, recruitProcessList);
                // 最近背调：若未发起，则不显示，若有记录但是无结果的，显示“暂无背调结果”；若有结果则显示“背调日期，结果”；若存在多条，则显示最新的数据；若存在多条则取最新的【背调时间】
                buildBackProcess(id, rs, recruitProcessList);
                // 最近薪酬谈判：若未发起，则不显示，若有记录但是无结果的，显示“暂无薪酬谈判结果”；若有结果则显示“谈判日期，结果”；若存在多条，则显示最新的数据；若存在多条则取最新的【谈判时间】
                buildSalaryProcess(id, rs, recruitProcessList);
                // offer状态：若未产生数据则不显示，若有数据了，则显示offer状态，若反馈时间有数值，则显示，没数值则不现实
                buildOfferProcess(id, rs, recruitProcessList);

                recruitProcessList = recruitProcessList.stream().sorted(Comparator.comparing(RecruitProcess::getCreateDateTime)).collect(Collectors.toList());
                resumeCardInfo.setRecruitProcess(recruitProcessList);


                resumeCardInfos.add(resumeCardInfo);
            }
        }
        Map<String, Object> returnMap = new HashMap<>();
        returnMap.put("resumeCardInfos", resumeCardInfos);
        return returnMap;
    }

    @Override
    public String getResumeListStatus(Map<String, Object> param) {
        int uid = user.getUID();
        RecordSet rs = new RecordSet();
        rs.executeQuery("select ypzlb from uf_jcl_recruit where userId = ?", uid);
        String listType = "1";
        if (rs.next()) {
            listType = rs.getString("ypzlb");
        }
        return listType;
    }

    @Override
    public Map<String, Object> updateResumeListStatus(Map<String, Object> param) {
        int uid = user.getUID();
        String listType = Util.null2String(param.get("listType"));
        RecordSet rs = new RecordSet();
        rs.executeQuery("select ypzlb from uf_jcl_recruit where userId = ?", uid);
        if (rs.next()) {
            rs.executeUpdate("update uf_jcl_recruit set ypzlb = ? where userId = ?", listType, uid);
        } else {
            rs.executeUpdate("insert into uf_jcl_recruit (ypzlb,userId) values (?,?)", listType, uid);
        }
        return null;
    }

    /**
     * 若未发起反馈则不展示，若有且均为待反馈的，则显示待反馈，反馈人；若存在已反馈记录的，则显示，反馈结果，反馈人【取最新反馈的结果】；若存在多条则取最新的【创建时间】
     *
     * @param id
     * @param rs
     * @param recruitProcessList
     */
    private void buildScreenProcess(String id, RecordSet rs, List<RecruitProcess> recruitProcessList) {
        rs.executeQuery("select zt,fkr,jg,modedatacreatedate,modedatacreatetime from uf_jcl_bmsxfk where ypz = ? order by modedatacreatedate desc,modedatacreatetime desc", id);
        if (rs.next()) {
            // 状态
            String zt = rs.getString("zt");
            // 反馈人
            String fkr = rs.getString("fkr");
            // 结果
            String jg = rs.getString("jg");
            String date = rs.getString("modedatacreatedate");
            String time = rs.getString("modedatacreatetime");

            ScreenProcess screenProcess = new ScreenProcess();
            screenProcess.setZt(zt);
            screenProcess.setFkr(fkr);
            screenProcess.setJg(jg);
            RecruitProcess process = new RecruitProcess();
            process.setTitle(ScreenProcess.TITLE);
            process.setIcon(ScreenProcess.ICON_NAME);
            process.setValue(screenProcess.toString());
            process.setCreateDateTime(DateUtil.parseToDateTime(date + " " + time));
            recruitProcessList.add(process);
        }
    }

    /**
     * 最近笔试：若未发起，则不显示，若有记录但是无分数和结果的，显示“暂无得分结果”；若有结果则显示“得分、结果”；若存在多条，则显示最新的数据；若存在多条则取最新的【笔试时间】
     *
     * @param id
     * @param rs
     * @param recruitProcessList
     */
    private void buildWrittenProcess(String id, RecordSet rs, List<RecruitProcess> recruitProcessList) {
        rs.executeQuery("select bsmc ,bscj ,bsjg ,modedatacreatedate ,modedatacreatetime from uf_jcl_bs where ypz = ? order by bssj desc", id);
        if (rs.next()) {
            // 笔试名称
            String bsmc = rs.getString("bsmc");
            // 笔试成绩
            String bscj = rs.getString("bscj");
            // 笔试结果
            String bsjg = rs.getString("bsjg");
            String date = rs.getString("modedatacreatedate");
            String time = rs.getString("modedatacreatetime");

            WrittenProcess writtenProcess = new WrittenProcess();
            writtenProcess.setBsmc(bsmc);
            writtenProcess.setBscj(bscj);
            writtenProcess.setBsjg(bsjg);

            RecruitProcess process = new RecruitProcess();
            process.setTitle(WrittenProcess.TITLE);
            process.setIcon(WrittenProcess.ICON_NAME);
            process.setValue(writtenProcess.toString());
            process.setCreateDateTime(DateUtil.parseToDateTime(date + " " + time));
            recruitProcessList.add(process);
        }
    }

    /**
     * 最近面试：若未发起，则不显示，若有记录但是是“待面试”，显示“面试时间、待面试、面试官”；若有结果则显示“面试时间、结果、面试官”；若存在多条，则显示最新的数据；若存在多条则取最新的【面试时间】
     *
     * @param id
     * @param rs
     * @param recruitProcessList
     */
    private void buildInterviewProcess(String id, RecordSet rs, List<RecruitProcess> recruitProcessList) {
        rs.executeQuery("select id,zt, msrq, msg, ptmsg, jg, modedatacreatedate, modedatacreatetime from uf_jcl_ms where ypz = ? order by msrq desc", id);
        if (rs.next()) {
            // 面试状态
            String zt = rs.getString("zt");
            // 面试日期
            String msrq = rs.getString("msrq");
            // 面试官
            String msg = rs.getString("msg");
            // 结果
            String jg = rs.getString("jg");
            String date = rs.getString("modedatacreatedate");
            String time = rs.getString("modedatacreatetime");

            InterviewProcess interviewProcess = new InterviewProcess();
            interviewProcess.setZt(zt);
            interviewProcess.setMsrq(msrq);

            String msId = rs.getString("id");

            // 查询面试评价
            rs.executeQuery("select msg,jg from uf_jcl_mspjfk where msid = ?", msId);
            while(rs.next()){
                interviewProcess.addInterviewDetail(rs.getString("msg"), rs.getString("jg"));
            }
            List<InterviewProcess.InterviewDetail> interviewDetails = interviewProcess.getInterviewDetails();
            if(CollectionUtils.isEmpty(interviewDetails)){
                if(StringUtils.isNotBlank(msg)){
                    String[] split = msg.split(",");
                    for (String s : split) {
                        interviewProcess.addInterviewDetail(s, jg);
                    }
                }
            }

            RecruitProcess process = new RecruitProcess();
            process.setTitle(InterviewProcess.TITLE);
            process.setIcon(InterviewProcess.ICON_NAME);
            process.setValue(interviewProcess.toString());
            process.setCreateDateTime(DateUtil.parseToDateTime(date + " " + time));
            recruitProcessList.add(process);
        }
    }

    /**
     * 最近背调：若未发起，则不显示，若有记录但是无结果的，显示“暂无背调结果”；若有结果则显示“背调日期，结果”；若存在多条，则显示最新的数据；若存在多条则取最新的【背调时间】
     *
     * @param id
     * @param rs
     * @param recruitProcessList
     */
    private void buildBackProcess(String id, RecordSet rs, List<RecruitProcess> recruitProcessList) {
        rs.executeQuery("select dcrq, dcjg, modedatacreatedate, modedatacreatetime from uf_jcl_bd where ypz = ? order by dcrq desc", id);
        if (rs.next()) {
            // 调查日期
            String dcrq = rs.getString("dcrq");
            // 调查结果
            String dcjg = rs.getString("dcjg");

            String date = rs.getString("modedatacreatedate");
            String time = rs.getString("modedatacreatetime");

            BackProcess backProcess = new BackProcess();
            backProcess.setDcjg(dcjg);
            backProcess.setDcrq(dcrq);

            RecruitProcess process = new RecruitProcess();
            process.setTitle(BackProcess.TITLE);
            process.setIcon(BackProcess.ICON_NAME);
            process.setValue(backProcess.toString());
            process.setCreateDateTime(DateUtil.parseToDateTime(date + " " + time));
            recruitProcessList.add(process);
        }
    }

    /**
     * 最近薪酬谈判：若未发起，则不显示，若有记录但是无结果的，显示“暂无薪酬谈判结果”；若有结果则显示“谈判日期，结果”；若存在多条，则显示最新的数据；若存在多条则取最新的【谈判时间】
     *
     * @param id
     * @param rs
     * @param recruitProcessList
     */
    private void buildSalaryProcess(String id, RecordSet rs, List<RecruitProcess> recruitProcessList) {
        rs.executeQuery("select tpsj, tpjg, modedatacreatedate, modedatacreatetime from uf_jcl_xctp where ypz = ? order by tpsj desc", id);
        if (rs.next()) {
            // 谈判时间
            String tpsj = rs.getString("tpsj");
            // 谈判结果
            String tpjg = rs.getString("tpjg");

            String date = rs.getString("modedatacreatedate");
            String time = rs.getString("modedatacreatetime");

            SalaryProcess salaryProcess = new SalaryProcess();
            salaryProcess.setTpjg(tpjg);
            salaryProcess.setTpsj(tpsj);

            RecruitProcess process = new RecruitProcess();
            process.setTitle(SalaryProcess.TITLE);
            process.setIcon(SalaryProcess.ICON_NAME);
            process.setValue(salaryProcess.toString());
            process.setCreateDateTime(DateUtil.parseToDateTime(date + " " + time));
            recruitProcessList.add(process);
        }
    }

    /**
     * offer状态：若未产生数据则不显示，若有数据了，则显示offer状态，若反馈时间有数值，则显示，没数值则不现实
     *
     * @param id
     * @param rs
     * @param recruitProcessList
     */
    private void buildOfferProcess(String id, RecordSet rs, List<RecruitProcess> recruitProcessList) {
        rs.executeQuery("select  zt, fksj, modedatacreatedate, modedatacreatetime from uf_jcl_offer where xm = ? order by modedatacreatedate desc,modedatacreatetime desc", id);
        if (rs.next()) {
            // offer状态
            String zt = rs.getString("zt");
            // 反馈时间
            String fksj = rs.getString("fksj");

            String date = rs.getString("modedatacreatedate");
            String time = rs.getString("modedatacreatetime");

            OfferProcess offerProcess = new OfferProcess();
            offerProcess.setFksj(fksj);
            offerProcess.setZt(zt);


            RecruitProcess process = new RecruitProcess();
            process.setTitle(OfferProcess.TITLE);
            process.setIcon(OfferProcess.ICON_NAME);
            process.setValue(offerProcess.toString());
            process.setCreateDateTime(DateUtil.parseToDateTime(date + " " + time));
            recruitProcessList.add(process);
        }
    }

    /**
     * 构建普通数据格式
     *
     * @param value
     * @return
     */
    private Map<String, Object> createApplicantBrowserMap(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        Map<String, Object> browserMap = new HashMap<>(1);
        browserMap.put("value", value);
        return browserMap;
    }

    /**
     * 构建应聘者浏览按钮值
     *
     * @param id
     * @param name
     * @return
     */
    private Map<String, Object> createApplicantBrowserMap(String id, String name) {
        Map<String, Object> browserMap = new HashMap<>(2);
        if (StringUtils.isBlank(id)) {
            return browserMap;
        }
        browserMap.put("value", id);
        List<Map<String, Object>> objList = new ArrayList<>();
        Map<String, Object> obj = new HashMap<>(2);
        obj.put("id", id);
        obj.put("name", name);
        objList.add(obj);
        browserMap.put("specialobj", objList);
        return browserMap;
    }

    /**
     * 构建应聘职位浏览按钮
     *
     * @param id
     * @return
     */
    private Map<String, Object> createAppliedPositionBrowserMap(String id) {
        Map<String, Object> browserMap = new HashMap<>(2);
        if (StringUtils.isBlank(id)) {
            return browserMap;
        }
        browserMap.put("value", id);
        RecordSet rs = new RecordSet();
        rs.executeQuery("select zpzwmc from uf_jcl_zp_zpzw where id = ?", id);
        if (rs.next()) {
            List<Map<String, Object>> objList = new ArrayList<>();
            Map<String, Object> obj = new HashMap<>(2);
            obj.put("id", id);
            obj.put("name", rs.getString("zpzwmc"));
            objList.add(obj);
            browserMap.put("specialobj", objList);
        }
        return browserMap;
    }

    /**
     * 构建人员浏览按钮值
     *
     * @param ids
     * @return
     */
    private Map<String, Object> createResourceBrowserMap(String ids) {
        Map<String, Object> browserMap = new HashMap<>(2);
        if (StringUtils.isBlank(ids)) {
            return browserMap;
        }
        browserMap.put("value", ids);
        List<Map<String, Object>> objList = new ArrayList<>();
        String[] split = ids.split(",");
        try {
            ResourceComInfo resourceComInfo = new ResourceComInfo();
            for (String s : split) {
                Map<String, Object> obj = new HashMap<>(2);
                obj.put("id", s);
                obj.put("name", resourceComInfo.getLastname(s));
                objList.add(obj);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        browserMap.put("specialobj", objList);
        return browserMap;

    }

    /**
     * 归档人才库
     *
     * @param applicantId   应聘者ID
     * @param joinBlacklist 是否加入黑名单
     * @param gdyy          归档原因
     */
    public void archiveTalentPool(String applicantId, boolean joinBlacklist, String gdyy) {
        RecordSet rs = new RecordSet();
        String name = "";
        String mobile = "";
        String talentPoolId = "";
        rs.executeQuery("select xm,sjhm from uf_jcl_yppc where id = ?", applicantId);
        if (rs.next()) {
            name = rs.getString("xm");
            mobile = rs.getString("sjhm");
        }

        rs.executeQuery("select id from uf_jcl_rck where xm = ? and sjhm = ?", name, mobile);
        if (rs.next()) {
            talentPoolId = rs.getString("id");
        }

        // 推送建模主表数据
        Map<String, Object> dataMap = new RecruitDataMap<>();
        String uuid = UUID.randomUUID().toString();
        dataMap.put("modeuuid", uuid);
        int formModeId = ApplicantCommonInfo.getModeIdByTableName("uf_jcl_rck");

        dataMap.put("formmodeid", formModeId);
        // 构建建模表基本数据
        RecruitRecordSet.buildModeInsertFields(dataMap, user.getUID());
        rs.executeQuery("select * from uf_jcl_yppc where id = ?", applicantId);
        if (rs.next()) {
            dataMap.put("sfz", RecruitModeUtil.parseBlankToNull(rs.getString("sfz")));
            dataMap.put("jlzp", RecruitModeUtil.parseBlankToNull(rs.getString("jlzp")));
            dataMap.put("zhypzw", RecruitModeUtil.parseBlankToNull(rs.getString("ypzw")));
            dataMap.put("ysjl", RecruitModeUtil.parseBlankToNull(rs.getString("ysjl")));
            dataMap.put("jlly", RecruitModeUtil.parseBlankToNull(rs.getString("jlly")));
            dataMap.put("xm", RecruitModeUtil.parseBlankToNull(rs.getString("xm")));
            dataMap.put("xb", RecruitModeUtil.parseBlankToNull(rs.getString("xb")));
            dataMap.put("sjhm", RecruitModeUtil.parseBlankToNull(rs.getString("sjhm")));
            dataMap.put("dzyx", RecruitModeUtil.parseBlankToNull(rs.getString("dzyx")));
            dataMap.put("csrq", RecruitModeUtil.parseBlankToNull(rs.getString("csrq")));
            dataMap.put("nl", RecruitModeUtil.parseBlankToNull(rs.getString("nl")));
            dataMap.put("zgxl", RecruitModeUtil.parseBlankToNull(rs.getString("zgxl")));
            dataMap.put("zgxw", RecruitModeUtil.parseBlankToNull(rs.getString("zgxw")));
            dataMap.put("byyx", RecruitModeUtil.parseBlankToNull(rs.getString("byyx")));
            dataMap.put("zy", RecruitModeUtil.parseBlankToNull(rs.getString("zy")));
            dataMap.put("hyzk", RecruitModeUtil.parseBlankToNull(rs.getString("hyzk")));
            dataMap.put("gzjy", RecruitModeUtil.parseBlankToNull(rs.getString("gzjy")));
            dataMap.put("zzzt", RecruitModeUtil.parseBlankToNull(rs.getString("zzzt")));
            dataMap.put("dqszd", RecruitModeUtil.parseBlankToNull(rs.getString("dqszd")));
            dataMap.put("zhtdsj", RecruitModeUtil.parseBlankToNull(rs.getString("tdsj")));
            dataMap.put("cjr", RecruitModeUtil.parseBlankToNull(rs.getString("cjr")));
            dataMap.put("zwpj", RecruitModeUtil.parseBlankToNull(rs.getString("zwpj")));
            dataMap.put("mz", RecruitModeUtil.parseBlankToNull(rs.getString("mz")));
            dataMap.put("jg", RecruitModeUtil.parseBlankToNull(rs.getString("jg")));
            dataMap.put("zzmm", RecruitModeUtil.parseBlankToNull(rs.getString("zzmm")));
            dataMap.put("sgcm", RecruitModeUtil.parseBlankToNull(rs.getString("sgcm")));
            dataMap.put("tzkg", RecruitModeUtil.parseBlankToNull(rs.getString("tzkg")));
            // 归档阶段
            dataMap.put("gdjd", RecruitModeUtil.parseBlankToNull(rs.getString("dqypjd")));
            dataMap.put("gdyy", RecruitModeUtil.parseBlankToNull(rs.getString("gdyy")));
            dataMap.put("gdxxyy", RecruitModeUtil.parseBlankToNull(rs.getString("gdxxyy")));
        }
        // 历史投递次数
        rs.executeQuery("select count(id) as num from uf_jcl_yppc where xm=? and sjhm =?", rs.getString("xm"), rs.getString("sjhm"));
        if (rs.next()) {
            dataMap.put("lstdcs", rs.getInt("num"));
        }
        // 是否加入黑名单
        if (joinBlacklist) {
            dataMap.put("sfjrhmd", 0);
            // 归档原因黑名单
            dataMap.put("gdyy", 16);
        } else {
            dataMap.put("sfjrhmd", 1);
        }

        if (StringUtils.isNotBlank(gdyy)) {
            dataMap.put("gdyy", gdyy);
            dataMap.put("gdxxyy", "");
        }

        RecruitRecordSet.insertData(dataMap, "uf_jcl_rck");
        refreshRight(uuid, formModeId, applicantId);


        // 删除人才库原来的数据
        rs.executeUpdate("delete from uf_jcl_rck where id = ? ", talentPoolId);
        rs.executeUpdate("delete from uf_jcl_rck_dt1 where mainid = ? ", talentPoolId);
        rs.executeUpdate("delete from uf_jcl_rck_dt2 where mainid = ? ", talentPoolId);
        rs.executeUpdate("delete from uf_jcl_rck_dt3 where mainid = ? ", talentPoolId);
        rs.executeUpdate("delete from uf_jcl_rck_dt4 where mainid = ? ", talentPoolId);
    }


    /**
     * 权限重构
     *
     * @param uuid        UUID
     * @param formModeId  建模ID
     * @param applicantId 应聘者ID
     */
    private void refreshRight(String uuid, int formModeId, String applicantId) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select id from uf_jcl_rck where modeuuid='" + uuid + "'");
        if (rs.next()) {
            //建模数据的id
            int bid = Util.getIntValue(rs.getString("id"));
            ModeRightInfo modeRightInfo = new ModeRightInfo();
            modeRightInfo.setNewRight(true);
            //新建的时候添加共享
            modeRightInfo.editModeDataShare(user.getUID(), formModeId, bid);

            // 插入明细表数据
            rs.executeQuery("select * from uf_jcl_yppc_dt1 where mainid = ? ", applicantId);
            List<List<Object>> insertList = new ArrayList<>();
            while (rs.next()) {
                List<Object> paramList = new ArrayList<>();
                // mainid
                paramList.add(bid);
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("xxmc")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("xl")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("zy")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("kssj")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("jssj")));
                insertList.add(paramList);
            }
            for (List<Object> list : insertList) {
                rs.executeUpdate("insert into uf_jcl_rck_dt1 (mainid, xxmc, xl, zy, kssj, jssj) values (?, ?, ?, ?, ?, ?)", list);
            }

            rs.executeQuery("select * from uf_jcl_yppc_dt2 where mainid = ? ", applicantId);
            insertList = new ArrayList<>();
            while (rs.next()) {
                List<Object> paramList = new ArrayList<>();
                // mainid
                paramList.add(bid);
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("gsmc")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("kssj")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("jssj")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("gw")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("gzzz")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("sqyxk")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("lzyy")));
                insertList.add(paramList);
            }
            for (List<Object> list : insertList) {
                rs.executeUpdate("insert into uf_jcl_rck_dt2 (mainid, gsmc, kssj, jssj, gw, gzzz, sqyxk, lzyy) values (?, ?, ?, ?, ?, ?, ?, ?)", list);
            }

            rs.executeQuery("select * from uf_jcl_yppc_dt3 where mainid = ? ", applicantId);
            insertList = new ArrayList<>();
            while (rs.next()) {
                List<Object> paramList = new ArrayList<>();
                // mainid
                paramList.add(bid);
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("xmmc")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("kssj")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("jssj")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("drjs")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("xmms")));
                insertList.add(paramList);
            }
            for (List<Object> list : insertList) {
                rs.executeUpdate("insert into uf_jcl_rck_dt3 (mainid, xmmc, kssj, jssj, drjs, xmms) values (?, ?, ?, ?, ?, ?)", list);
            }

            rs.executeQuery("select * from uf_jcl_yppc_dt4 where mainid = ? ", applicantId);
            insertList = new ArrayList<>();
            while (rs.next()) {
                List<Object> paramList = new ArrayList<>();
                // mainid
                paramList.add(bid);
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("yylx")));
                paramList.add(RecruitModeUtil.parseBlankToNull(rs.getString("zwcd")));
                insertList.add(paramList);
            }
            for (List<Object> list : insertList) {
                rs.executeUpdate("insert into uf_jcl_rck_dt4 (mainid, yylx, zwcd) values (?, ?, ?)", list);
            }

            // 同步设置的标签
            List<Map<String, Object>> modeTabList = getModeTabs(applicantId, rs);
            String dateTime = DateUtil.getFullDate();
            String[] dateSplit = dateTime.split(" ");
            String createdate = dateSplit[0];
            String createtime = dateSplit[1];
            Set<String> tabIdSet = new HashSet<>();
            for (Map<String, Object> modeTab : modeTabList) {
                String tabName = Util.null2String(modeTab.get("tabname"));
                // 查询人才库是否有此标签
                rs.executeQuery("select id from modeTabs_" + formModeId + " where tabname = ?", tabName);
                String tabid = null;
                if (rs.next()) {
                    tabid = rs.getString("id");
                } else {
                    // 不存在，则插入数据
                    RecruitRecordSet.insertData(modeTab, "modeTabs_" + formModeId);
                    rs.executeQuery("select id from modeTabs_" + formModeId + " where tabname = ?", tabName);
                    if (rs.next()) {
                        tabid = rs.getString("id");
                    }
                }

                // 插入标签数据
                if (StringUtils.isNotBlank(tabid)) {
                    Map<String, Object> tabsLogMap = new RecruitDataMap<>();
                    tabsLogMap.put("tabid", tabid);
                    tabsLogMap.put("operate", 0);
                    tabsLogMap.put("modeid", formModeId);
                    tabsLogMap.put("billid", bid);
                    tabsLogMap.put("creator", user.getUID());
                    tabsLogMap.put("createdate", createdate);
                    tabsLogMap.put("createtime", createtime);
                    RecruitRecordSet.insertData(tabsLogMap, "modetabslog_" + formModeId);
                    tabIdSet.add(tabid);
                }

            }
            // 更新标签信息
            rs.executeUpdate("update uf_jcl_rck set modelableid=? where id = ? ", StringUtils.join(tabIdSet, ","), bid);
        }
    }

    /**
     * 获取标签信息
     *
     * @param applicantId
     * @return
     */
    private static List<Map<String, Object>> getModeTabs(String applicantId, RecordSet rs) {
        int applicantModeId = ApplicantCommonInfo.getModeIdByTableName("uf_jcl_yppc");
        rs.executeQuery(" select modelableid from uf_jcl_yppc where id = ?", applicantId);
        String modelableid = "";
        if (rs.next()) {
            modelableid = rs.getString("modelableid");
        }
        if (StringUtils.isNotBlank(modelableid)) {
            rs.executeQuery("select a.tabname , a.color , a.bgcolor , a.bdcolor , a.type , a.creator , a.orderid from modeTabs_" + applicantModeId + " a where a.id in (" + modelableid + ")");
            return RecruitRecordSet.getRecordMapList(rs);
        }
        return new ArrayList<>();
    }


}
