package weaver.interfaces.mfkj.job;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.mfkj.util.HttpUtils;
import weaver.interfaces.schedule.BaseCronJob;

import java.util.*;

/**
 * @Title
 * @Author wangchaofa
 * @CreateDate 2023/8/12
 * @Version 1.0
 * @Description
 */
public class SynResumeJob extends BaseCronJob {


    BaseBean bb = new BaseBean();

    @Override
    public void execute() {
        bb.writeLog("========== start to syn resume info ==========");
        RecordSet rs = new RecordSet();
        RecordSet rs1 = new RecordSet();
        RecordSet rst = new RecordSet();
        RecordSet rscheck = new RecordSet();

        //企业编码
        String corpCode = bb.getPropValue("syn_othersys_mfkj","corpCode");
        //用户名称
        String userName = bb.getPropValue("syn_othersys_mfkj","userName");
        //加密密码
        String password = bb.getPropValue("syn_othersys_mfkj","password");
        //获取 token  url
        String token_url = bb.getPropValue("syn_othersys_mfkj","token_url");
        //
        String getUnEnterDuty_url = bb.getPropValue("syn_othersys_mfkj","getUnEnterDuty_url");
        //uf_dy_token   modeuuid
        String token_uuid = bb.getPropValue("syn_othersys_mfkj","token_uuid");

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("corpCode",corpCode);
        jsonObject.put("userName",userName);
        jsonObject.put("password",password);

        Map<String,Object> tokenMap = new HashMap<>();
        Map<String,String> headers = new HashMap<>();
        String encode = "utf-8";
        String token = "";
        String expire = "";

        Calendar cal1 = Calendar.getInstance();
        long now_time = cal1.getTimeInMillis();
        bb.writeLog("now_time",now_time);

        try {
            rst.executeQuery("select * from uf_dy_token where modeuuid='" + token_uuid + "'");
            rst.next();
            expire = Util.null2o(rst.getString("expire"));
            token = Util.null2o(rst.getString("token"));

            long timestamp = Long.parseLong(expire) * 1000;
            //token已过期，重新调用获取新的token
            if (now_time > timestamp) {
                tokenMap = HttpUtils.getTokenInfo(token_url, headers, jsonObject.toString(), encode);
                if (tokenMap.size() > 0) {
                    token = (String) tokenMap.get("token");
                    expire = (String) tokenMap.get("expire");
                    //更新token和有效时间戳
                    rs1.executeUpdate("update uf_dy_token set token='" + token + "',expire='" + expire + "' where modeuuid='" + token_uuid + "'");
                }
            }

            headers.put("Authorization", "Bearer "+token);

            JSONObject json = new JSONObject();

            json.put("rowSize","10");
            json.put("cType","2,4,400");
            json.put("vType","1");

            //请求数据
            String data = HttpUtils.getResumeInfo(getUnEnterDuty_url,headers,json.toString(),"UTF-8");
            bb.writeLog("data:  "+data);

            JSONObject json_data = JSONObject.parseObject(data);
            String resume = json_data.getString("resume");
            JSONArray jsonArray = JSONArray.parseArray(resume);
            bb.writeLog("resume:  "+jsonArray);


            for(int i=0;i<jsonArray.size();i++){
                bb.writeLog("job sync index:",i);

                String uuid = UUID.randomUUID().toString();
                String currentdate = TimeUtil.getCurrentDateString();
                String currenttime = TimeUtil.getOnlyCurrentTimeString();
                String currentdatetime = currentdate+" "+currenttime;
                int resume_formmodeid = Integer.parseInt(bb.getPropValue("syn_othersys_mfkj","resume_formmodeid"));
                int creater = 1;

                JSONObject jsonObject1 = jsonArray.getJSONObject(i);
                bb.writeLog("jsonObject1:  "+jsonObject1);
                String resumeContent = jsonObject1.getString("resumeContent");
                bb.writeLog("resumeContent:  "+resumeContent);
                JSONObject json_resumeContent = JSONObject.parseObject(resumeContent);

                //外部职位信息
                String responsibilities = "";
                String externalPostId = Util.null2String(jsonObject1.getString("externalPostId"));
                bb.writeLog("externalPostId:  "+externalPostId);
                if (StringUtils.isNotBlank(externalPostId)) {
                    //对应流程中获取岗位职责字段的值
                    String tableName = bb.getPropValue("syn_othersys_mfkj","recruitmentWorkflowName");
                    if (StringUtils.isNotBlank(tableName)) {
                        String acqResponSql = "select gwzz from " + tableName + " where requestid = ?";
                        rst.executeQuery(acqResponSql,externalPostId);
                        while (rst.next()) {
                            responsibilities = Util.null2String(rst.getString("gwzz"));
                        }
                    }
                }
                bb.writeLog("responsibilities:  "+responsibilities);

                String applyId = jsonObject1.getString("applyId");
                bb.writeLog("applyId:  "+applyId);

                String resumeId = jsonObject1.getString("resumeId");
                bb.writeLog("resumeId:  "+resumeId);

                //面试 评价
                boolean interviewFlag = true;
                String interviewEvaluation = jsonObject1.getString("interviewEvaluation");
                bb.writeLog("interviewEvaluation:  "+interviewEvaluation);
                if (StringUtils.isBlank(interviewEvaluation)) {
                    interviewFlag = false;
                }
                JSONArray array_interviewEvaluation = JSONArray.parseArray(interviewEvaluation);

                // 个人基本信息
                String personalInformation = json_resumeContent.getString("personalInformation");
                bb.writeLog("personalInformation:  "+personalInformation);
                JSONObject json_personalInformation = JSONObject.parseObject(personalInformation);

                //  求职意向
                String careerObjective = json_resumeContent.getString("careerObjective");
                bb.writeLog("careerObjective:  "+careerObjective);
                JSONObject json_careerObjective = JSONObject.parseObject(careerObjective);

                // 姓名
                String name = Util.null2String(json_personalInformation.getString("name"));
                //身份证号码
                String sfzhm = Util.null2String(json_personalInformation.getString("iDNumber"));
                // 英文名
                String englishName = Util.null2String(json_personalInformation.getString("englishName"));
                // 国籍
                String nation = Util.null2String(json_personalInformation.getString("Nationality"));
                // 国籍编码
                String nationCode = Util.null2String(json_personalInformation.getString("nationCode"));
                // 性别  0 男 1 女
                String gender = Util.null2String(json_personalInformation.getString("gender"));
                if("男".equals(gender)){
                    gender = "0";
                }else{
                    gender = "1";
                }
                // 邮箱地址
                String email = Util.null2String(json_personalInformation.getString("email"));
                // 手机号码
                String mobilePhone = Util.null2String(json_personalInformation.getString("mobilePhone"));
                // 现住址
                String currentCity = Util.null2String(json_personalInformation.getString("currentCity"));
                // 身份证地址
                String hukou = Util.null2String(json_personalInformation.getString("hukou"));
                // 婚姻情况 0 未婚  1 已婚已育  2 已婚未育
//                String maritalStatus = Util.null2String(json_personalInformation.getString("hunyuzhuangkuang"));
                String maritalStatus = Util.null2String(json_personalInformation.getString("maritalAndFertilityStatus"));
                if(maritalStatus.contains("未婚")){
                    maritalStatus = "0";
                }else if(maritalStatus.contains("已育")){
                    maritalStatus = "1";
                }else if(maritalStatus.contains("未育")){
                    maritalStatus = "2";
                }
                // 出生日期
                String dateOfBirth = Util.null2String(json_personalInformation.getString("dateOfBirth"));
                // 应聘职位
                String desiredPosition = Util.null2String(json_careerObjective.getString("desiredPosition"));
                bb.writeLog("desiredPosition: "+desiredPosition);
                // 最快到岗时间
                String dateAvailable = Util.null2String(json_personalInformation.getString("dateAvailable"));

                // 家庭关系  明细 1
                String familyRelationship = json_resumeContent.getString("familyRelationship");
                bb.writeLog("familyRelationship:  "+familyRelationship);
                JSONArray array_familyRelationship = JSONArray.parseArray(familyRelationship);

                // 教育经历  明细 2
                String educationBackground = json_resumeContent.getString("educationBackground");
                bb.writeLog("educationBackground:  "+educationBackground);
                JSONArray array_educationBackground = JSONArray.parseArray(educationBackground);

                // 工作经历  明细 3
                String workingExperience = json_resumeContent.getString("workingExperience");
                bb.writeLog("workingExperience:  "+workingExperience);
                JSONArray array_workingExperience = JSONArray.parseArray(workingExperience);

                // 过往经历证明  明细 4
                String employeeBackground = json_resumeContent.getString("employeeBackground");
                bb.writeLog("employeeBackground:  "+employeeBackground);
                JSONArray array_employeeBackground = JSONArray.parseArray(employeeBackground);

                // 薪资要求  明细 5
                String packageRequirements = json_resumeContent.getString("packageRequirements");
                bb.writeLog("packageRequirements:  "+packageRequirements);
                JSONObject json_packageRequirements = JSONObject.parseObject(packageRequirements);

                //语言能力  明细 6
                String language = json_resumeContent.getString("language");
                bb.writeLog("language:  "+language);
                JSONArray array_language = JSONArray.parseArray(language);

                // 综合资料
                String generalInformation = json_resumeContent.getString("generalInformation");
                bb.writeLog("generalInformation:  "+generalInformation);
                JSONObject json_generalInformation = JSONObject.parseObject(generalInformation);

                // 请简述你短期或长期工作目标  a
                String gongzuomubiao = Util.null2String(json_generalInformation.getString("gongzuomubiao"));

                // 请列明有助于您申请此职位的其他材料   b
                String qitacailiao = Util.null2String(json_generalInformation.getString("qitacailiao"));

                // 是否曾被起诉，或违反过有关国家法律   c     0 Y  1 N
                String weifanfalv = Util.null2String(json_generalInformation.getString("weifanfalv"));
                weifanfalv = "是".equals(weifanfalv) ? "0" : "1";

                // 您是否有传染性疾病，精神病、高血压或心脏病等较重病史    d     0 Y  1 N
                String chuanranjibing = Util.null2String(json_generalInformation.getString("chuanranjibing"));
                chuanranjibing = "是".equals(chuanranjibing) ? "0" : "1";

                //  请说明   d_2
                String qingshuoming = Util.null2String(json_generalInformation.getString("qingshuoming"));

                // 您是否有亲戚或朋友在本公司工作或工作过  e     0 Y  1 N
                String qinqizaigognsi = Util.null2String(json_generalInformation.getString("qinqizaigognsi"));
                qinqizaigognsi = "是".equals(qinqizaigognsi) ? "0" : "1";

                // 是否与上家公司有培训协议  f     0 Y  1 N
                String peixunxieyi = Util.null2String(json_generalInformation.getString("peixunxieyi"));
                peixunxieyi = "是".equals(peixunxieyi) ? "0" : "1";

                //  请详细说明   f_2
                String qingxiangxishuoming1 = Util.null2String(json_generalInformation.getString("qingxiangxishuoming1"));

                // 是否与上家公司有竞业限制责任  g   0 Y  1 N
                String jingyexieyi = Util.null2String(json_generalInformation.getString("jingyexieyi"));
                jingyexieyi = "是".equals(jingyexieyi) ? "0" : "1";

                // 是否与前股雇主有尚未结束的劳动争议   h     0 Y  1 N
                String laodongzhengyi = Util.null2String(json_generalInformation.getString("laodongzhengyi"));
                laodongzhengyi = "是".equals(laodongzhengyi) ? "0" : "1";

                rs.executeQuery("select * from uf_ygjlxxb where zwxm = ? and sjhm = ?",name,mobilePhone);
                int billid = -1;

                String insertSql = "INSERT INTO uf_ygjlxxb (gwzz, sfzhm, ypzw, zkdgsj, zwxm, ywxm, gj, " +
                        "xb, yxdz, sjhm, xzz, sfzdz," +
                        "hyqk, csrq, a, b, c, " +
                        "d, d2, e, f, g, g2," +
                        "h, applyid, resumeid, modedatacreater, modedatacreatedate, modedatacreatetime, formmodeid, modeuuid) " +
                        "VALUES (?, ?, ?, ?, ?, ?, ?, " +
                        "?, ?, ?, ?, ?," +
                        "?, ?, ?, ?, ?, " +
                        "?, ?, ?, ?, ?, ?," +
                        "?, ?, ?, ?, ?, ?, ?, ?)";


                String insertSql_dt1 = "INSERT INTO uf_ygjlxxb_dt1 (mainid, xm, gx2, lxfs, zy, dz, sfjjlxr, dybs) VALUES(?, ?, ?, ?, ?, ?, ?, ?)";

                String insertSql_dt2 = "INSERT INTO uf_ygjlxxb_dt2 (mainid, xx, zy, rxsj, bysj, xl, xllx, wyyz, yynl) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";

                String insertSql_dt3 = "INSERT INTO uf_ygjlxxb_dt3 (mainid, gzdw, gzkssj, gzjssj, zw, zhydxz, lzyy, gzdwdybs) VALUES(?, ?, ?, ?, ?, ?, ?, ?)";

                String insertSql_dt4 = "INSERT INTO uf_ygjlxxb_dt4 (mainid, gzdw, zmr, zw, lxfs) VALUES(?, ?, ?, ?, ?)";

                String insertSql_dt5 = "INSERT INTO uf_ygjlxxb_dt5 (mainid, mqxz, qwxzsq) VALUES(?, ?, ?)";

                String insertSql_dt6 = "INSERT INTO uf_ygjlxxb_dt6 (mainid, wyyz, yynl) VALUES(?, ?, ?)";

                //复试面试官~  沟通表达~  具体评价内容~  专业能力~  具体评价内容2~  思维逻辑~  具体评价内容3~  职业规划~  具体评价内容4~  面试综合评价~  面试总体评价~  面试轮次~
                String insertSql_dt7 = "INSERT INTO uf_ygjlxxb_dt7 (mainid, fsmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, mslc) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
                //初试面试官  沟通表达  具体评价内容  专业能力  具体评价内容2  思维逻辑  具体评价内容3  职业规划  具体评价内容4  面试综合评价  面试总体评价  面试轮次
                String insertSql_dt8 = "INSERT INTO uf_ygjlxxb_dt8 (mainid, csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, mslc) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

                //不存在，新增
                if(!rs.next()){
                    bb.writeLog("不存在，新增");
                    //写入 主表
                    boolean exeRes = rst.executeUpdate(insertSql,new Object[]{responsibilities,sfzhm,desiredPosition,dateAvailable,name,englishName,nation,
                            gender,email,mobilePhone,currentCity,hukou,
                            maritalStatus,dateOfBirth,gongzuomubiao,qitacailiao,weifanfalv,
                            chuanranjibing,qingshuoming,qinqizaigognsi,peixunxieyi,jingyexieyi,qingxiangxishuoming1,
                            laodongzhengyi,applyId,resumeId, creater, currentdate,currenttime,resume_formmodeid,uuid});
                    bb.writeLog("insertSql",insertSql);
                    bb.writeLog("insertSql",new Object[]{responsibilities,sfzhm,desiredPosition,dateAvailable,name,englishName,nation,
                            gender,email,mobilePhone,currentCity,hukou,
                            maritalStatus,dateOfBirth,gongzuomubiao,qitacailiao,weifanfalv,
                            chuanranjibing,qingshuoming,qinqizaigognsi,peixunxieyi,jingyexieyi,qingxiangxishuoming1,
                            laodongzhengyi,applyId,resumeId, creater, currentdate,currenttime,resume_formmodeid,uuid});
                    bb.writeLog("exeRes",exeRes);

                    if (exeRes) {
                        //重构权限
                        rs1.executeQuery(" select id from uf_ygjlxxb where modeuuid=? ",new Object[]{uuid});
                        rs1.next();
                        billid = rs1.getInt("id");
                        ModeRightInfo moderight = new ModeRightInfo();
                        moderight.editModeDataShare(creater, resume_formmodeid, billid);
                    }
                    // 明细1
                    for(int j=0;j<array_familyRelationship.size();j++) {
                        JSONObject jsonObject_family = array_familyRelationship.getJSONObject(j);

                        // 姓名
                        String name1 = Util.null2String(jsonObject_family.getString("name"));
                        // 关系
                        String relationship = Util.null2String(jsonObject_family.getString("relationship"));
                        // 联系方式
                        String contactNumber = Util.null2String(jsonObject_family.getString("phone"));
                        // 职业
                        String jobTitle = Util.null2String(jsonObject_family.getString("occupation"));
                        // 地址
                        String address = Util.null2String(jsonObject_family.getString("address"));
                        // 是否紧急联系人  0 是 1 否
                        String emergencyContact = Util.null2String(jsonObject_family.getString("emergencyContact"));
                        //大易标识
                        String uniqueKey = Util.null2String(jsonObject_family.getString("uniqueKey"));

                        if("是".equals(emergencyContact)){
                            emergencyContact = "0";
                        }else{
                            emergencyContact = "1";
                        }

                        if("配偶".equals(relationship)){
                            relationship = "0";
                        }else if("儿子".equals(relationship)){
                            relationship = "1";
                        }else if("女儿".equals(relationship)){
                            relationship = "2";
                        }else if("父亲".equals(relationship)){
                            relationship = "3";
                        }else if("母亲".equals(relationship)){
                            relationship = "4";
                        }else if("其他".equals(relationship)){
                            relationship = "5";
                        }else if("兄妹".equals(relationship)){
                            relationship = "6";
                        }else if("兄弟".equals(relationship)){
                            relationship = "7";
                        }else if("姐妹".equals(relationship)){
                            relationship = "8";
                        }else{
                            relationship = "9";
                        }

                        // 写入 明细1
                        rst.executeUpdate(insertSql_dt1,new Object[]{billid,name1,relationship,contactNumber,jobTitle,address,emergencyContact,uniqueKey});
                    }

                    // 明细2
                    for(int j=0;j<array_educationBackground.size();j++) {
                        JSONObject jsonObject_education = array_educationBackground.getJSONObject(j);

                        //学校
                        String schoolName = Util.null2String(jsonObject_education.getString("schoolName"));
                        //专业
                        String major = Util.null2String(jsonObject_education.getString("major"));
                        //入学时间
                        String startDate = Util.null2String(jsonObject_education.getString("startDate"));
                        //毕业时间
                        String endDate = Util.null2String(jsonObject_education.getString("endDate"));
                        //学历 0 初中及以下 1 中专 2 高中 3 大专 4 本科 5 硕士研究生 6 技校/职高 7 博士研究生
                        String diploma = Util.null2String(jsonObject_education.getString("diploma"));
                        if(diploma.contains("初中")){
                            diploma = "0";
                        }else if("中专".equals(diploma)){
                            diploma = "1";
                        }else if("高中".equals(diploma)){
                            diploma = "2";
                        }else if("大专".equals(diploma)){
                            diploma = "3";
                        }else if("本科".equals(diploma)){
                            diploma = "4";
                        }else if("硕士研究生".equals(diploma)){
                            diploma = "5";
                        }else if("技校/职高".equals(diploma)){
                            diploma = "6";
                        }else{
                            diploma = "7";
                        }
                        //学历类型  0 统招 1 自考 2 函授
                        String educationType = Util.null2String(jsonObject_education.getString("educationType"));
                        if("统招".equals(educationType)){
                            educationType = "0";
                        }else if("自考".equals(educationType)){
                            educationType = "1";
                        }else{
                            educationType = "2";
                        }
                        // 写入 明细2
                        rst.executeUpdate(insertSql_dt2,new Object[]{billid,schoolName,major,startDate,endDate,diploma,educationType,null,"0"});
                    }

                    // 明细3
                    for(int j=0;j<array_workingExperience.size();j++) {
                        JSONObject jsonObject_working = array_workingExperience.getJSONObject(j);

                        //工作单位
                        String companyName = Util.null2String(jsonObject_working.getString("companyName"));
                        //工作开始日期
                        String startDate = Util.null2String(jsonObject_working.getString("startDate"));
                        //工作结束日期
                        String endDate = Util.null2String(jsonObject_working.getString("endDate"));
                        //职位
                        String jobTitle = Util.null2String(jsonObject_working.getString("jobTitle"));
                        //最后月度薪资
                        String salaryMonthly = Util.null2String(jsonObject_working.getString("salaryMonthly"));
                        //离职原因
                        String reasonForQuit = Util.null2String(jsonObject_working.getString("reasonForQuit"));
                        //标识Key
                        String uniqueKey = Util.null2String(jsonObject_working.getString("uniqueKey"));

                        // 写入 明细3
                        rst.executeUpdate(insertSql_dt3,new Object[]{billid,companyName,startDate,endDate,jobTitle,salaryMonthly,reasonForQuit, uniqueKey});
                    }

                    // 明细4
                    for(int j=0;j<array_employeeBackground.size();j++) {
                        JSONObject jsonObject_employee = array_employeeBackground.getJSONObject(j);
                        //工作单位
                        String company = Util.null2String(jsonObject_employee.getString("company"));
                        //证明人
                        String referenceName = Util.null2String(jsonObject_employee.getString("referenceName"));
                        //职位
                        String position = Util.null2String(jsonObject_employee.getString("position"));
                        //联系电话
                        String contactNumber = Util.null2String(jsonObject_employee.getString("contactNumber"));

                        //写入 明细4
                        rst.executeUpdate(insertSql_dt4,new Object[]{billid,company,referenceName,position,contactNumber});
                    }

                    // 明细5

                    //目前薪资
                    String currentSalary = Util.null2String(json_packageRequirements.getString("currentSalary"));

                    //期望薪资
                    String expectedSalary = Util.null2String(json_packageRequirements.getString("expectedSalary"));

                    // 写入 明细5
                    rst.executeUpdate(insertSql_dt5,new Object[]{billid,currentSalary,expectedSalary});

                    // 明细6
                    for(int j=0;j<array_language.size();j++) {
                        JSONObject jsonObject_language = array_language.getJSONObject(j);
                        //外语语种
                        String languages = Util.null2String(jsonObject_language.getString("languages"));
                        //语言能力 0 很好 1 好 2 一般  3 较差
                        String languageAbility = Util.null2String(jsonObject_language.getString("languageAbility"));
                        if("很好".equals(languageAbility)){
                            languageAbility = "0";
                        }else if("好".equals(languageAbility)){
                            languageAbility = "1";
                        }else if("一般".equals(languageAbility)){
                            languageAbility = "2";
                        }else if("较差".equals(languageAbility)){
                            languageAbility = "3";
                        }
                        //写入 明细6
                        rst.executeUpdate(insertSql_dt6,new Object[]{billid,languages,languageAbility});
                    }

                    //明细7  复试  根据interviewType来确认初试和复试
                    if (interviewFlag) {
                        for(int j=0;j<array_interviewEvaluation.size();j++) {
                            JSONObject jsonObject_interviewEvaluation = array_interviewEvaluation.getJSONObject(j);
                            String round = jsonObject_interviewEvaluation.getString("round");//面试轮次
                            bb.writeLog("round: "+round);

                            String interviewType = jsonObject_interviewEvaluation.getString("interviewType");
                            bb.writeLog("interviewType: "+interviewType);

                            String interviewer = jsonObject_interviewEvaluation.getString("interviewer");
                            bb.writeLog("interviewer:  "+interviewer);
                            //                    out.print("新增--明细7:interviewer："+interviewer);

                            JSONArray array_interviewer = JSONArray.parseArray(interviewer);
                            for(int k=0;k<array_interviewer.size();k++) {
                                JSONObject jsonObject_interview = array_interviewer.getJSONObject(k);
                                //加校验
                                String summarySheetOfInterview = jsonObject_interview.getString("summarySheetOfInterview");
                                String pingjia = jsonObject_interview.getString("pingjia");
                                String interviewEmail = jsonObject_interview.getString("interviewEmail");
                                if (StringUtils.isNotBlank(summarySheetOfInterview)
                                        && StringUtils.isNotBlank(pingjia)
                                        && StringUtils.isNotBlank(interviewEmail)) {

                                    String msg_id = getUserid(interviewEmail);
                                    bb.writeLog("msg_id: " + msg_id);

                                    JSONObject json_summarySheetOfInterview = JSONObject.parseObject(summarySheetOfInterview);
                                    JSONObject json_pingjia = JSONObject.parseObject(pingjia);
                                    //                            if(!"1".equals(round)){
                                    if ("复试".equals(interviewType)) {
                                        String fsmsg = msg_id;
                                        String fsdf = json_summarySheetOfInterview.getString("comprehensiveEvaluationOfInterview");//面试综合评价
                                        String fspj = json_summarySheetOfInterview.getString("mianshizongtipingjia");//面试总体评价

                                        String jtpjnr = json_pingjia.getString("pingjia1");//具体评价内容1
                                        String jtpjnr2 = json_pingjia.getString("pingjia2");//具体评价内容2
                                        String jtpjnr3 = json_pingjia.getString("pingjia3");//具体评价内容3
                                        String jtpjnr4 = json_pingjia.getString("pingjia4");//具体评价内容4
                                        String gtbd = json_pingjia.getString("communicationAndExpression");//沟通表达
                                        String zynl = json_pingjia.getString("professionalCompetence");//专业能力
                                        String swlj = json_pingjia.getString("thinkingLogic");//思维逻辑
                                        String zygh = json_pingjia.getString("careerPlanning");//职业规划

                                        bb.writeLog("insertSql_dt7: " + insertSql_dt7);
                                        bb.writeLog("params: " + new Object[]{billid, fsmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, fsdf, fspj, round}.toString());

                                        // 写入 明细7
                                        rst.executeUpdate(insertSql_dt7, new Object[]{billid, fsmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, fsdf, fspj, round});
                                    }
                                }
                            }
                        }
                        bb.writeLog("明细8: ");
                        //明细8  初试  根据interviewType来确认初试和复试
                        for(int j=0;j<array_interviewEvaluation.size();j++) {

                            JSONObject jsonObject_interviewEvaluation = array_interviewEvaluation.getJSONObject(j);
                            String round = jsonObject_interviewEvaluation.getString("round");
                            bb.writeLog("round: "+round);

                            String interviewType = jsonObject_interviewEvaluation.getString("interviewType");
                            bb.writeLog("interviewType: "+interviewType);

                            String interviewer = jsonObject_interviewEvaluation.getString("interviewer");
                            bb.writeLog("interviewer:  "+interviewer);

                            JSONArray array_interviewer = JSONArray.parseArray(interviewer);
                            for(int k=0;k<array_interviewer.size();k++) {
                                JSONObject jsonObject_interview = array_interviewer.getJSONObject(k);
                                //summarySheetOfInterview
                                //加校验
                                String summarySheetOfInterview = jsonObject_interview.getString("summarySheetOfInterview");
                                bb.writeLog("summarySheetOfInterview: " + summarySheetOfInterview);

                                String pingjia = jsonObject_interview.getString("pingjia");
                                bb.writeLog("pingjia: " + pingjia);

                                String interviewEmail = jsonObject_interview.getString("interviewEmail");
                                bb.writeLog("interviewEmail: " + interviewEmail);

                                if (StringUtils.isNotBlank(summarySheetOfInterview)
                                        && StringUtils.isNotBlank(pingjia)
                                        && StringUtils.isNotBlank(interviewEmail)) {

                                    String msg_id = getUserid(interviewEmail);
                                    bb.writeLog("msg_id: " + msg_id);

                                    JSONObject json_summarySheetOfInterview = JSONObject.parseObject(summarySheetOfInterview);
                                    JSONObject json_pingjia = JSONObject.parseObject(pingjia);

                                    if ("初试".equals(interviewType)) {
                                        String csmsg = msg_id;
                                        String mszhpj = json_summarySheetOfInterview.getString("comprehensiveEvaluationOfInterview");//面试综合评价
                                        String msztpj = json_summarySheetOfInterview.getString("mianshizongtipingjia");//面试总体评价

                                        String jtpjnr = json_pingjia.getString("pingjia1");//具体评价内容1
                                        String jtpjnr2 = json_pingjia.getString("pingjia2");//具体评价内容2
                                        String jtpjnr3 = json_pingjia.getString("pingjia3");//具体评价内容3
                                        String jtpjnr4 = json_pingjia.getString("pingjia4");//具体评价内容4
                                        String gtbd = json_pingjia.getString("communicationAndExpression");//沟通表达
                                        String zynl = json_pingjia.getString("professionalCompetence");//专业能力
                                        String swlj = json_pingjia.getString("thinkingLogic");//思维逻辑
                                        String zygh = json_pingjia.getString("careerPlanning");//职业规划

                                        bb.writeLog("insertSql_dt8: " + insertSql_dt8);
                                        bb.writeLog("params: " + new Object[]{billid, csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, round}.toString());

                                        // 写入 明细8
                                        //csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, mslc
                                        rst.executeUpdate(insertSql_dt8, new Object[]{billid, csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, round});
                                    }
                                }
                            }
                        }
                    }

                }
                // 更新
                else{
                    bb.writeLog("更新: ");
                    billid = Util.getIntValue(rs.getString("id"));
                    bb.writeLog("billid: "+billid);

                    //更新 主表
                    String updateSql = "UPDATE uf_ygjlxxb SET sfzhm='"+sfzhm+"',ypzw='"+ desiredPosition +"', zkdgsj='"+ dateAvailable +"', zwxm='"+ name +"', ywxm='"+ englishName +"', gj='"+ nation +"', " +
                            "xb='"+ gender +"', yxdz='"+ email +"', sjhm='"+ mobilePhone +"', xzz='"+ currentCity +"', sfzdz='"+ hukou +"'," +
                            "hyqk='"+ maritalStatus +"', csrq='"+ dateOfBirth +"', a='"+ gongzuomubiao +"', b='"+ qitacailiao +"', c='"+ weifanfalv +"', " +
                            "d='"+ chuanranjibing +"', d2='"+ qingshuoming +"', e='"+ qinqizaigognsi +"', f='"+ peixunxieyi +"', g='"+ jingyexieyi +"', g2='"+ qingxiangxishuoming1 +"'," +
                            "h='"+ laodongzhengyi +"', " +
//                            "', csmsg='"+csmsg+"', csdf='"+csdf+"', cspj='"+cspj+"', fszhdf='"+fszhdf+"', " +   主表转明细表，废除
                            "applyid='"+ applyId +"',resumeId='"+ resumeId +"',modedatamodifier='"+ creater +"',modedatamodifydatetime='"+ currentdatetime +"', gwzz = '"+responsibilities+"' WHERE id="+ billid;

                    bb.writeLog("updateSql: "+updateSql);
                    //更新 主表
                    rst.executeUpdate(updateSql);

                    // 明细1
                    String acqFamilySql = "select count(*) as number from uf_ygjlxxb_dt1 where dybs = ?";
                    for(int j=0;j<array_familyRelationship.size();j++) {
                        JSONObject jsonObject_family = array_familyRelationship.getJSONObject(j);

                        // 姓名
                        String name1 = Util.null2String(jsonObject_family.getString("name"));
                        // 关系
                        String relationship = Util.null2String(jsonObject_family.getString("relationship"));
                        // 联系方式
                        String contactNumber = Util.null2String(jsonObject_family.getString("phone"));
                        // 职业
                        String jobTitle = Util.null2String(jsonObject_family.getString("occupation"));
                        // 地址
                        String address = Util.null2String(jsonObject_family.getString("address"));
                        // 是否紧急联系人  0 是 1 否
                        String emergencyContact = Util.null2String(jsonObject_family.getString("emergencyContact"));
                        //大易标识
                        String uniqueKey = Util.null2String(jsonObject_family.getString("uniqueKey"));

                        if("是".equals(emergencyContact)){
                            emergencyContact = "0";
                        }else{
                            emergencyContact = "1";
                        }

                        if("配偶".equals(relationship)){
                            relationship = "0";
                        }else if("儿子".equals(relationship)){
                            relationship = "1";
                        }else if("女儿".equals(relationship)){
                            relationship = "2";
                        }else if("父亲".equals(relationship)){
                            relationship = "3";
                        }else if("母亲".equals(relationship)){
                            relationship = "4";
                        }else if("其他".equals(relationship)){
                            relationship = "5";
                        }else if("兄妹".equals(relationship)){
                            relationship = "6";
                        }else if("兄弟".equals(relationship)){
                            relationship = "7";
                        }else if("姐妹".equals(relationship)){
                            relationship = "8";
                        }else{
                            relationship = "9";
                        }

                        String updateSql_dt1 = "UPDATE uf_ygjlxxb_dt1 SET gx2='"+ relationship +"',lxfs='"+ contactNumber +"',zy='"+ jobTitle +"',dz='"+ address +"',sfjjlxr='"+ emergencyContact +"', xm='" + name1 + "' WHERE mainid="+billid +" and dybs = '" + uniqueKey + "'";

                        rst.executeQuery(acqFamilySql, uniqueKey);
                        Integer number = -1;
                        while(rst.next()) {
                            number = Util.getIntValue(Util.null2String(rst.getString("number")));
                        }
                        if (number <= 0 ) {
                            rst.executeUpdate(insertSql_dt1, new Object[]{billid,name1,relationship,contactNumber,jobTitle,address,emergencyContact,uniqueKey});
                        } else {
                            // 更新 明细1
                            rst.executeUpdate(updateSql_dt1);
                        }
                    }

                    // 明细2
                    for(int j=0;j<array_educationBackground.size();j++) {
                        JSONObject jsonObject_education = array_educationBackground.getJSONObject(j);

                        //学校
                        String schoolName = Util.null2String(jsonObject_education.getString("schoolName"));
                        //专业
                        String major = Util.null2String(jsonObject_education.getString("major"));
                        //入学时间
                        String startDate = Util.null2String(jsonObject_education.getString("startDate"));
                        //毕业时间
                        String endDate = Util.null2String(jsonObject_education.getString("endDate"));
                        //学历 0 初中及以下 1 中专 2 高中 3 大专 4 本科 5 硕士研究生 6 技校/职高 7 博士研究生
                        String diploma = Util.null2String(jsonObject_education.getString("diploma"));
                        if(diploma.contains("初中")){
                            diploma = "0";
                        }else if("中专".equals(diploma)){
                            diploma = "1";
                        }else if("高中".equals(diploma)){
                            diploma = "2";
                        }else if("大专".equals(diploma)){
                            diploma = "3";
                        }else if("本科".equals(diploma)){
                            diploma = "4";
                        }else if("硕士研究生".equals(diploma)){
                            diploma = "5";
                        }else if("技校/职高".equals(diploma)){
                            diploma = "6";
                        }else{
                            diploma = "7";
                        }
                        //学历类型  0 统招 1 自考 2 函授
                        String educationType = Util.null2String(jsonObject_education.getString("educationType"));
                        if("统招".equals(educationType)){
                            educationType = "0";
                        }else if("自考".equals(educationType)){
                            educationType = "1";
                        }else{
                            educationType = "2";
                        }

                        String updateSql_dt2 = "UPDATE uf_ygjlxxb_dt2 SET zy='"+ major +"',rxsj='"+ startDate +"',bysj='"+ endDate +"',xl='"+ diploma +"',xllx='"+ educationType +"' where xx='"+ schoolName +"' and mainid="+billid;
                        //更新 明细2
                        rst.executeUpdate(updateSql_dt2);
                    }

                    // 明细3
                    //先获取所有工作经历的key
                    List<String> compKeys = new ArrayList<>();
                    String acqWorkExpSql = "select gzdwdybs from uf_ygjlxxb_dt3 where mainid = ? ";
                    bb.writeLog("acqWorkExpSql: "+acqWorkExpSql);
                    rst.executeQuery(acqWorkExpSql, billid);
                    while ( rst.next()) {
                        String gzdwdybs = Util.null2String(rst.getString("gzdwdybs"));
                        compKeys.add(gzdwdybs);
                    }
                    bb.writeLog("compKeys: "+compKeys);
                    for(int j=0;j<array_workingExperience.size();j++) {
                        JSONObject jsonObject_working = array_workingExperience.getJSONObject(j);

                        //工作单位
                        String companyName = Util.null2String(jsonObject_working.getString("companyName"));
                        bb.writeLog("companyName: "+companyName);
                        //工作开始日期
                        String startDate = Util.null2String(jsonObject_working.getString("startDate"));
                        bb.writeLog("startDate: "+startDate);
                        //工作结束日期
                        String endDate = Util.null2String(jsonObject_working.getString("endDate"));
                        bb.writeLog("endDate: "+endDate);
                        //职位
                        String jobTitle = Util.null2String(jsonObject_working.getString("jobTitle"));
                        bb.writeLog("jobTitle: "+jobTitle);
                        //最后月度薪资
                        String salaryMonthly = Util.null2String(jsonObject_working.getString("salaryMonthly"));
                        bb.writeLog("salaryMonthly: "+salaryMonthly);
                        //离职原因
                        String reasonForQuit = Util.null2String(jsonObject_working.getString("reasonForQuit"));
                        bb.writeLog("reasonForQuit: "+reasonForQuit);
                        //标识Key
                        String uniqueKey = Util.null2String(jsonObject_working.getString("uniqueKey"));
                        bb.writeLog("uniqueKey: "+uniqueKey);

                        if (compKeys.contains(uniqueKey)) {
                            String updateSql_dt3 = "UPDATE uf_ygjlxxb_dt3 SET gzkssj='"+ startDate +"',gzjssj='"+ endDate +"',zw='"+ jobTitle +"',zhydxz='"+ salaryMonthly +"',lzyy='"+ reasonForQuit +"', gzdw = '" + companyName +"'  where gzdwdybs = '" + uniqueKey +"'";
                            bb.writeLog("updateSql_dt3: "+updateSql_dt3);
                            //更新 明细3
                            rst.executeUpdate(updateSql_dt3);
                        } else {
                            // 写入 明细3
                            rst.executeUpdate(insertSql_dt3,new Object[]{billid,companyName,startDate,endDate,jobTitle,salaryMonthly,reasonForQuit, uniqueKey});
                        }


                    }

                    // 明细4
                    for(int j=0;j<array_employeeBackground.size();j++) {
                        JSONObject jsonObject_employee = array_employeeBackground.getJSONObject(j);
                        //工作单位
                        String company = Util.null2String(jsonObject_employee.getString("company"));
                        //证明人
                        String referenceName = Util.null2String(jsonObject_employee.getString("referenceName"));
                        //职位
                        String position = Util.null2String(jsonObject_employee.getString("position"));
                        //联系电话
                        String contactNumber = Util.null2String(jsonObject_employee.getString("contactNumber"));

                        String updateSql_dt4 = "UPDATE uf_ygjlxxb_dt4 SET zmr='"+ referenceName +"',zw='"+ position +"',lxfs='"+ contactNumber +"' where gzdw='"+ company +"' and mainid="+billid;

                        //更新 明细4
                        rst.executeUpdate(updateSql_dt4);
                    }

                    // 明细5

                    //目前薪资
                    String currentSalary = Util.null2String(json_packageRequirements.getString("currentSalary"));

                    //期望薪资
                    String expectedSalary = Util.null2String(json_packageRequirements.getString("expectedSalary"));

                    String updateSql_dt5 = "UPDATE uf_ygjlxxb_dt5 SET mqxz='"+ currentSalary +"',qwxzsq='"+ expectedSalary +"' where mainid="+billid;
                    //更新 明细5
                    rst.executeUpdate(updateSql_dt5);

                    // 明细6
                    for(int j=0;j<array_language.size();j++) {
                        JSONObject jsonObject_language = array_language.getJSONObject(j);
                        //外语语种
                        String languages = Util.null2String(jsonObject_language.getString("languages"));
                        //语言能力 0 很好 1 好 2 一般  3 较差
                        String languageAbility = Util.null2String(jsonObject_language.getString("languageAbility"));
                        if("很好".equals(languageAbility)){
                            languageAbility = "0";
                        }else if("好".equals(languageAbility)){
                            languageAbility = "1";
                        }else if("一般".equals(languageAbility)){
                            languageAbility = "2";
                        }else if("较差".equals(languageAbility)){
                            languageAbility = "3";
                        }

                        String updateSql_dt6 = "UPDATE uf_ygjlxxb_dt6 SET wyyz='"+ languages +"',yynl='"+ languageAbility +"' where mainid="+billid;
                        //更新 明细6
                        rst.executeUpdate(updateSql_dt6);
                    }

                    bb.writeLog("明细7");
                    //明细7
                    if ( interviewFlag ) {
                        for(int j=0;j<array_interviewEvaluation.size();j++) {
                            JSONObject jsonObject_interviewEvaluation = array_interviewEvaluation.getJSONObject(j);
                            String round = jsonObject_interviewEvaluation.getString("round");//面试轮次
                            bb.writeLog("round: "+round);

                            String interviewType = jsonObject_interviewEvaluation.getString("interviewType");
                            bb.writeLog("interviewType: "+interviewType);

                            String interviewer = jsonObject_interviewEvaluation.getString("interviewer");
                            bb.writeLog("interviewer:  "+interviewer);

                            JSONArray array_interviewer = JSONArray.parseArray(interviewer);
                            for(int k=0;k<array_interviewer.size();k++) {
                                JSONObject jsonObject_interview = array_interviewer.getJSONObject(k);
                                String isForCc = jsonObject_interview.getString("isForCc");

                                //加校验
                                String summarySheetOfInterview = jsonObject_interview.getString("summarySheetOfInterview");
                                String pingjia = jsonObject_interview.getString("pingjia");
                                String interviewEmail = jsonObject_interview.getString("interviewEmail");
                                if (StringUtils.isNotBlank(summarySheetOfInterview)
                                        && StringUtils.isNotBlank(pingjia)
                                        && StringUtils.isNotBlank(interviewEmail)) {

                                    if (isForCc.equals("1")) {

                                        String msg_id = getUserid(interviewEmail);
                                        bb.writeLog("msg_id: " + msg_id);

                                        JSONObject json_summarySheetOfInterview = JSONObject.parseObject(summarySheetOfInterview);
                                        JSONObject json_pingjia = JSONObject.parseObject(pingjia);

                                        if ("复试".equals(interviewType)) {
                                            String fsmsg = msg_id;
                                            String mszhpj = json_summarySheetOfInterview.getString("comprehensiveEvaluationOfInterview");//面试综合评价
                                            String msztpj = json_summarySheetOfInterview.getString("mianshizongtipingjia");//面试总体评价

                                            String jtpjnr = json_pingjia.getString("pingjia1");//具体评价内容1
                                            String jtpjnr2 = json_pingjia.getString("pingjia2");//具体评价内容2
                                            String jtpjnr3 = json_pingjia.getString("pingjia3");//具体评价内容3
                                            String jtpjnr4 = json_pingjia.getString("pingjia4");//具体评价内容4
                                            String gtbd = json_pingjia.getString("communicationAndExpression");//沟通表达
                                            String zynl = json_pingjia.getString("professionalCompetence");//专业能力
                                            String swlj = json_pingjia.getString("thinkingLogic");//思维逻辑
                                            String zygh = json_pingjia.getString("careerPlanning");//职业规划

                                            String updateSql_dt7 = "UPDATE uf_ygjlxxb_dt7 SET " +
                                                    "fsmsg='" + fsmsg + "', gtbd = '" + gtbd + "', jtpjnr='" + jtpjnr + "', zynl='" + zynl + "', jtpjnr2 = '" + jtpjnr2 + "'," +
                                                    "swlj = '" + swlj + "', jtpjnr3 = '" + jtpjnr3 + "',zygh = '" + zygh + "',jtpjnr4 = '" + jtpjnr4 + "',mszhpj = '" + mszhpj + "', " +
                                                    "msztpj = '" + msztpj + "', mslc = '" + round + "' " +
                                                    "where mainid=" + billid + " and mslc = '" + round + "' and fsmsg='" + fsmsg + "' ";

                                            Integer numberDt7 = -1;
                                            String checkDt7NumberSql = "select count(*) as number from uf_ygjlxxb_dt7 where mainid = ? and mslc = ? and fsmsg = ?";
                                            bb.writeLog("checkDt7NumberSql: " + checkDt7NumberSql);

                                            rscheck.executeQuery(checkDt7NumberSql, billid, round, fsmsg);
                                            while (rscheck.next()) {
                                                numberDt7 = Util.getIntValue(Util.null2String(rscheck.getString("number")));
                                            }
                                            bb.writeLog("numberDt7: " + numberDt7);

                                            if (numberDt7 < 1) {
                                                bb.writeLog("insertSql_dt7: " + insertSql_dt7);
                                                rst.executeUpdate(insertSql_dt7, billid, fsmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, round);
                                            } else {
                                                // 写入 明细7
                                                bb.writeLog("billid: " + billid);
                                                bb.writeLog("updateSql_dt7: " + updateSql_dt7);

                                                rst.executeUpdate(updateSql_dt7);
                                            }

                                        }
                                    }
                                }
                            }
                        }

                        //明细8
                        for(int j=0;j<array_interviewEvaluation.size();j++) {

                            JSONObject jsonObject_interviewEvaluation = array_interviewEvaluation.getJSONObject(j);

                            String round = jsonObject_interviewEvaluation.getString("round");

                            String interviewType = jsonObject_interviewEvaluation.getString("interviewType");

                            String interviewer = jsonObject_interviewEvaluation.getString("interviewer");

                            JSONArray array_interviewer = JSONArray.parseArray(interviewer);

                            for(int k=0;k<array_interviewer.size();k++) {

                                JSONObject jsonObject_interview = array_interviewer.getJSONObject(k);
                                String isForCc = jsonObject_interview.getString("isForCc");
                                //加校验
                                String summarySheetOfInterview = jsonObject_interview.getString("summarySheetOfInterview");
                                String pingjia = jsonObject_interview.getString("pingjia");
                                String interviewEmail = jsonObject_interview.getString("interviewEmail");
                                if (StringUtils.isNotBlank(summarySheetOfInterview)
                                        && StringUtils.isNotBlank(pingjia)
                                        && StringUtils.isNotBlank(interviewEmail)) {
                                    if (isForCc.equals("1")) {

                                        String msg_id = getUserid(interviewEmail);
                                        JSONObject json_summarySheetOfInterview = JSONObject.parseObject(summarySheetOfInterview);
                                        JSONObject json_pingjia = JSONObject.parseObject(pingjia);

                                        if ("初试".equals(interviewType)) {
                                            String csmsg = msg_id;
                                            String mszhpj = json_summarySheetOfInterview.getString("comprehensiveEvaluationOfInterview");//面试综合评价
                                            String msztpj = json_summarySheetOfInterview.getString("mianshizongtipingjia");//面试总体评价

                                            String jtpjnr = json_pingjia.getString("pingjia1");//具体评价内容1
                                            String jtpjnr2 = json_pingjia.getString("pingjia2");//具体评价内容2
                                            String jtpjnr3 = json_pingjia.getString("pingjia3");//具体评价内容3
                                            String jtpjnr4 = json_pingjia.getString("pingjia4");//具体评价内容4
                                            String gtbd = json_pingjia.getString("communicationAndExpression");//沟通表达
                                            String zynl = json_pingjia.getString("professionalCompetence");//专业能力
                                            String swlj = json_pingjia.getString("thinkingLogic");//思维逻辑
                                            String zygh = json_pingjia.getString("careerPlanning");//职业规划

                                            String updateSql_dt8 = "UPDATE uf_ygjlxxb_dt8 SET " +
                                                    "csmsg='" + csmsg + "', gtbd = '" + gtbd + "', jtpjnr='" + jtpjnr + "', zynl='" + zynl + "', jtpjnr2 = '" + jtpjnr2 + "'," +
                                                    "swlj = '" + swlj + "', jtpjnr3 = '" + jtpjnr3 + "',zygh = '" + zygh + "',jtpjnr4 = '" + jtpjnr4 + "',mszhpj = '" + mszhpj + "', " +
                                                    "msztpj = '" + msztpj + "', mslc = '" + round + "' " +
                                                    "where mainid=" + billid + " and mslc = '" + round + "' and csmsg='" + csmsg + "'";

                                            Integer numberDt8 = -1;
                                            String checkDt8NumberSql = "select count(*) as number from uf_ygjlxxb_dt8 where mainid = ? and mslc = ? and csmsg = ?";
                                            bb.writeLog("checkDt8NumberSql: " + checkDt8NumberSql);

                                            rscheck.executeQuery(checkDt8NumberSql, billid, round, csmsg);
                                            while (rscheck.next()) {
                                                numberDt8 = Util.getIntValue(Util.null2String(rscheck.getString("number")));
                                            }
                                            bb.writeLog("numberDt8: " + numberDt8);

                                            if (numberDt8 < 1) {
                                                rst.executeUpdate(insertSql_dt8, billid, csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, round);
                                            } else {
                                                // 写入 明细8
                                                bb.writeLog("==========================注意啦！！！==================");
                                                bb.writeLog("billid: " + billid);
                                                bb.writeLog("updateSql_dt8: " + updateSql_dt8);

                                                rst.executeUpdate(updateSql_dt8);
                                                bb.writeLog("==========================结束啦！！！==================");
                                            }
                                        }
                                    }
                                }

                            }
                        }
                    }

                }

            }

        }catch (Exception e){
            e.printStackTrace();
            bb.writeLog("SyResumeJob Exception: " + e);
        }
        bb.writeLog("========== end to syn resume info ==========");
    }

    public static String getUserid(String email){
        String result = "";
        RecordSet rs = new RecordSet();
        rs.executeQuery("select * from hrmresource where email='"+ email +"'");
        if(rs.next()){
            result = Util.null2String(rs.getString("id"));
        }
        return result;
    }
}
