package nckd.jxccl.hr.gzbb;

import kd.bos.algo.DataSet;
import kd.bos.algo.Row;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.FormOperate;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.login.utils.DateUtils;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import org.apache.commons.lang.StringUtils;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;

/**
 * 央国企人事云》国资报表ext》单据》数据填报
 * 数据填报初始化各级单位职工收入情况统计表
 * nckd_sjtbrw
 * duanyuqi
 * */
public class SjtbInitZgsrFormPlugin extends AbstractFormPlugin {

    private static final Log logger = LogFactory.getLog(SjtbInitZgsrFormPlugin.class);

    @Override
    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
        super.beforeDoOperation(args);
    }

    @Override
    public void afterDoOperation(AfterDoOperationEventArgs ags) {
        FormOperate formOperate = (FormOperate) ags.getSource();
        if ("nckd_getzgsr".equals(formOperate.getOperateKey())) { // 拉取各级单位职工收入统计表数据
            // 入职方式
            Map<String, DynamicObject> rzfsMap = findRzfsMap();
            // 证件类型
            Map<String, DynamicObject> zjlxMap = findZjlxMap();
            //国籍地区
            Map<String, DynamicObject> gjdqMap = findGjdqMap();
            // 岗位性质
            Map<String, DynamicObject> gwxzMap = findGwxzMap();
            // 岗位层级
            Map<String, DynamicObject> gwcjMap = findGwcjMap();
            // 最高学历
            Map<String, DynamicObject> zgxlMap = findZgxlMap();
            // 政治面貌
            Map<String, DynamicObject> zzmmMap = findZzmmMap();
            // 技术职称
            Map<String, DynamicObject> jszcMap = findJszcMap();
            // 职业技能等级
            Map<String, DynamicObject> zyjndjMap = findZyjndjMap();
            // 是否在岗
            Map<String, DynamicObject> sfzgMap = findSfzgMap();
            // 是否实行任期制和契约化管理或新型经营责任制集合
            Map<String, DynamicObject> xxjyzzMap = findRqqyxxjyMap();
            // 是否竞聘上岗或因考核调整
            Map<String, DynamicObject> jpsgkhtzMap = findJpsgkhtzMap();
            // 薪酬项目计算
            DynamicObject xcxmjspz = findXcxmjspz();
            // 获取数据填报配置
            DynamicObject sjtbzfpsz = findSjtbpz();
            // 获取所有的薪酬项目
            List<String> xcxmList = findAllXcProject();

            // 填报数据年月
            Date nckd_tbsjny = this.getModel().getDataEntity().getDate("nckd_tbsjny");
            // 当前日期
            Date nowDate = new Date();
            // 填报组织id
            Object tbzzId = this.getModel().getDataEntity().get("org.id");
            // 核算任务id
            List<Long> hsTaskId = findHeSuanRenWuIds(tbzzId, nckd_tbsjny);

            if (hsTaskId.size() > 0) {
                // 获取薪酬项目明细
                Map<Long, Map<String, Object>> xcxmMap =  findUserXcProject(hsTaskId);
                String hsTaskIds = StringUtils.join(hsTaskId, ",");
                // 查询人员数据
                String ksql_rysj = " select a.fid as mingdanid,a.fempnumber as gonghao,c.fpersonid as renyuanid,c.femployeeid as qiyerenyuanid," +
                        " a.fname as xingming,c.fstartdate as ruzhiriqi,s.fstartdate as ruzhiriqis,c.fisprimary as zhurenzhi," +
                        " e.fnumber as ruzhifangshibm,e.fname as ruzhifangshimc,c.fenddate as lizhiriqi,s.fenddate as lizhiriqis," +
                        " g.fnumber as xingbiebm,g.fname as xingbiemc,i.fnumber as zhengjianhm,j.fname as zhegnjianleixmc," +
                        " j.fnumber as zhengjianleixbm,f.fage as nianling,h.fnumber as guojibm,h.fname as guojimc," +
                        " a.forgid as gongsiid,k1.fnumber as gongsibm,k1.fname as gongsimc," +
                        " c.fadminorgid as bumenid,k2.fname as bumenmc,k2.fstructlongnumber as bumencbm," +
                        " l.fid as gangweiid,l.fnumber as gangweibm," +
                        " l.fname as gangweimc,l.fk_nckd_dgwcj as gangweicjid,m.fnumber as gangweilbbm,m.fname as gangweilbmc," +
                        " n.fnumber as zhijibm,n.fname as zhijimc,p.fnumber as xuelibm,p.fname as xuelimc,o.fmajor as zhuanye," +
                        " q.fname as zhengzhimianmaomc,q.fnumber as zhengzhimianmaobm,t.fnumber as yonggonggxbm,t.fname as yonggonggxmc," +
                        " t1.fnumber as yonggongjdbm,t1.fname as yonggongjdmc,d.fk_nckd_dgjjkjrclx as guojiajircid,d.fk_nckd_dsffbqyry as feibenqyry," +
                        " u1.fid as jinengid,u1.fk_nckd_zhichengname as jinengmc,u1.fk_nckd_zhichenglevel as jinengdj,u1.fprolevelid as jinengjbid," +
                        " u2.fid as zhiyeid,u2.fk_nckd_zhichengname as zhiyeidmc,u2.fk_nckd_zhichenglevel as zhiyeidj,u2.fprolevelid as zhiyejbid," +
                        " u3.fid as zhichengid,u3.fk_nckd_zhichengname as zhichengmc,u3.fk_nckd_zhichenglevel as zhichengdj,u3.fprolevelid as zhichengjbid," +
                        " i1.fstartdate as ruzhiriqifirst " +
                        " from t_hsas_calperson a" +
                        " left join t_hsas_calperson_s a1 on a.fid = a1.fid " +
                        " left join t_hsas_calpayrolltask b on a.fcaltaskid = b.fid" +
                        " left join t_hsas_empposorgrelhr c on a.fempposorgrelhrvid = c.fid" +
                        " left join t_hrpi_perregion d on c.fpersonid = d.fpersonid and d.fiscurrentversion = 1 and d.fdatastatus = 1" +
                        " left join t_hbss_recrutyp e on d.fk_nckd_zhaopinlaiyuannew = e.fid" +
                        " left join t_hrpi_pernontsprop f on a.fpernontspropvid = f.fid" +
                        " left join t_hbss_sex g on f.fgenderid = g.fid" +
                        " left join t_hbss_nationality h on f.fnationalityid = h.fid" +
                        " left join t_hrpi_percre i on i.fpersonid = c.fpersonid and i.fismajor = 1 and i.fiscurrentversion = 1 and i.fdatastatus = 1" +
                        " left join t_hrpi_empentrel i1 on i1.fpersonid = c.fpersonid and i1.fiscurrentversion = 1 and i1.fdatastatus = 1 and i1.fislatestrecord = 1 " +
                        " left join t_hbss_credentialstype j on i.fcredentialstypeid = j.fid" +
                        " left join t_haos_adminorg k1 on k1.fid = a.forgid" +
                        " left join t_haos_adminorg k2 on k2.fid = c.fadminorgid" +
                        " left join t_hbpm_position l on l.fid = c.fpositionid" +
                        " left join t_hbpm_positiontype m on m.fid = l.ftypeid" +
                        " left join tk_nckd_hbss_zhiji n on n.fid = c.fk_nckd_zhijijx" +
                        " left join t_hsas_pereduexp o on o.fpersonid = c.fpersonid and o.fiscurrentversion = 1 and o.fdatastatus = 1 and o.fishighestdegree = 1" +
                        " left join t_hbss_diploma p on o.feducationid = p.fid" +
                        " left join t_hbss_politicalstatus q on q.fid = d.fpoliticalstatusid" +
                        " left join t_hsas_empentrel s on s.fid = a.fempentrelvid" +
                        " left join t_hbss_laborrelstatus t on t.fid = s.flaborrelstatusid" +
                        " left join t_hbss_labrelstatusprd t1 on s.flaborreltypeid  = t1.fid " +
                        " left join t_hrpi_perprotitle u1 on c.fpersonid  = u1.fpersonid and u1.fiscurrentversion = 1 and u1.fdatastatus = 1 and u1.fk_nckd_iszuigao = 1 and u1.fk_nckd_type = 'jineng' " +
                        " left join t_hrpi_perprotitle u2 on c.fpersonid  = u2.fpersonid and u2.fiscurrentversion = 1 and u2.fdatastatus = 1 and u2.fk_nckd_iszuigao = 1 and u2.fk_nckd_type = 'zhiye' " +
                        " left join t_hrpi_perprotitle u3 on c.fpersonid  = u3.fpersonid and u3.fiscurrentversion = 1 and u3.fdatastatus = 1 and u3.fk_nckd_iszuigao = 1 and u3.fk_nckd_type = 'zhicheng'" +
                        "  " +
                        " where b.fid in ("+hsTaskIds+") and a1.fcalstatus in (4,10) " +
                        //" and a.fempnumber in ('001630') " +
                        "  ";
                logger.info("查询人员数据SQL：{}", ksql_rysj);
                DataSet dataSet_rysj = DB.queryDataSet(this.getClass().getName(), DBRoute.of("hr"), ksql_rysj);
                Iterator<Row> iterator_rysj = dataSet_rysj.iterator();
                List<ZgsrVO> zgsrVOList = new ArrayList();
                List<Long> gongsiidList = new ArrayList();
                Set<Long> personIdUserSet = new HashSet();
                while (iterator_rysj.hasNext()) {
                    Row row = iterator_rysj.next();
                    ZgsrVO zgsrVO = new ZgsrVO();
                    zgsrVO.setMingdanid(row.getLong("mingdanid"));
                    zgsrVO.setGonghao(row.getString("gonghao"));
                    zgsrVO.setRenyuanid(row.getLong("renyuanid"));
                    zgsrVO.setQiyerenyuanid(row.getLong("qiyerenyuanid"));
                    zgsrVO.setXingming(row.getString("xingming"));
                    zgsrVO.setRuzhiriqi(row.getDate("ruzhiriqi"));
                    zgsrVO.setRuzhiriqis(row.getDate("ruzhiriqis"));
                    zgsrVO.setRuzhiriqifirst(row.getDate("ruzhiriqifirst"));
                    zgsrVO.setRuzhifangshibm(row.getString("ruzhifangshibm"));
                    zgsrVO.setRuzhifangshimc(row.getString("ruzhifangshimc"));
                    zgsrVO.setLizhiriqi(row.getDate("lizhiriqi"));
                    zgsrVO.setLizhiriqis(row.getDate("lizhiriqis"));
                    zgsrVO.setXingbiebm(row.getString("xingbiebm"));
                    zgsrVO.setXingbiemc(row.getString("xingbiemc"));
                    zgsrVO.setZhengjianhm(row.getString("zhengjianhm"));
                    zgsrVO.setZhegnjianleixmc(row.getString("zhegnjianleixmc"));
                    zgsrVO.setZhengjianleixbm(row.getString("zhengjianleixbm"));
                    zgsrVO.setNianling(row.getString("nianling"));
                    zgsrVO.setGuojibm(row.getString("guojibm"));
                    zgsrVO.setGuojimc(row.getString("guojimc"));
                    zgsrVO.setBumenid(row.getLong("bumenid"));
                    zgsrVO.setBumenmc(row.getString("bumenmc"));
                    zgsrVO.setGongsiid(row.getLong("gongsiid"));
                    zgsrVO.setGongsimc(row.getString("gongsimc"));
                    zgsrVO.setGangweiid(row.getLong("gangweiid"));
                    zgsrVO.setGangweimc(row.getString("gangweimc"));
                    zgsrVO.setGangweibm(row.getString("gangweibm"));
                    zgsrVO.setGangweilbbm(row.getString("gangweilbbm"));
                    zgsrVO.setGangweicjid(row.getLong("gangweicjid"));
                    zgsrVO.setZhijibm(row.getString("zhijibm"));
                    zgsrVO.setZhijimc(row.getString("zhijimc"));
                    zgsrVO.setXuelibm(row.getString("xuelibm"));
                    zgsrVO.setXuelimc(row.getString("xuelimc"));
                    zgsrVO.setZhuanye(row.getString("zhuanye"));
                    zgsrVO.setZhengzhimianmaomc(row.getString("zhengzhimianmaomc"));
                    zgsrVO.setZhengzhimianmaobm(row.getString("zhengzhimianmaobm"));
                    zgsrVO.setYonggonggxbm(row.getString("yonggonggxbm"));
                    zgsrVO.setYonggonggxmc(row.getString("yonggonggxmc"));
                    zgsrVO.setYonggongjdbm(row.getString("yonggongjdbm"));
                    zgsrVO.setYonggongjdmc(row.getString("yonggongjdmc"));
                    zgsrVO.setFeibenqyry(row.getString("feibenqyry"));
                    zgsrVO.setGuojiajircid(row.getLong("guojiajircid"));
                    zgsrVO.setGongsibm(row.getString("gongsibm"));
                    zgsrVO.setBumencbm(row.getString("bumencbm"));

                    zgsrVO.setJinengid(row.getLong("jinengid"));
                    zgsrVO.setJinengmc(row.getString("jinengmc"));
                    zgsrVO.setJinengdj(row.getString("jinengdj"));
                    zgsrVO.setJinengjbid(row.getLong("jinengjbid"));

                    zgsrVO.setZhiyeid(row.getLong("zhiyeid"));
                    zgsrVO.setZhiyeidmc(row.getString("zhiyeidmc"));
                    zgsrVO.setZhiyeidj(row.getString("zhiyeidj"));
                    zgsrVO.setZhiyejbid(row.getLong("zhiyejbid"));

                    zgsrVO.setZhichengid(row.getLong("zhichengid"));
                    zgsrVO.setZhichengmc(row.getString("zhichengmc"));
                    zgsrVO.setZhichengdj(row.getString("zhichengdj"));
                    zgsrVO.setZhichengjbid(row.getLong("zhichengjbid"));
                    zgsrVO.setZhurenzhi(row.getString("zhurenzhi"));

                    gongsiidList.add(zgsrVO.getGongsiid());
                    zgsrVOList.add(zgsrVO);
                    personIdUserSet.add(zgsrVO.getRenyuanid());
                }
                if (zgsrVOList.size() > 0) {
                    // 获取人员薪酬数据
                    Map<Long, ZgsrDetailsAmtVO> userJbxcData = getUserJbxcData(xcxmMap, zgsrVOList, xcxmjspz, xcxmList);
                    // 获取组织人数据
                    Map<Long, Long> hrpiDepempMap = findHrpiDepempMap(zgsrVOList);
                    // 获取人员证书
                    Map<Long, List<DynamicObject>> uerZhenShuMap = findUserZhenShuMap(zgsrVOList);
                    // 获取人员任职经历变化数据
                    Map<Long, List<DynamicObject>> userRenZhiJingLiBianHuaMap = findUserRenZhiJingLiBianHuaMap(zgsrVOList, nckd_tbsjny);
                    // 获取人员任职经历数据
                    Map<Long, List<DynamicObject>> userRenZhiJingLiMap = findUserRenZhiJingLiMap(zgsrVOList, nckd_tbsjny);
                    // 获取人员项目经历数据
                    Map<Long, List<DynamicObject>> userXiangMuJingLiMap = findUserXiangMuJingLiMap(zgsrVOList);
                    // 获取人员职称级别信息
                    Map<Long, DynamicObject> userZhiChenMap = findUserZhiChenMap(zgsrVOList);

                    // 根据公司id获取业务单元数据
                    Long[] gongsidStr = (Long[]) gongsiidList.toArray(new Long[gongsiidList.size()]);
                    List<QFilter> qfilterYwdy = new ArrayList<QFilter>();
                    qfilterYwdy.add(new QFilter("id", "in", gongsidStr));
                    QFilter[] filtersYwdy = (QFilter[]) qfilterYwdy.toArray(new QFilter[qfilterYwdy.size()]);
                    String selectYwdyFields = "id,number,name,uniformsocialcreditcode,ffirmname,ftaxregnum";
                    DynamicObjectCollection ywdyObjectCollection = QueryServiceHelper.query("bos_org", selectYwdyFields, filtersYwdy);
                    // 将所有的业务单元放到map中
                    Map<Object, DynamicObject> ywdyObjMap = new LinkedHashMap<Object, DynamicObject>();
                    for (int i = 0; i < ywdyObjectCollection.size(); i++) {
                        DynamicObject dynamicObject = ywdyObjectCollection.get(i);
                        ywdyObjMap.put(dynamicObject.get("id"), dynamicObject);
                    }
                    // 处理单据体
                    IDataModel dataModel = this.getModel();
                    int createNewRow = personIdUserSet.size();
                    int newRow = this.getModel().getEntryEntity("nckd_dwzgsrentry").size();
                    dataModel.batchCreateNewEntryRow("nckd_dwzgsrentry", createNewRow);
                    Set<Long> personIdSet = new HashSet<Long>();
                    for (ZgsrVO zgsrVO: zgsrVOList) {
                        // 过滤掉重复的薪酬记录，薪酬获取已合并
                        if(personIdSet.contains(zgsrVO.getRenyuanid())) {
                            continue;
                        } else {
                            personIdSet.add(zgsrVO.getRenyuanid());
                        }
                        Object gongsiid = zgsrVO.getGongsiid();
                        DynamicObject ywdyObject = ywdyObjMap.get(gongsiid);
                        Object uniformsocialcreditcode = ywdyObject.get("uniformsocialcreditcode");// 统一社会信用代码
                        dataModel.setValue("nckd_dtjny", nckd_tbsjny, newRow);// 统计年月
                        if (!isNullEmpty(uniformsocialcreditcode)) {
                            dataModel.setValue("nckd_dzqyxxdm", uniformsocialcreditcode, newRow);// 子企业统一社会信用代码
                        }
                        dataModel.setValue("nckd_dzqydwdata", gongsiid, newRow);// 子企业单位名称
                        if (hrpiDepempMap.get(zgsrVO.getRenyuanid()) != null) {
                            dataModel.setValue("nckd_dxmdata", hrpiDepempMap.get(zgsrVO.getRenyuanid()), newRow);// 姓名--更新未工号
                        }
                        //dataModel.setValue("nckd_dxmdatasn", zgsrVO.getGonghao(), newRow);// 工号--更新未姓名
                        dataModel.setValue("nckd_dxmdatasn", zgsrVO.getXingming(), newRow);
                        boolean isMoreRzjlbh = isMoreRzjlbhDifferent(nckd_tbsjny, zgsrVO, userRenZhiJingLiMap);// 是否有主任职经历变化
                        if (isMoreRzjlbh) {
                            dataModel.setValue("nckd_drzrq", zgsrVO.getRuzhiriqi(), newRow);// 入职日期
                        } else {
                            dataModel.setValue("nckd_drzrq", zgsrVO.getRuzhiriqifirst(), newRow);// 入职日期
                        }
                        boolean isMoreRzjlbhCompany = isMoreRzjlbhDifferentCompany(nckd_tbsjny, zgsrVO, userRenZhiJingLiMap);// 是否有多公司主任职经历
                        // 2024年1月前入职选择空白项
                        Integer rzriqYear = 999999;
                        if (zgsrVO.getRuzhiriqi() != null) {
                            rzriqYear = Integer.valueOf(DateUtils.formatDate(zgsrVO.getRuzhiriqi(), "yyyyMM"));
                        }
                        if (rzriqYear.intValue() < 202401) {
                            DynamicObject rzfsObj = rzfsMap.get("50");
                            dataModel.setValue("nckd_drzfs", rzfsObj.get("id"), newRow);// 入职方式
                        } else {
                            if (isMoreRzjlbhCompany) {
                                DynamicObject rzfsObj = rzfsMap.get("40");//集团内部调动
                                dataModel.setValue("nckd_drzfs", rzfsObj.get("id"), newRow);
                            } else {
                                String ruzhifangshibm = zgsrVO.getRuzhifangshibm();
                                if ("1010_S".equals(ruzhifangshibm) || "1020_S".equals(ruzhifangshibm)) {// 校园招聘或社会招聘
                                    DynamicObject rzfsObj = rzfsMap.get("10");// 公开招聘
                                    dataModel.setValue("nckd_drzfs", rzfsObj.get("id"), newRow);
                                } else if ("1050_S".equals(ruzhifangshibm) || "1060_S".equals(ruzhifangshibm)) {// 组织安置或退役大学生士兵
                                    DynamicObject rzfsObj = rzfsMap.get("20");// 政策性安置
                                    dataModel.setValue("nckd_drzfs", rzfsObj.get("id"), newRow);
                                } else if ("1040_S".equals(ruzhifangshibm)) {// 组织任命
                                    DynamicObject rzfsObj = rzfsMap.get("30");//组织委派
                                    dataModel.setValue("nckd_drzfs", rzfsObj.get("id"), newRow);
                                } else if ("1030_S".equals(ruzhifangshibm)) {// 内部招聘
                                    DynamicObject rzfsObj = rzfsMap.get("40");//集团内部调动
                                    dataModel.setValue("nckd_drzfs", rzfsObj.get("id"), newRow);
                                } else {
                                    DynamicObject rzfsObj = rzfsMap.get("50");
                                    dataModel.setValue("nckd_drzfs", rzfsObj.get("id"), newRow);// 其他
                                }
                            }
                        }

                        // 离职日期
                        Date lizhiRiQiDate = null;
                        if (isMoreRzjlbhCompany) { // 跨公司调动了
                            if ("1".equals(zgsrVO.getZhurenzhi())) {
                                lizhiRiQiDate = getLiZhiRiQi(nckd_tbsjny, zgsrVO.getLizhiriqi());
                            } else {
                                lizhiRiQiDate = getLiZhiRiQi(nckd_tbsjny, zgsrVO.getLizhiriqis());
                            }
                        } else {
                            lizhiRiQiDate = getLiZhiRiQi(nckd_tbsjny, zgsrVO.getLizhiriqis());
                        }
                        if (lizhiRiQiDate != null) {
                            dataModel.setValue("nckd_dlzsj", lizhiRiQiDate, newRow);// 离职时间
                        }


                        if ("1020_S".equals(zgsrVO.getXingbiebm())) {
                            dataModel.setValue("nckd_dxb", "0", newRow);// 性别女
                        } else if ("1010_S".equals(zgsrVO.getXingbiebm())){
                            dataModel.setValue("nckd_dxb", "1", newRow);// 性别男
                        }
                        if ("1010_S".equals(zgsrVO.getZhengjianleixbm())) {// 中国居民身份证
                            DynamicObject zjlxObj = zjlxMap.get("1");// 身份证
                            dataModel.setValue("nckd_dzjlx", zjlxObj.get("id"), newRow);
                        } else if ("1030_S".equals(zgsrVO.getZhengjianleixbm()) || "1060_S".equals(zgsrVO.getZhengjianleixbm())) {// 港澳居民居住证
                            DynamicObject zjlxObj = zjlxMap.get("2");// 2-港澳居民来往内地通行证（回乡证）
                            dataModel.setValue("nckd_dzjlx", zjlxObj.get("id"), newRow);
                        } else if ("1040_S".equals(zgsrVO.getZhengjianleixbm()) || "1070_S".equals(zgsrVO.getZhengjianleixbm())) {// 台湾居民居住证
                            DynamicObject zjlxObj = zjlxMap.get("3");// 3-台湾居民来往大陆通行证（台胞证）
                            dataModel.setValue("nckd_dzjlx", zjlxObj.get("id"), newRow);
                        } else if ("1020_S".equals(zgsrVO.getZhengjianleixbm())) {// 护照
                            DynamicObject zjlxObj = zjlxMap.get("4");// 4-护照
                            dataModel.setValue("nckd_dzjlx", zjlxObj.get("id"), newRow);
                        } else  {
                            DynamicObject zjlxObj = zjlxMap.get("5");// 其他
                            dataModel.setValue("nckd_dzjlx", zjlxObj.get("id"), newRow);
                        }
                        dataModel.setValue("nckd_dzjhm", zgsrVO.getZhengjianhm(), newRow);// 证件号码
                        dataModel.setValue("nckd_dnl", Integer.valueOf(zgsrVO.getNianling()), newRow);// 年龄
                        if (!isNullEmpty(zgsrVO.getGuojimc())) {
                            Long guojiaId = getGongJiaId(gjdqMap, zgsrVO.getGuojimc());
                            dataModel.setValue("nckd_dgjdq", guojiaId, newRow);// 国家地区
                        }
                        dataModel.setValue("nckd_dbmbadata", zgsrVO.getBumenid(), newRow);// 部门
                        dataModel.setValue("nckd_dgw", zgsrVO.getGangweiid(), newRow);// 岗位
                        // 处理岗位性质逻辑
                        boolean isJiNengRc = false;// 技能人才
                        String gangWeiXingZhiNumber = "";// 岗位性质编号
                        if ("1010_S".equals(zgsrVO.getZhijibm()) || "1020_S".equals(zgsrVO.getZhijibm()) || "1030_S".equals(zgsrVO.getZhijibm())
                                || "1040_S".equals(zgsrVO.getZhijibm()) || "1050_S".equals(zgsrVO.getZhijibm())) { //高管/中层正职/中层副职/主管/部长助理/主任助理
                            DynamicObject gwxzObj = gwxzMap.get("10");// 管理岗
                            dataModel.setValue("nckd_dgwxz", gwxzObj.get("id"), newRow);//岗位性质
                            gangWeiXingZhiNumber = "10";
                        } else if ("1060_S".equals(zgsrVO.getZhijibm()) || "1070_S".equals(zgsrVO.getZhijibm())) { //主任工程师/副主任工程师
                            DynamicObject gwxzObj = gwxzMap.get("20");// 技术岗
                            dataModel.setValue("nckd_dgwxz", gwxzObj.get("id"), newRow);//岗位性质
                            gangWeiXingZhiNumber = "20";
                        } else {
                            String gangweimc = zgsrVO.getGangweimc();//岗位名称
                            String gangweilbbm = zgsrVO.getGangweilbbm();//岗位类别编码
                            if (gangweimc.contains("技术员") && !"GWFL_07".equals(gangweilbbm)) {
                                DynamicObject gwxzObj = gwxzMap.get("20");// 技术岗
                                dataModel.setValue("nckd_dgwxz", gwxzObj.get("id"), newRow);//岗位性质
                                gangWeiXingZhiNumber = "20";
                            } else {
                                if (uerZhenShuMap.get(zgsrVO.getRenyuanid()) != null) { // 有证书
                                    DynamicObject gwxzObj = gwxzMap.get("30");// 一线技能岗
                                    dataModel.setValue("nckd_dgwxz", gwxzObj.get("id"), newRow);//岗位性质
                                    gangWeiXingZhiNumber = "30";
                                    isJiNengRc = true;
                                } else {
                                    DynamicObject gwxzObj = gwxzMap.get("40");// 一线其他岗
                                    dataModel.setValue("nckd_dgwxz", gwxzObj.get("id"), newRow);//岗位性质
                                    gangWeiXingZhiNumber = "40";
                                }
                            }
                        }

                        // 处理岗位层级、职称、职业技能等级、执业资格逻辑
                        getGangWeiXingZhiId(dataModel, gwcjMap, gangWeiXingZhiNumber, zgsrVO, newRow, userZhiChenMap);

                        Long zgxlId = getZuigaoxueliId(zgxlMap, zgsrVO.getXuelibm());
                        dataModel.setValue("nckd_dzgxl", zgxlId, newRow);//最高学历
                        dataModel.setValue("nckd_dzy", zgsrVO.getZhuanye(), newRow);//专业
                        Long zzmmId = getZzmmId(zzmmMap, zgsrVO.getZhengzhimianmaomc());
                        dataModel.setValue("nckd_dzzmm", zzmmId, newRow);// 政治面貌
                        // 处理是否在岗业务逻辑
                        String yonggonggxbm = zgsrVO.getYonggonggxbm();
                        String yonggongjdbm = zgsrVO.getYonggongjdbm();
                        if ("1180_S".equals(yonggonggxbm) || "1200_S".equals(yonggonggxbm)
                                || "1190_S".equals(yonggonggxbm) || "1020_S".equals(yonggongjdbm)) {// 长期休假/三年离岗创业/离岗退养/用工关系终止
                            DynamicObject sfzgObj = sfzgMap.get("30");// 其他离岗
                            dataModel.setValue("nckd_dsfzg", sfzgObj.get("id"), newRow);//是否在岗
                        } else {
                            DynamicObject sfzgObj = sfzgMap.get("10");// 是
                            dataModel.setValue("nckd_dsfzg", sfzgObj.get("id"), newRow);//是否在岗
                        }
                        if ("1".equals(zgsrVO.getFeibenqyry())) {
                            dataModel.setValue("nckd_dsffbqyry", zgsrVO.getFeibenqyry(), newRow);//是否非本企业人员
                        } else {
                            dataModel.setValue("nckd_dsffbqyry", 0, newRow);//是否非本企业人员
                        }

                        if ("101".equals(zgsrVO.getGongsibm())) {// 江西省盐业集团股份有限公司总部
                            dataModel.setValue("nckd_dsfyjqyzbry", "1", newRow);//是否一级企业总部人员
                        } else {
                            dataModel.setValue("nckd_dsfyjqyzbry", "0", newRow);//是否一级企业总部人员
                        }
                        if ("1010_S".equals(zgsrVO.getZhijibm())) {// 职级等于高管
                            dataModel.setValue("nckd_dsfgg", "1", newRow);//是否高管
                        } else {
                            dataModel.setValue("nckd_dsfgg", "0", newRow);//是否高管
                        }
                        if (zgsrVO.getGangweimc().contains("专职外部董事")) {
                            dataModel.setValue("nckd_dsfwzzwbds", "1", newRow);//是否专职外部董事
                        } else {
                            dataModel.setValue("nckd_dsfwzzwbds", "0", newRow);//是否专职外部董事
                        }
                        dataModel.setValue("nckd_dsfzyjlr", "0", newRow);//是否职业经理人
                        dataModel.setValue("nckd_dsfkjrc", "0", newRow);//是否为科技人才
                        if (isJiNengRc) {
                            dataModel.setValue("nckd_dsfjnrc", "1", newRow);//是否为技能人才
                        } else {
                            dataModel.setValue("nckd_dsfjnrc", "0", newRow);//是否为技能人才
                        }
                        dataModel.setValue("nckd_dgjjkjrclx", zgsrVO.getGuojiajircid(), newRow);//国家级科技人才类型
                        // 处理是否从事研发工作逻辑
                        if (isHaveYanFaWork(zgsrVO.getBumencbm(), sjtbzfpsz, userXiangMuJingLiMap, xcxmMap,
                                zgsrVO.getMingdanid(), zgsrVO.getRenyuanid(), nckd_tbsjny)) {
                            dataModel.setValue("nckd_dsffzjcsyfggz", 1, newRow);//是否直接从事研发工作
                        } else {
                            dataModel.setValue("nckd_dsffzjcsyfggz", 0, newRow);//是否直接从事研发工作
                        }
                        if ("1010_S".equals(zgsrVO.getRuzhifangshibm())) {// 招聘来源校园招聘
                            dataModel.setValue("nckd_dsfyjbys", 1, newRow);//是否应届毕业生就业
                        } else {
                            dataModel.setValue("nckd_dsfyjbys", 0, newRow);//是否应届毕业生就业
                        }
                        if ("1010_S".equals(zgsrVO.getZhijibm())) {// 职级等于高管
                            DynamicObject xxjyzzObj = xxjyzzMap.get("10");// 实行任期制和契约化管理
                            dataModel.setValue("nckd_dsfrqqy", xxjyzzObj.get("id"), newRow);//是否实行任期制和契约化管理或新型经营责任制
                        } else if ("1020_S".equals(zgsrVO.getZhijibm()) || "1030_S".equals(zgsrVO.getZhijibm())
                                || "1060_S".equals(zgsrVO.getZhijibm()) || "1070_S".equals(zgsrVO.getZhijibm())) { //中层正职+副职+主任工程师+副主任工程师
                            DynamicObject xxjyzzObj = xxjyzzMap.get("20");// 新型经营责任制
                            dataModel.setValue("nckd_dsfrqqy", xxjyzzObj.get("id"), newRow);//是否实行任期制和契约化管理或新型经营责任制
                        } else if ("1050_S".equals(zgsrVO.getZhijibm())) {// 主任助理
                            if (isJkGs(zgsrVO.getGongsibm(), sjtbzfpsz)) {// 晶昊公司的人
                                DynamicObject xxjyzzObj = xxjyzzMap.get("20");// 新型经营责任制
                                dataModel.setValue("nckd_dsfrqqy", xxjyzzObj.get("id"), newRow);//是否实行任期制和契约化管理或新型经营责任制
                            }
                        }
                        if ("1180_S".equals(yonggonggxbm) || "1200_S".equals(yonggonggxbm)
                                || "1010_S".equals(yonggonggxbm)|| "1190_S".equals(yonggonggxbm)) {// 长期休假/三年离岗创业/试用期人员/离岗退养
                            dataModel.setValue("nckd_dsfjxkh", 0, newRow);//是否实行绩效考核
                        } else {
                            dataModel.setValue("nckd_dsfjxkh", 1, newRow);//是否实行绩效考核
                        }

                        boolean isGangWeiTiaoZheng = false;
                        if (isRzjlbh(zgsrVO.getRenyuanid(), userRenZhiJingLiBianHuaMap)) {// 判断填报月份是否有任职经历记录
                            dataModel.setValue("nckd_dsfygwtz", 1, newRow);//是否有岗位调整
                            isGangWeiTiaoZheng = true;
                        } else {
                            dataModel.setValue("nckd_dsfygwtz", 0, newRow);//是否有岗位调整
                        }

                        if (isGangWeiTiaoZheng) {
                            if ("1010_S".equals(zgsrVO.getRuzhifangshibm()) || "1020_S".equals(zgsrVO.getRuzhifangshibm())) {// 校园招聘或社会招聘
                                DynamicObject jpsgkhtzObj = jpsgkhtzMap.get("10");// 竞聘上岗
                                dataModel.setValue("nckd_dsfjpsg", jpsgkhtzObj.get("id"), newRow);//是否竞聘上岗或因考核调整
                            } else {
                                DynamicObject jpsgkhtzObj = jpsgkhtzMap.get("30");// 无
                                dataModel.setValue("nckd_dsfjpsg", jpsgkhtzObj.get("id"), newRow);//是否竞聘上岗或因考核调整
                            }
                        } else {
                            DynamicObject jpsgkhtzObj = jpsgkhtzMap.get("30");// 无
                            dataModel.setValue("nckd_dsfjpsg", jpsgkhtzObj.get("id"), newRow);//是否竞聘上岗或因考核调整
                        }

                        // 处理薪酬项目字段
                        //getUserJbxc( dataModel , xcxmMap,  zgsrVO.getMingdanid(),  xcxmjspz, xcxmList,  newRow);
                        if (userJbxcData.get(zgsrVO.getRenyuanid()) != null) {
                            ZgsrDetailsAmtVO zgsrDetailsAmtVO = userJbxcData.get(zgsrVO.getRenyuanid());
                            dataModel.setValue("nckd_djbxc", zgsrDetailsAmtVO.getNckd_djbxc(), newRow);// 基本薪酬
                            dataModel.setValue("nckd_ddnyfjx", zgsrDetailsAmtVO.getNckd_ddnyfjx(), newRow);// 当年应发绩效
                            dataModel.setValue("nckd_dyjdnjx", zgsrDetailsAmtVO.getNckd_dyjdnjx(), newRow);// 预发当年绩效
                            dataModel.setValue("nckd_dbfsnjx", zgsrDetailsAmtVO.getNckd_dbfsnjx(), newRow);// 补发上年绩效
                            dataModel.setValue("nckd_dydyzfjx", zgsrDetailsAmtVO.getNckd_dydyzfjx(), newRow);// 应递延支付绩效
                            dataModel.setValue("nckd_dffsyrjxjl", zgsrDetailsAmtVO.getNckd_dffsyrjxjl(), newRow);// 发放上一任期的任期激励
                            dataModel.setValue("nckd_dytbnrqjl", zgsrDetailsAmtVO.getNckd_dytbnrqjl(), newRow);// 预提本年度任期激励
                            dataModel.setValue("nckd_djbt", zgsrDetailsAmtVO.getNckd_djbt(), newRow);// 津补贴
                            dataModel.setValue("nckd_dqtycxzxjl", zgsrDetailsAmtVO.getNckd_dqtycxzxjl(), newRow);// 其他一次性专项奖励
                        }
                        newRow ++;
                    }
                }
            }


        }
        super.afterDoOperation(ags);
    }

    public List<Long> findHeSuanRenWuIds(Object tbzzId, Date nckd_tbsjny) {
        List<Long> hsrwIds = new ArrayList<Long>();
        // 查询所有下级组织
        List<QFilter> qfilterHr = new ArrayList<QFilter>();
        qfilterHr.add(new QFilter("iscurrentversion", "=", "1"));// 是否当前版本
        qfilterHr.add(new QFilter("datastatus", "=", "1"));// 数据版本状态
        qfilterHr.add(new QFilter("nckd_sssjgsdata.id", "=", tbzzId).or(new QFilter("id", "=", tbzzId)));// 所属公司为填报组织
        QFilter[] filtersQueryHr = (QFilter[]) qfilterHr.toArray(new QFilter[qfilterHr.size()]);
        String selectHrFields = "id,number,structnumber,structlongnumber,name,nckd_qyszhy.id,nckd_gjdq.id,nckd_xzqh.id,nckd_sscj.id,nckd_qygm.id,nckd_sslx.id,nckd_sfnrhbbb,nckd_sfsykjxqy" +
                ",nckd_kjxqylx.id,nckd_qyfl.id,nckd_zcqjl,nckd_jbsszcqjl,nckd_zqypxm,simplename";
        DynamicObjectCollection hrObjectCollection = QueryServiceHelper.query("haos_adminorghr", selectHrFields, filtersQueryHr, "sortcode asc");
        if (hrObjectCollection.size() > 0) {
            Long[] hrOrgIds = new Long[hrObjectCollection.size()];
            for (int i = 0; i < hrObjectCollection.size(); i++) {
                DynamicObject dynamicObject = hrObjectCollection.get(i);
                hrOrgIds[i] = dynamicObject.getLong("id");
            }
            List<QFilter> qfilterHs = new ArrayList<QFilter>();
            qfilterHs.add(new QFilter("enable", "=", "1"));// 使用状态
            qfilterHs.add(new QFilter("taskstatus", "=", "4").or(new QFilter("taskstatus", "=", "7")));// 任务状态-审批通过-已审核
            qfilterHs.add(new QFilter("org.id", "in", hrOrgIds));// 核算组织id
            qfilterHs.add(new QFilter("payrolldate", "=", nckd_tbsjny));// 薪资所属年月
            qfilterHs.add(new QFilter("payrollscene.nckd_notgzbb", "=", "0"));// 核算场景
            QFilter[] filtersQueryHs = (QFilter[]) qfilterHs.toArray(new QFilter[qfilterHs.size()]);
            String selectHsFields = "id,name,number";
            DynamicObjectCollection hsObjectCollection = QueryServiceHelper.query("hsas_calpayrolltask", selectHsFields, filtersQueryHs);
            if (hsObjectCollection.size() > 0) {
                for (int i = 0; i < hsObjectCollection.size(); i++) {
                    DynamicObject dynamicObject = hsObjectCollection.get(i);
                    hsrwIds.add(dynamicObject.getLong("id"));
                }
            }
        }
        return hsrwIds;
    }

    /**空判断*/
    public static boolean isNullEmpty(Object obj) {
        return obj == null || (obj instanceof String && ((String) obj).isEmpty());
    }

    /**转换国籍*/
    public Long getGongJiaId(Map<String, DynamicObject> gjdqMap, String gongJiaName) {
        Long id = 0L;
        if (isNullEmpty(gongJiaName)) {
            return id;
        }
        Set<String> gjdqKeys = gjdqMap.keySet();
        for (String key : gjdqKeys) {
            if (key.contains(gongJiaName)) {
                DynamicObject gjdqObj = gjdqMap.get(key);
                id = gjdqObj.getLong("id");
            }
        }
        return id;
    }

    /**转换岗位层级以及填充技术职称、职业技能等级、执业资格*/
    public void getGangWeiXingZhiId(IDataModel dataModel, Map<String, DynamicObject> gwcjMap, String gangWeiXingZhiNumber,
                                    ZgsrVO zgsrVO, int rowIndex, Map<Long, DynamicObject> userZhiChenMap) {
        /**①用工关系状态为长期病假、三年创业、离岗退养归入到其他；
         ②岗位信息上增加岗位层级字段；如果有岗位层级则先取，没有的话则进行转换；
         企业正副职、部门正副职、内设机构正副职等通过岗位信息上的字段；
         ③一般管理岗：岗位性质中管理岗的其他人员；
         ④正高级、高级、中级等专业技术人员：先取职称证书的最高等级，再取仅信息证书的最高等级；岗位性质为技术岗但是没有证书的进未鉴定职称技术人才；（证书信息中的职称级别增加属性字段，对照关系）
         ⑤岗位性质为一线技能岗、一线员工岗的其他人员归入未鉴定技能等级人员*/
        Long zeroId = 0L;
        boolean isSetGwcj = false;
        boolean isSetJszc = false;
        boolean isSetZyjndj = false;

        //长期休假 离岗退养 三年离岗创业
        if ("1180_S".equals(zgsrVO.getYonggonggxbm()) || "1190_S".equals(zgsrVO.getYonggonggxbm()) || "1200_S".equals(zgsrVO.getYonggonggxbm())) {
            DynamicObject gwcjObj = gwcjMap.get("91");// 其他
            dataModel.setValue("nckd_dgwcj", gwcjObj.getLong("id"), rowIndex);
            isSetGwcj = true;
        }
        if (!zeroId.equals(zgsrVO.getGangweicjid()) && !isSetGwcj) {
            dataModel.setValue("nckd_dgwcj", zgsrVO.getGangweicjid(), rowIndex);
            isSetGwcj = true;
        }
        if ("10".equals(gangWeiXingZhiNumber) && !isSetGwcj) {
            DynamicObject gwcjObj = gwcjMap.get("16");//一般管理人员
            dataModel.setValue("nckd_dgwcj", gwcjObj.getLong("id"), rowIndex);
            isSetGwcj = true;
        }

        // 先判断职称最高等级
        if (!zeroId.equals(zgsrVO.getZhichengid()) && !zeroId.equals(zgsrVO.getZhichengjbid())) {
            if (userZhiChenMap.get(zgsrVO.getZhichengjbid()) != null) {
                DynamicObject zhichengjbObj = userZhiChenMap.get(zgsrVO.getZhichengjbid());
                // 岗位层级
                if (!zeroId.equals(zhichengjbObj.getLong("nckd_dgwcj.id")) && !isSetGwcj) {
                    dataModel.setValue("nckd_dgwcj", zhichengjbObj.getLong("nckd_dgwcj.id"), rowIndex);
                    isSetGwcj = true;
                }
                // 技术职称
                if (!zeroId.equals(zhichengjbObj.getLong("nckd_djszc.id")) && !isSetJszc) {
                    dataModel.setValue("nckd_djszc", zhichengjbObj.getLong("nckd_djszc.id"), rowIndex);
                    isSetJszc = true;
                }
                // 职业技能等级
                /*if (!zeroId.equals(zhichengjbObj.getLong("nckd_dzyjndj.id")) && !isSetZyjndj) {
                    dataModel.setValue("nckd_dzyjndj", zhichengjbObj.getLong("nckd_dzyjndj.id"), rowIndex);
                    isSetZyjndj = true;
                }*/
            }
        }
        // 再判断技能最高等级
        if (!zeroId.equals(zgsrVO.getJinengid()) && !zeroId.equals(zgsrVO.getJinengjbid())) {
            if (userZhiChenMap.get(zgsrVO.getJinengjbid()) != null) {
                DynamicObject jinengjbObj = userZhiChenMap.get(zgsrVO.getJinengjbid());
                // 岗位层级
                if (!zeroId.equals(jinengjbObj.getLong("nckd_dgwcj.id")) && !isSetGwcj) {
                    dataModel.setValue("nckd_dgwcj", jinengjbObj.getLong("nckd_dgwcj.id"), rowIndex);
                    isSetGwcj = true;
                }
                // 技术职称
               /* if (!zeroId.equals(jinengjbObj.getLong("nckd_djszc.id")) && !isSetJszc) {
                    dataModel.setValue("nckd_djszc", jinengjbObj.getLong("nckd_djszc.id"), rowIndex);
                    isSetJszc = true;
                }*/
                // 职业技能等级
                if (!zeroId.equals(jinengjbObj.getLong("nckd_dzyjndj.id")) && !isSetZyjndj) {
                    dataModel.setValue("nckd_dzyjndj", jinengjbObj.getLong("nckd_dzyjndj.id"), rowIndex);
                    isSetZyjndj = true;
                }
            }

        }
        // 再判断执业资格最高等级
        if (!zeroId.equals(zgsrVO.getZhiyeid()) && !zeroId.equals(zgsrVO.getZhiyejbid())) {
            if (userZhiChenMap.get(zgsrVO.getZhiyejbid()) != null) {
                DynamicObject zhiyejbObj = userZhiChenMap.get(zgsrVO.getZhiyejbid());
                if (!zeroId.equals(zhiyejbObj.getLong("nckd_dgwcj.id")) && !isSetGwcj) {
                    dataModel.setValue("nckd_dgwcj", zhiyejbObj.getLong("nckd_dgwcj.id"), rowIndex);
                    isSetGwcj = true;
                }
                // 技术职称
                /*if (!zeroId.equals(zhiyejbObj.getLong("nckd_djszc.id")) && !isSetJszc) {
                    dataModel.setValue("nckd_djszc", zhiyejbObj.getLong("nckd_djszc.id"), rowIndex);
                    isSetJszc = true;
                }*/
                // 职业技能等级
                /*if (!zeroId.equals(zhiyejbObj.getLong("nckd_dzyjndj.id")) && !isSetZyjndj) {
                    dataModel.setValue("nckd_dzyjndj", zhiyejbObj.getLong("nckd_dzyjndj.id"), rowIndex);
                    isSetZyjndj = true;
                }*/
            }
        }

        // 执业资格
        if (isNullEmpty(zgsrVO.getZhiyeidmc())) {
            dataModel.setValue("nckd_dzyzg", "无", rowIndex);
        } else {
            dataModel.setValue("nckd_dzyzg", zgsrVO.getZhiyeidmc(), rowIndex);
        }

        if ("20".equals(gangWeiXingZhiNumber) && !isSetGwcj) {
            DynamicObject gwcjObj = gwcjMap.get("24");//未评定职称技术人员
            dataModel.setValue("nckd_dgwcj", gwcjObj.getLong("id"), rowIndex);
            isSetGwcj = true;
        }
        if (("30".equals(gangWeiXingZhiNumber) || "40".equals(gangWeiXingZhiNumber)) && !isSetGwcj) {
            DynamicObject gwcjObj = gwcjMap.get("37");//未鉴定技能等级人员
            dataModel.setValue("nckd_dgwcj", gwcjObj.getLong("id"), rowIndex);
            isSetGwcj = true;
        }
    }


    /**转换最高学历*/
    public Long getZuigaoxueliId(Map<String, DynamicObject> zgxlMap, String xueliNumber) {
        Long id = 0L;
        if (isNullEmpty(xueliNumber)) {
            return id;
        }
        if ("1010_S".equals(xueliNumber)) {//博士研究生
            DynamicObject zgxlObj = zgxlMap.get("10");
            id = zgxlObj.getLong("id");
        } else if ("1020_S".equals(xueliNumber)) {//硕士研究生
            DynamicObject zgxlObj = zgxlMap.get("20");
            id = zgxlObj.getLong("id");
        } else if ("1030_S".equals(xueliNumber)) {//本科
            DynamicObject zgxlObj = zgxlMap.get("30");
            id = zgxlObj.getLong("id");
        } else if ("1040_S".equals(xueliNumber)) {//大专
            DynamicObject zgxlObj = zgxlMap.get("40");
            id = zgxlObj.getLong("id");
        } else if ("1050_S".equals(xueliNumber)) {//高中
            DynamicObject zgxlObj = zgxlMap.get("60");
            id = zgxlObj.getLong("id");
        } else if ("1055_S".equals(xueliNumber)) {//职高
            DynamicObject zgxlObj = zgxlMap.get("50");
            id = zgxlObj.getLong("id");
        } else if ("1060_S".equals(xueliNumber)) {//中专
            DynamicObject zgxlObj = zgxlMap.get("50");
            id = zgxlObj.getLong("id");
        } else if ("1061_S".equals(xueliNumber)) {//技校
            DynamicObject zgxlObj = zgxlMap.get("50");
            id = zgxlObj.getLong("id");
        } else if ("1070_S".equals(xueliNumber)) {//初中
            DynamicObject zgxlObj = zgxlMap.get("70");
            id = zgxlObj.getLong("id");
        } else if ("1080_S".equals(xueliNumber)) {//小学
            DynamicObject zgxlObj = zgxlMap.get("80");
            id = zgxlObj.getLong("id");
        } else if ("1090_S".equals(xueliNumber)) {//其它

        }
        return id;
    }

    /**转换政治面貌*/
    public Long getZzmmId(Map<String, DynamicObject> zzmmMap, String zzmmName) {
        Long id = 0L;
        if (isNullEmpty(zzmmName)) {
            return id;
        }
        Set<String> zzmmKeys = zzmmMap.keySet();
        for (String key : zzmmKeys) {
            if (key.contains(zzmmName)) {
                DynamicObject zzmmObj = zzmmMap.get(key);
                id = zzmmObj.getLong("id");
            }
        }
        return id;
    }

    /**判断用户是否有证书*/
    public boolean isHaveZhengShu(Object personId) {
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("person.id", "=", personId));
        qfilter.add(new QFilter("iscurrentversion", "=", 1));
        qfilter.add(new QFilter("datastatus", "=", 1));
        QFilter[] filters = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        return QueryServiceHelper.exists("hsas_perprotitlehr", filters);
    }



    /**判断用户是否直接从事研发工作,部门编码，填报配置，项目经历，薪酬项目，核算名单id*/
    public boolean isHaveYanFaWork(String bumencbm, DynamicObject sjtbpzObject, Map<Long, List<DynamicObject>> userXiangMuJingLiMap,
                                   Map<Long, Map<String, Object>> xcxmMap, Long mingdanId, Long personId, Date nckd_tbsjny) {
        // 集团创新中心101.14组织的人员都是研发人员
        if (sjtbpzObject.get("nckd_jtcxzxdata.structlongnumber") != null) {
            String jtcxzxdata = sjtbpzObject.getString("nckd_jtcxzxdata.structlongnumber");
            if (bumencbm.contains(jtcxzxdata)) {
                return true;
            }
        }
        // 晶昊公司的人如果核算出的薪酬项目含JT216则是研发人员
        if (sjtbpzObject.get("nckd_jkypsybdata.structlongnumber") != null) {
            String jkypsybdata = sjtbpzObject.getString("nckd_jkypsybdata.structlongnumber");
            if (bumencbm.contains(jkypsybdata)) {
                if (xcxmMap.get(mingdanId) != null) {
                    Map<String, Object> xcxmDataMap = xcxmMap.get(mingdanId);
                    String yfryxcxmbmData = sjtbpzObject.getString("nckd_yfryxcxmbm");
                    if (!isNullEmpty(yfryxcxmbmData)) {
                        String[] yfryxcxmbmStr = yfryxcxmbmData.split(",");
                        for (String yfryxcxmbm : yfryxcxmbmStr) {
                            if (xcxmDataMap.get(yfryxcxmbm+"_txt") != null) {
                                String checkTxt = xcxmDataMap.get(yfryxcxmbm+"_txt").toString();
                                if ("研发".equals(checkTxt)) {
                                    return true;
                                }
                            }
                        }
                    }
                }
            }
        }
        // 不是集团总部的人也不是晶昊公司的人，判断是否存在项目经历还未结束的记录
        if (sjtbpzObject.get("nckd_jyzb.structlongnumber") != null && sjtbpzObject.get("nckd_jkypsybdata.structlongnumber") != null) {
            String jtzbStructlongnumber = sjtbpzObject.getString("nckd_jyzb.structlongnumber");
            String jhgsStructlongnumber = sjtbpzObject.getString("nckd_jkypsybdata.structlongnumber");
            if (!bumencbm.contains(jtzbStructlongnumber) && !bumencbm.contains(jhgsStructlongnumber)) {
                if (userXiangMuJingLiMap.get(personId) != null) {
                    String nckd_tbsjxm = DateUtils.formatDate(nckd_tbsjny, "yyyy-MM-dd");
                    LocalDate date = LocalDate.parse(nckd_tbsjxm, DateTimeFormatter.ISO_LOCAL_DATE);
                    LocalDate nckdTbsjxmLastDay = date.with(TemporalAdjusters.lastDayOfMonth());
                    List<DynamicObject> xiangMuObjets = userXiangMuJingLiMap.get(personId);
                    for (DynamicObject xiangMuObject : xiangMuObjets) {
                        Date projectEndDate = xiangMuObject.getDate("enddate");
                        if (projectEndDate != null) {
                            LocalDate projectEndLocalDate = projectEndDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
                            if (!projectEndLocalDate.isBefore(nckdTbsjxmLastDay)) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

    /**判断是否是晶昊公司的人*/
    public boolean isJkGs(String gongsibm, DynamicObject sjtbpzObject) {
        String nckd_jhgsbm = sjtbpzObject.getString("nckd_jhgsbm");
        if (gongsibm.equals(nckd_jhgsbm)) {
            return true;
        }
        return false;
    }

    /**判断当月是否有任职经历变化*/
    public boolean isRzjlbh(Long personid, Map<Long, List<DynamicObject>> userRenZhiJingLiBianHuaMap) {
        if (userRenZhiJingLiBianHuaMap.get(personid) != null) {
            List<DynamicObject> list = userRenZhiJingLiBianHuaMap.get(personid);
            if (list.size() > 0) {
                return true;
            }
        }
        return false;
    }

    /**判断是否有多个任职经历*/
    public boolean isMoreRzjlbh(Long personid, Date nckd_tbsjny) {
        String nckd_tbsjxm = DateUtils.formatDate(nckd_tbsjny, "yyyy-MM-dd");
        LocalDate date = LocalDate.parse(nckd_tbsjxm, DateTimeFormatter.ISO_LOCAL_DATE);
        LocalDate nckdTbsjxmLastDay = date.with(TemporalAdjusters.lastDayOfMonth());
        //LocalDate nckdTbsjxmFirstDay = date.with(TemporalAdjusters.firstDayOfMonth());
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("person.id", "=", personid));
        qfilter.add(new QFilter("iscurrentversion", "=", "1"));//当前版本
        //qfilter.add(new QFilter("startdate", ">=", nckdTbsjxmFirstDay));
        qfilter.add(new QFilter("startdate", "<=", nckdTbsjxmLastDay));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection dynamicObjectCollection = QueryServiceHelper.query("hrpi_empposorgrel", "id", filtersQuery);
        if (dynamicObjectCollection.size() > 1) {
            return true;
        }
        return false;
    }

    /**判断发薪任务中的业务组织不等于当月的主任职单位*/
    public boolean isMoreRzjlbhDifferent(Date nckd_tbsjny, ZgsrVO zgsrVO, Map<Long, List<DynamicObject>> userRenZhiJingLiMap) {
        String nckd_tbsjxm = DateUtils.formatDate(nckd_tbsjny, "yyyy-MM-dd");
        LocalDate date = LocalDate.parse(nckd_tbsjxm, DateTimeFormatter.ISO_LOCAL_DATE);
        LocalDate nckdTbsjxmLastDay = date.with(TemporalAdjusters.lastDayOfMonth());
        LocalDate nckdTbsjxmFirstDay = date.with(TemporalAdjusters.firstDayOfMonth());
        boolean result = false;
        Long personid = zgsrVO.getRenyuanid();
        if (userRenZhiJingLiMap.get(personid) != null) {
            Long xcCompanyId = zgsrVO.getGongsiid();
            List<DynamicObject> dynamicObjectList = userRenZhiJingLiMap.get(personid);
            if (dynamicObjectList.size() == 1) {
                return false;
            }
            for (DynamicObject dynamicObject : dynamicObjectList) {
                /**Date enddate = dynamicObject.getDate("enddate");
                // 如果enddate小于nckdTbsjxmFirstDay就跳过
                if (enddate != null) {
                    LocalDate endLocalDate = enddate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
                    if (endLocalDate.isBefore(nckdTbsjxmFirstDay)) {
                        continue; // 跳过此次循环
                    }
                }*/
                Long companyId2 = dynamicObject.getLong("company.id");
                if (!companyId2.equals(xcCompanyId)) {
                   result = true;
                   break;
                }
            }
       }
       return result;
    }

    /**获取用户当月任职经历的结束日期*/
    public Date getLiZhiRiQi(Date nckd_tbsjny, Date lizhiDate) {
        String nckd_tbsjxm = DateUtils.formatDate(nckd_tbsjny, "yyyy-MM-dd");
        LocalDate date = LocalDate.parse(nckd_tbsjxm, DateTimeFormatter.ISO_LOCAL_DATE);
        LocalDate nckdTbsjxmLastDay = date.with(TemporalAdjusters.lastDayOfMonth());
        Date lizhiRiqiDate = null;
        if (lizhiDate != null) {
            LocalDate endLocalDate = lizhiDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
            if (endLocalDate.isAfter(nckdTbsjxmLastDay)) {
                return null;
            }
            lizhiRiqiDate = lizhiDate;
        }
        return lizhiRiqiDate;
    }

    /**判断用户主任职经历是否跨公司*/
    public boolean isMoreRzjlbhDifferentCompany(Date nckd_tbsjny, ZgsrVO zgsrVO, Map<Long, List<DynamicObject>> userRenZhiJingLiMap) {
        boolean result = false;
        Long personid = zgsrVO.getRenyuanid();
        if (userRenZhiJingLiMap.get(personid) != null) {
            Long xcCompanyId = zgsrVO.getGongsiid();
            List<DynamicObject> dynamicObjectList = userRenZhiJingLiMap.get(personid);
            if (dynamicObjectList.size() == 1) {
                return false;
            }
            for (DynamicObject dynamicObject : dynamicObjectList) {
                Long companyId2 = dynamicObject.getLong("company.id");
                if (!companyId2.equals(xcCompanyId)) {
                    result = true;
                    break;
                }
            }
        }
        return result;
    }

    /**处理用户薪酬项目字段*/
    public void getUserJbxc(IDataModel dataModel ,Map<Long, Map<String, Object>> zgsrMap, Long fcalpersonid, DynamicObject xcxmjspz, List<String> xcxmList, int rowIndex) {
        logger.info("处理薪酬用户ID：" + fcalpersonid);
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("JavaScript");
        String nckd_xcxm = xcxmjspz.getString("nckd_xcxm");// 基本薪酬
        if (!isNullEmpty(nckd_xcxm)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_xcxm = nckd_xcxm.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_xcxm = nckd_xcxm.replace(xcxm, "0");
                }
                nckd_xcxm = nckd_xcxm.replace("--", "-");
                nckd_xcxm = nckd_xcxm.replace("++", "+");
                logger.info("处理薪酬用户nckd_xcxm：" + nckd_xcxm);
                try {
                    Object resultData = engine.eval(nckd_xcxm);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_djbxc", result, rowIndex);// 基本薪酬
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }
        String nckd_dnyfjx = xcxmjspz.getString("nckd_dnyfjx");// 当年应发绩效
        if (!isNullEmpty(nckd_dnyfjx)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_dnyfjx = nckd_dnyfjx.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_dnyfjx = nckd_dnyfjx.replace(xcxm, "0");
                }
                nckd_dnyfjx = nckd_dnyfjx.replace("--", "-");
                nckd_dnyfjx = nckd_dnyfjx.replace("++", "+");
                logger.info("处理薪酬用户nckd_dnyfjx：" + nckd_dnyfjx);
                try {
                    Object resultData = engine.eval(nckd_dnyfjx);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_ddnyfjx", result, rowIndex);// 当年应发绩效
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }
        String nckd_yfdnjx = xcxmjspz.getString("nckd_yfdnjx");// 预发当年绩效
        if (!isNullEmpty(nckd_yfdnjx)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_yfdnjx = nckd_yfdnjx.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_yfdnjx = nckd_yfdnjx.replace(xcxm, "0");
                }
                nckd_yfdnjx = nckd_yfdnjx.replace("--", "-");
                nckd_yfdnjx = nckd_yfdnjx.replace("++", "+");
                logger.info("处理薪酬用户nckd_yfdnjx：" + nckd_yfdnjx);
                try {
                    Object resultData = engine.eval(nckd_yfdnjx);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_dyjdnjx", result, rowIndex);// 预发当年绩效
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }
        String nckd_bfdnjx = xcxmjspz.getString("nckd_bfdnjx");// 补发上年绩效
        if (!isNullEmpty(nckd_bfdnjx)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_bfdnjx = nckd_bfdnjx.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_bfdnjx = nckd_bfdnjx.replace(xcxm, "0");
                }
                nckd_bfdnjx = nckd_bfdnjx.replace("--", "-");
                nckd_bfdnjx = nckd_bfdnjx.replace("++", "+");
                logger.info("处理薪酬用户nckd_bfdnjx：" + nckd_bfdnjx);
                try {
                    Object resultData = engine.eval(nckd_bfdnjx);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_dbfsnjx", result, rowIndex);// 补发上年绩效
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }
        String nckd_ydyzfjx = xcxmjspz.getString("nckd_ydyzfjx");// 应递延支付绩效
        if (!isNullEmpty(nckd_ydyzfjx)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_ydyzfjx = nckd_ydyzfjx.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_ydyzfjx = nckd_ydyzfjx.replace(xcxm, "0");
                }
                nckd_ydyzfjx = nckd_ydyzfjx.replace("--", "-");
                nckd_ydyzfjx = nckd_ydyzfjx.replace("++", "+");
                logger.info("处理薪酬用户nckd_ydyzfjx：" + nckd_ydyzfjx);
                try {
                    Object resultData = engine.eval(nckd_ydyzfjx);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_dydyzfjx", result, rowIndex);// 应递延支付绩效
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }
        String nckd_syrrqjl = xcxmjspz.getString("nckd_syrrqjl");// 发放上一任期的任期激励
        if (!isNullEmpty(nckd_syrrqjl)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_syrrqjl = nckd_syrrqjl.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_syrrqjl = nckd_syrrqjl.replace(xcxm, "0");
                }
                nckd_syrrqjl = nckd_syrrqjl.replace("--", "-");
                nckd_syrrqjl = nckd_syrrqjl.replace("++", "+");
                logger.info("处理薪酬用户nckd_syrrqjl：" + nckd_syrrqjl);
                try {
                    Object resultData = engine.eval(nckd_syrrqjl);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_dffsyrjxjl", result, rowIndex);// 发放上一任期的任期激励
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }
        String nckd_bndrqjl = xcxmjspz.getString("nckd_bndrqjl");// 预提本年度任期激励
        if (!isNullEmpty(nckd_bndrqjl)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_bndrqjl = nckd_bndrqjl.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_bndrqjl = nckd_bndrqjl.replace(xcxm, "0");
                }
                nckd_bndrqjl = nckd_bndrqjl.replace("--", "-");
                nckd_bndrqjl = nckd_bndrqjl.replace("++", "+");
                logger.info("处理薪酬用户nckd_bndrqjl：" + nckd_bndrqjl);
                try {
                    Object resultData = engine.eval(nckd_bndrqjl);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_dytbnrqjl", result, rowIndex);// 预提本年度任期激励
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }
        String nckd_jbt = xcxmjspz.getString("nckd_jbt");// 津补贴
        if (!isNullEmpty(nckd_jbt)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_jbt = nckd_jbt.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_jbt = nckd_jbt.replace(xcxm, "0");
                }
                nckd_jbt = nckd_jbt.replace("--", "-");
                nckd_jbt = nckd_jbt.replace("++", "+");
                logger.info("处理薪酬用户nckd_jbt：" + nckd_jbt);
                try {
                    Object resultData = engine.eval(nckd_jbt);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_djbt", result, rowIndex);// 津补贴
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }
        String nckd_qtycxjl = xcxmjspz.getString("nckd_qtycxjl");// 其他一次性专项奖励
        if (!isNullEmpty(nckd_qtycxjl)) {
            if (zgsrMap.get(fcalpersonid) != null) {
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                for (String key : keys) {
                    nckd_qtycxjl = nckd_qtycxjl.replace(key, String.valueOf(personMap.get(key)));
                }
                // 将公式中的变量替换成对应的值
                for (String xcxm : xcxmList) {
                    nckd_qtycxjl = nckd_qtycxjl.replace(xcxm, "0");
                }
                nckd_qtycxjl = nckd_qtycxjl.replace("--", "-");
                nckd_qtycxjl = nckd_qtycxjl.replace("++", "+");
                logger.info("处理薪酬用户nckd_qtycxjl：" + nckd_qtycxjl);
                try {
                    Object resultData = engine.eval(nckd_qtycxjl);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    dataModel.setValue("nckd_dqtycxzxjl", result, rowIndex);// 其他一次性专项奖励
                } catch (ScriptException e) {
                    logger.info("计算配置错误");
                    e.printStackTrace();
                }
            }
        }


    }


    /**处理用户薪酬项目字段，将用户薪酬记录合并*/
    public Map<Long, ZgsrDetailsAmtVO> getUserJbxcData(Map<Long, Map<String, Object>> zgsrMap, List<ZgsrVO> zgsrVOList, DynamicObject xcxmjspz, List<String> xcxmList) {
        Map<Long, ZgsrDetailsAmtVO> zgsrDetailsDataMap = new HashMap<Long, ZgsrDetailsAmtVO>();
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("JavaScript");
        String nckd_xcxm_data = xcxmjspz.getString("nckd_xcxm");// 基本薪酬
        String nckd_dnyfjx_data = xcxmjspz.getString("nckd_dnyfjx");// 当年应发绩效
        String nckd_yfdnjx_data = xcxmjspz.getString("nckd_yfdnjx");// 预发当年绩效
        String nckd_bfdnjx_data = xcxmjspz.getString("nckd_bfdnjx");// 补发上年绩效
        String nckd_ydyzfjx_data = xcxmjspz.getString("nckd_ydyzfjx");// 应递延支付绩效
        String nckd_syrrqjl_data = xcxmjspz.getString("nckd_syrrqjl");// 发放上一任期的任期激励
        String nckd_bndrqjl_data = xcxmjspz.getString("nckd_bndrqjl");// 预提本年度任期激励
        String nckd_jbt_data = xcxmjspz.getString("nckd_jbt");// 津补贴
        String nckd_qtycxjl_data = xcxmjspz.getString("nckd_qtycxjl");// 其他一次性专项奖励
        try {
            String nckd_xcxm_check = "";// 基本薪酬
            String nckd_dnyfjx_check = "";// 当年应发绩效
            String nckd_yfdnjx_check = "";// 预发当年绩效
            String nckd_bfdnjx_check = "";// 补发上年绩效
            String nckd_ydyzfjx_check = "";// 应递延支付绩效
            String nckd_syrrqjl_check = "";// 发放上一任期的任期激励
            String nckd_bndrqjl_check = "";// 预提本年度任期激励
            String nckd_jbt_check = "";// 津补贴
            String nckd_qtycxjl_check = "";// 其他一次性专项奖励
            // 防止名单重复处理
            Set<Long> mingDanIdSet = new HashSet<Long>();
            for (ZgsrVO zgsrVO : zgsrVOList) {
                nckd_xcxm_check = nckd_xcxm_data;// 基本薪酬
                nckd_dnyfjx_check = nckd_dnyfjx_data;// 当年应发绩效
                nckd_yfdnjx_check = nckd_yfdnjx_data;// 预发当年绩效
                nckd_bfdnjx_check = nckd_bfdnjx_data;// 补发上年绩效
                nckd_ydyzfjx_check = nckd_ydyzfjx_data;// 应递延支付绩效
                nckd_syrrqjl_check = nckd_syrrqjl_data;// 发放上一任期的任期激励
                nckd_bndrqjl_check = nckd_bndrqjl_data;// 预提本年度任期激励
                nckd_jbt_check = nckd_jbt_data;// 津补贴
                nckd_qtycxjl_check = nckd_qtycxjl_data;// 其他一次性专项奖励
                Long fcalpersonid = zgsrVO.getMingdanid();
                if (mingDanIdSet.contains(fcalpersonid)) {
                    continue;
                } else {
                    mingDanIdSet.add(fcalpersonid);
                }
                logger.info("处理薪酬用户名单ID：" + fcalpersonid);
                if (zgsrMap.get(fcalpersonid) == null) {
                    logger.info("处理薪酬用户名单ID：" + fcalpersonid + "没有找到薪酬记录");
                    continue;
                }
                Long personid = zgsrVO.getRenyuanid();
                Map<String, Object> personMap = zgsrMap.get(fcalpersonid);
                Set<String> keys = personMap.keySet();
                if (!isNullEmpty(nckd_xcxm_check)) {
                    for (String key : keys) {
                        nckd_xcxm_check = nckd_xcxm_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_xcxm_check = nckd_xcxm_check.replace(xcxm, "0");
                    }
                    nckd_xcxm_check = nckd_xcxm_check.replace("--", "-");
                    nckd_xcxm_check = nckd_xcxm_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_xcxm：" + nckd_xcxm_check);
                    Object resultData = engine.eval(nckd_xcxm_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_djbxc(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_djbxc());
                        zsrDetailsAmtVO.setNckd_djbxc(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
                if (!isNullEmpty(nckd_dnyfjx_check)) {
                    for (String key : keys) {
                        nckd_dnyfjx_check = nckd_dnyfjx_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_dnyfjx_check = nckd_dnyfjx_check.replace(xcxm, "0");
                    }
                    nckd_dnyfjx_check = nckd_dnyfjx_check.replace("--", "-");
                    nckd_dnyfjx_check = nckd_dnyfjx_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_dnyfjx：" + nckd_dnyfjx_check);
                    Object resultData = engine.eval(nckd_dnyfjx_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_ddnyfjx(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_ddnyfjx());
                        zsrDetailsAmtVO.setNckd_ddnyfjx(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
                if (!isNullEmpty(nckd_yfdnjx_check)) {
                    for (String key : keys) {
                        nckd_yfdnjx_check = nckd_yfdnjx_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_yfdnjx_check = nckd_yfdnjx_check.replace(xcxm, "0");
                    }
                    nckd_yfdnjx_check = nckd_yfdnjx_check.replace("--", "-");
                    nckd_yfdnjx_check = nckd_yfdnjx_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_yfdnjx：" + nckd_yfdnjx_check);
                    Object resultData = engine.eval(nckd_yfdnjx_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_dyjdnjx(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_dyjdnjx());
                        zsrDetailsAmtVO.setNckd_dyjdnjx(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
                if (!isNullEmpty(nckd_bfdnjx_check)) {
                    for (String key : keys) {
                        nckd_bfdnjx_check = nckd_bfdnjx_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_bfdnjx_check = nckd_bfdnjx_check.replace(xcxm, "0");
                    }
                    nckd_bfdnjx_check = nckd_bfdnjx_check.replace("--", "-");
                    nckd_bfdnjx_check = nckd_bfdnjx_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_bfdnjx：" + nckd_bfdnjx_check);
                    Object resultData = engine.eval(nckd_bfdnjx_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_dbfsnjx(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_dbfsnjx());
                        zsrDetailsAmtVO.setNckd_dbfsnjx(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
                if (!isNullEmpty(nckd_ydyzfjx_check)) {
                    for (String key : keys) {
                        nckd_ydyzfjx_check = nckd_ydyzfjx_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_ydyzfjx_check = nckd_ydyzfjx_check.replace(xcxm, "0");
                    }
                    nckd_ydyzfjx_check = nckd_ydyzfjx_check.replace("--", "-");
                    nckd_ydyzfjx_check = nckd_ydyzfjx_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_ydyzfjx：" + nckd_ydyzfjx_check);
                    Object resultData = engine.eval(nckd_ydyzfjx_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_dydyzfjx(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_dydyzfjx());
                        zsrDetailsAmtVO.setNckd_dydyzfjx(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
                if (!isNullEmpty(nckd_syrrqjl_check)) {
                    for (String key : keys) {
                        nckd_syrrqjl_check = nckd_syrrqjl_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_syrrqjl_check = nckd_syrrqjl_check.replace(xcxm, "0");
                    }
                    nckd_syrrqjl_check = nckd_syrrqjl_check.replace("--", "-");
                    nckd_syrrqjl_check = nckd_syrrqjl_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_syrrqjl：" + nckd_syrrqjl_check);
                    Object resultData = engine.eval(nckd_syrrqjl_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_dffsyrjxjl(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_dffsyrjxjl());
                        zsrDetailsAmtVO.setNckd_dffsyrjxjl(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
                if (!isNullEmpty(nckd_bndrqjl_check)) {
                    for (String key : keys) {
                        nckd_bndrqjl_check = nckd_bndrqjl_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_bndrqjl_check = nckd_bndrqjl_check.replace(xcxm, "0");
                    }
                    nckd_bndrqjl_check = nckd_bndrqjl_check.replace("--", "-");
                    nckd_bndrqjl_check = nckd_bndrqjl_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_bndrqjl：" + nckd_bndrqjl_check);
                    Object resultData = engine.eval(nckd_bndrqjl_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_dytbnrqjl(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_dytbnrqjl());
                        zsrDetailsAmtVO.setNckd_dytbnrqjl(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
                if (!isNullEmpty(nckd_jbt_check)) {
                    for (String key : keys) {
                        nckd_jbt_check = nckd_jbt_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_jbt_check = nckd_jbt_check.replace(xcxm, "0");
                    }
                    nckd_jbt_check = nckd_jbt_check.replace("--", "-");
                    nckd_jbt_check = nckd_jbt_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_jbt：" + nckd_jbt_check);
                    Object resultData = engine.eval(nckd_jbt_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_djbt(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_djbt());
                        zsrDetailsAmtVO.setNckd_djbt(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
                if (!isNullEmpty(nckd_qtycxjl_check)) {
                    for (String key : keys) {
                        nckd_qtycxjl_check = nckd_qtycxjl_check.replace(key, String.valueOf(personMap.get(key)));
                    }
                    // 将公式中的变量替换成对应的值
                    for (String xcxm : xcxmList) {
                        nckd_qtycxjl_check = nckd_qtycxjl_check.replace(xcxm, "0");
                    }
                    nckd_qtycxjl_check = nckd_qtycxjl_check.replace("--", "-");
                    nckd_qtycxjl_check = nckd_qtycxjl_check.replace("++", "+");
                    logger.info("处理薪酬用户nckd_qtycxjl：" + nckd_qtycxjl_check);
                    Object resultData = engine.eval(nckd_qtycxjl_check);
                    BigDecimal result = new BigDecimal(resultData.toString());
                    if (zgsrDetailsDataMap.get(personid) != null) {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = zgsrDetailsDataMap.get(personid);
                        zsrDetailsAmtVO.setNckd_dqtycxzxjl(result);
                    } else {
                        ZgsrDetailsAmtVO zsrDetailsAmtVO = new ZgsrDetailsAmtVO();
                        result = result.add(zsrDetailsAmtVO.getNckd_dqtycxzxjl());
                        zsrDetailsAmtVO.setNckd_dqtycxzxjl(result);
                        zgsrDetailsDataMap.put(personid, zsrDetailsAmtVO);
                    }
                }
            }
        } catch (ScriptException e) {
            logger.info("计算配置错误");
            e.printStackTrace();
        }
        return zgsrDetailsDataMap;
    }

    /**获取入职方式集合*/
    public Map<String, DynamicObject> findRzfsMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_rzfs", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("number"), dynamicObject);
        }
        return resultMap;
    }

    /**获取证件类型集合*/
    public Map<String, DynamicObject> findZjlxMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_zjlx", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("number"), dynamicObject);
        }
        return resultMap;
    }

    /**获取国籍地区集合*/
    public Map<String, DynamicObject> findGjdqMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_gjdq", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("name"), dynamicObject);
        }
        return resultMap;
    }

    /**获取岗位性质集合*/
    public Map<String, DynamicObject> findGwxzMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_gwxz", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("number"), dynamicObject);
        }
        return resultMap;
    }

    /**获取岗位层级集合*/
    public Map<String, DynamicObject> findGwcjMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_gwcj", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("number"), dynamicObject);
        }
        return resultMap;
    }

    /**获取最高学历集合*/
    public Map<String, DynamicObject> findZgxlMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_zgxl", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("number"), dynamicObject);
        }
        return resultMap;
    }

    /**获取政治面貌集合*/
    public Map<String, DynamicObject> findZzmmMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_zzmm", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("name"), dynamicObject);
        }
        return resultMap;
    }

    /**获取技术职称*/
    public Map<String, DynamicObject> findJszcMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_jszc", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("name"), dynamicObject);
        }
        return resultMap;
    }

    /**获取职业技能等级*/
    public Map<String, DynamicObject> findZyjndjMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_zyjndj", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("name"), dynamicObject);
        }
        return resultMap;
    }

    /**获取是否在岗集合*/
    public Map<String, DynamicObject> findSfzgMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_sfzg", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("number"), dynamicObject);
        }
        return resultMap;
    }

    /**获取是否实行任期制和契约化管理或新型经营责任制集合*/
    public Map<String, DynamicObject> findRqqyxxjyMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_rqqyxxjy", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("number"), dynamicObject);
        }
        return resultMap;
    }

    /**获取是否竞聘上岗或因考核调整集合*/
    public Map<String, DynamicObject> findJpsgkhtzMap() {
        Map<String, DynamicObject> resultMap = new LinkedHashMap();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", "1"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_jpsgkhtz", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultMap.put(dynamicObject.getString("number"), dynamicObject);
        }
        return resultMap;
    }

    /**获取薪酬项目计算*/
    public DynamicObject findXcxmjspz() {
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("number", "=", "xcxmjs"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_jbxcjs", "id,number,name,nckd_xcxm,nckd_dnyfjx" +
                ",nckd_yfdnjx,nckd_bfdnjx,nckd_ydyzfjx,nckd_syrrqjl,nckd_bndrqjl,nckd_jbt,nckd_qtycxjl", filtersQuery);
        if (objectCollection.size() > 0) {
            return objectCollection.get(0);
        }
        return null;
    }

    /**获取数据填报配置*/
    public DynamicObject findSjtbpz() {
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("number", "=", "SJTBRWSET"));
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        // id,编码，名称，江西晶昊盐化有限公司编码，江西富达盐化有限公司编码，集团总部创新中心，晶昊公司，江西省盐业集团股份有限公司总部,晶昊公司研发人员薪酬项目编码
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("nckd_sjtbrwpz", "id,number,name,nckd_jhgsbm,nckd_fdgsbm," +
                "nckd_jtcxzxdata.id,nckd_jtcxzxdata.number,nckd_jtcxzxdata.structnumber,nckd_jtcxzxdata.structlongnumber," +
                "nckd_jkypsybdata.id,nckd_jkypsybdata.number,nckd_jkypsybdata.structnumber,nckd_jkypsybdata.structlongnumber," +
                "nckd_jyzb.id,nckd_jyzb.number,nckd_jyzb.structnumber,nckd_jyzb.structlongnumber," +
                "nckd_yfryxcxmbm", filtersQuery);
        if (objectCollection.size() > 0) {
            return objectCollection.get(0);
        }
        return null;
    }

    /**根据核算任务Id获取用户薪酬明细*/
    public Map<Long, Map<String, Object>> findUserXcProject(List<Long> hsTaskId) {
        String hsTaskIds = StringUtils.join(hsTaskId, ",");
        Map<Long, Map<String, Object>> resultDataMap = new LinkedHashMap();
        String ksql_xcxm = " select b.fcaltaskid as fcaltaskid,b.fcalpersonid as fcalpersonid,c.fname as username," +
                " d.fname as xmname,d.fnumber as xmnumber,a.fcalamountvalue as calamountvalue,a.ftextvalue as textvalue " +
                "from t_hsas_caltableentry a" +
                " left join t_hsas_caltable b on a.fid = b.fid " +
                " left join t_hsas_calperson c on c.fid = b.fcalpersonid" +
                " left join t_hsbs_salaryitem d on d.fid = a.fsalaryitemid" +
                " where b.fcaltaskid in ("+hsTaskIds+") " +
                //" and (c.fname = '杨冬莲' or c.fname='徐艳平') " +
                "";
        logger.info("ksql_xcxm："+ksql_xcxm);
        DataSet dataSet_xcxm = DB.queryDataSet(this.getClass().getName(), DBRoute.of("hr"), ksql_xcxm);
        Iterator<Row> iterator_scxm = dataSet_xcxm.iterator();
        List<ZgsrDetailsVO> zgsrDetailsList = new ArrayList();
        while (iterator_scxm.hasNext()) {
            Row row = iterator_scxm.next();
            Long fcalpersonid = row.getLong("fcalpersonid");
            String xmnumber = row.getString("xmnumber");
            BigDecimal calamountvalue = row.getBigDecimal("calamountvalue");
            String textvalue = row.getString("textvalue");

            ZgsrDetailsVO zgsrDetailsVO = new ZgsrDetailsVO();
            zgsrDetailsVO.setFcalpersonid(fcalpersonid);
            zgsrDetailsVO.setXmnumber(xmnumber);
            zgsrDetailsVO.setCalamountvalue(calamountvalue);
            zgsrDetailsVO.setTextvalue(textvalue);
            zgsrDetailsList.add(zgsrDetailsVO);
        }
        // 将薪酬项目明细分组
        Map<Long, List<ZgsrDetailsVO>> resultMap = new LinkedHashMap();
        for (ZgsrDetailsVO cp: zgsrDetailsList) {
            if (resultMap.get(cp.getFcalpersonid()) == null) {
                List<ZgsrDetailsVO> list = new ArrayList();
                list.add(cp);
                resultMap.put(cp.getFcalpersonid(), list);
            } else {
                List<ZgsrDetailsVO> list = resultMap.get(cp.getFcalpersonid());
                list.add(cp);
                resultMap.put(cp.getFcalpersonid(), list);
            }
        }
        // 将薪酬项目转换为Map
        Set<Long> keySet = resultMap.keySet();
        for (Long key: keySet) {
            List<ZgsrDetailsVO> list = resultMap.get(key);
            Map<String, Object> map = new LinkedHashMap();
            for (ZgsrDetailsVO cp:list) {
                map.put(cp.getXmnumber(), cp.getCalamountvalue());
                map.put(cp.getXmnumber()+"_txt", cp.getTextvalue());
            }
            resultDataMap.put(key, map);
        }
        return resultDataMap;
    }

    /**获取所有的薪酬项目*/
    public List<String> findAllXcProject() {
        List<String> resultList = new ArrayList();
        List<QFilter> qfilter = new ArrayList<QFilter>();
        qfilter.add(new QFilter("enable", "=", 1));//使用状态
        qfilter.add(new QFilter("status", "=", "C"));//数据状态
        QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
        DynamicObjectCollection objectCollection = QueryServiceHelper.query("hsbs_salaryitem", "id,number,name", filtersQuery);
        for (DynamicObject dynamicObject : objectCollection) {
            resultList.add(dynamicObject.getString("number"));
        }
        return resultList;
    }


    /**获取职称级别*/
    public DynamicObject getZhiChenJiBie(Long id) {
        return BusinessDataServiceHelper.loadSingle(id, "hbss_protitlelevel");
    }

    /**获取人员与组织人id关系，组织人有多个取第一个*/
    public Map<Long, Long> findHrpiDepempMap(List<ZgsrVO> zgsrVOList) {
        Map<Long, Long> resultMap = new LinkedHashMap();
        Object[] ryIds = new Long[zgsrVOList.size()];
        for (int i = 0; i < zgsrVOList.size(); i++) {
            ZgsrVO zgsrVO = zgsrVOList.get(i);
            ryIds[i] = zgsrVO.getRenyuanid();
        }
        if (ryIds.length > 0) {
            List<QFilter> qfilter = new ArrayList<QFilter>();
            qfilter.add(new QFilter("person.id", "in", ryIds));
            qfilter.add(new QFilter("iscurrentversion", "=", 1));
            qfilter.add(new QFilter("datastatus", "=", 1));
            QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
            DynamicObjectCollection objectCollection = QueryServiceHelper.query("hrpi_depemp", "id,datastatus,iscurrentversion,person.id", filtersQuery);
            for (DynamicObject object : objectCollection) {
                Long depempid = object.getLong("id");
                Long personid = object.getLong("person.id");
                if (resultMap.get(personid) == null) {
                    resultMap.put(personid, depempid);
                }
            }
        }
        return resultMap;
    }

    /**获取人员证书数据*/
    public Map<Long, List<DynamicObject>> findUserZhenShuMap(List<ZgsrVO> zgsrVOList) {
        Map<Long, List<DynamicObject>> resultMap = new LinkedHashMap();
        Object[] ryIds = new Long[zgsrVOList.size()];
        for (int i = 0; i < zgsrVOList.size(); i++) {
            ZgsrVO zgsrVO = zgsrVOList.get(i);
            ryIds[i] = zgsrVO.getRenyuanid();
        }
        if (ryIds.length > 0) {
            List<QFilter> qfilter = new ArrayList<QFilter>();
            qfilter.add(new QFilter("person.id", "in", ryIds));
            qfilter.add(new QFilter("iscurrentversion", "=", 1));
            qfilter.add(new QFilter("datastatus", "=", 1));
            QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
            DynamicObjectCollection objectCollection = QueryServiceHelper.query("hsas_perprotitlehr", "id,datastatus,iscurrentversion,person.id", filtersQuery);
            for (DynamicObject object : objectCollection) {
                Long personid = object.getLong("person.id");
                if (resultMap.get(personid) == null) {
                    List<DynamicObject> list = new ArrayList();
                    list.add(object);
                    resultMap.put(personid, list);
                } else {
                    resultMap.get(personid).add(object);
                }
            }
        }
        return resultMap;
    }

    /**获取人员任职经历变化数据*/
    public Map<Long, List<DynamicObject>> findUserRenZhiJingLiBianHuaMap(List<ZgsrVO> zgsrVOList, Date nckd_tbsjny) {
        Map<Long, List<DynamicObject>> resultMap = new LinkedHashMap();
        String nckd_tbsjxm = DateUtils.formatDate(nckd_tbsjny, "yyyy-MM-dd");
        LocalDate date = LocalDate.parse(nckd_tbsjxm, DateTimeFormatter.ISO_LOCAL_DATE);
        LocalDate nckdTbsjxmLastDay = date.with(TemporalAdjusters.lastDayOfMonth());
        LocalDate nckdTbsjxmFirstDay = date.with(TemporalAdjusters.firstDayOfMonth());
        Object[] ryIds = new Long[zgsrVOList.size()];
        for (int i = 0; i < zgsrVOList.size(); i++) {
            ZgsrVO zgsrVO = zgsrVOList.get(i);
            ryIds[i] = zgsrVO.getRenyuanid();
        }
        if (ryIds.length > 0) {
            List<QFilter> qfilter = new ArrayList<QFilter>();
            qfilter.add(new QFilter("person.id", "in", ryIds));
            qfilter.add(new QFilter("startdate", ">=", nckdTbsjxmFirstDay));
            qfilter.add(new QFilter("startdate", "<=", nckdTbsjxmLastDay));
            qfilter.add(new QFilter("iscurrentversion", "=", "1"));//当前版本
            QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
            DynamicObjectCollection objectCollection = QueryServiceHelper.query("hrpi_empposorgrel", "id,startdate,iscurrentversion,person.id", filtersQuery);
            for (DynamicObject object : objectCollection) {
                Long personid = object.getLong("person.id");
                if (resultMap.get(personid) == null) {
                    List<DynamicObject> list = new ArrayList();
                    list.add(object);
                    resultMap.put(personid, list);
                } else {
                    resultMap.get(personid).add(object);
                }
            }
        }
        return resultMap;
    }

    /**获取人员当月的主任职经历数据*/
    public Map<Long, List<DynamicObject>> findUserRenZhiJingLiMap(List<ZgsrVO> zgsrVOList, Date nckd_tbsjny) {
        Map<Long, List<DynamicObject>> resultMap = new LinkedHashMap();
        String nckd_tbsjxm = DateUtils.formatDate(nckd_tbsjny, "yyyy-MM-dd");
        LocalDate date = LocalDate.parse(nckd_tbsjxm, DateTimeFormatter.ISO_LOCAL_DATE);
        LocalDate nckdTbsjxmLastDay = date.with(TemporalAdjusters.lastDayOfMonth());
        LocalDate nckdTbsjxmFirstDay = date.with(TemporalAdjusters.firstDayOfMonth());
        Object[] ryIds = new Long[zgsrVOList.size()];
        for (int i = 0; i < zgsrVOList.size(); i++) {
            ZgsrVO zgsrVO = zgsrVOList.get(i);
            ryIds[i] = zgsrVO.getRenyuanid();
        }
        if (ryIds.length > 0) {
            List<QFilter> qfilter = new ArrayList<QFilter>();
            qfilter.add(new QFilter("person.id", "in", ryIds));
            qfilter.add(new QFilter("isprimary", "=", "1"));//主任职
            //qfilter.add(new QFilter("startdate", "<=", nckdTbsjxmLastDay));//
            //qfilter.add(new QFilter("enddate", ">=", nckdTbsjxmFirstDay));//任职结束日期大于当月
            qfilter.add(new QFilter("iscurrentversion", "=", "1"));//当前版本
            QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
            DynamicObjectCollection objectCollection = QueryServiceHelper.query("hrpi_empposorgrel", "id,startdate,iscurrentversion,person.id,company.id,company.name,enddate", filtersQuery);
            for (DynamicObject object : objectCollection) {
                Long personid = object.getLong("person.id");
                if (resultMap.get(personid) == null) {
                    List<DynamicObject> list = new ArrayList();
                    list.add(object);
                    resultMap.put(personid, list);
                } else {
                    resultMap.get(personid).add(object);
                }
            }
        }
        return resultMap;
    }


    /**获取人员项目经历数据*/
    public Map<Long, List<DynamicObject>> findUserXiangMuJingLiMap(List<ZgsrVO> zgsrVOList) {
        Map<Long, List<DynamicObject>> resultMap = new LinkedHashMap();
        Object[] ryIds = new Long[zgsrVOList.size()];
        for (int i = 0; i < zgsrVOList.size(); i++) {
            ZgsrVO zgsrVO = zgsrVOList.get(i);
            ryIds[i] = zgsrVO.getRenyuanid();
        }
        if (ryIds.length > 0) {
            List<QFilter> qfilter = new ArrayList<QFilter>();
            qfilter.add(new QFilter("person.id", "in", ryIds));
            qfilter.add(new QFilter("datastatus", "=", "1"));// 数据版本状态
            qfilter.add(new QFilter("iscurrentversion", "=", "1"));//当前版本
            QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
            DynamicObjectCollection objectCollection = QueryServiceHelper.query("hspm_empproexp", "id,startdate,enddate,person.id", filtersQuery);
            for (DynamicObject object : objectCollection) {
                Long personid = object.getLong("person.id");
                if (resultMap.get(personid) == null) {
                    List<DynamicObject> list = new ArrayList();
                    list.add(object);
                    resultMap.put(personid, list);
                } else {
                    resultMap.get(personid).add(object);
                }
            }
        }
        return resultMap;
    }


    /**获取人员职称信息/技能信息/执业资格信息*/
    public Map<Long, DynamicObject> findUserZhiChenMap(List<ZgsrVO> zgsrVOList) {
        Set<Long> ids = new HashSet<Long>();
        Map<Long, DynamicObject> resultMap = new LinkedHashMap();
        for (int i = 0; i < zgsrVOList.size(); i++) {
            ZgsrVO zgsrVO = zgsrVOList.get(i);
            ids.add(zgsrVO.getZhichengjbid());
            ids.add(zgsrVO.getJinengjbid());
            ids.add(zgsrVO.getZhiyejbid());
        }
        if (ids.size() > 0) {
            Object[] idsArray = ids.toArray(new Object[0]);
            List<QFilter> qfilter = new ArrayList<QFilter>();
            qfilter.add(new QFilter("id", "in", idsArray));
            QFilter[] filtersQuery = (QFilter[]) qfilter.toArray(new QFilter[qfilter.size()]);
            DynamicObjectCollection objectCollection = QueryServiceHelper.query("hbss_protitlelevel", "id,nckd_dgwcj.id,nckd_djszc.id,nckd_dzyjndj.id", filtersQuery);
            for (DynamicObject object : objectCollection) {
                Long id = object.getLong("id");
                if (resultMap.get(id) == null) {
                    resultMap.put(id, object);
                }
            }
        }
        return resultMap;

    }

}
