package com.engine.resumestorage.service.impl; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.engine.core.exception.ECException; import com.engine.core.impl.Service; import com.engine.resumestorage.service.ResumeIdentifyService; import com.engine.resumestorage.util.ParseResumeQliUtil; import com.engine.resumestorage.util.Sql; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.conn.RecordSetTrans; import weaver.docs.docs.DocCoder; import weaver.docs.docs.DocComInfo; import weaver.docs.docs.DocImageManager; import weaver.docs.docs.DocManager; import weaver.file.ImageFileManager; import weaver.formmode.setup.ModeRightInfo; import weaver.general.BaseBean; import weaver.general.TimeUtil; import weaver.general.Util; import weaver.hrm.User; import weaver.integration.logging.Logger; import weaver.integration.logging.LoggerFactory; import java.util.*; public class ResumeIdentifyServiceImpl extends Service implements ResumeIdentifyService { private final Logger log = LoggerFactory.getLogger(ResumeIdentifyService.class); BaseBean bb = new BaseBean(); String formmodeid_tmp; String sfsymr; public ResumeIdentifyServiceImpl() { this.formmodeid_tmp = this.bb.getPropValue("resume_qianliling", "model.id"); this.sfsymr = this.bb.getPropValue("resume_qianliling", "sfsymr"); } @Override public Map saveResumeByImageFileId(int imageFileId) throws Exception { Map returnMap = new HashMap<>(); String response = ParseResumeQliUtil.doParseHostPost(imageFileId); this.log.info("千里聆接口返回值:" + response); if (response.length() == 0) { this.log.info("调用千里零接口失败,返回值为空"); throw new Exception("调用千里零接口失败,返回值为空"); } else { JSONObject all = JSONObject.parseObject(response); if (!all.getBoolean("isSuccess")) { this.log.info("调用千里零接口失败,接口不通"); throw new Exception("调用千里零接口失败,接口不通"); } else { JSONObject resultall = all.getJSONObject("data"); String status = resultall.getString("state"); if ("fail".equals(status)) { this.log.info("调用千里零接口失败,失败原因:" + resultall.getString("info")); throw new Exception("调用千里零接口失败,失败原因:" + resultall.getString("info")); } else { JSONObject result = resultall.getJSONObject("result"); Map saveResume = this.parseJsonToMap(result, imageFileId); int id = saveResumeInDB(saveResume); returnMap.put("id", id); Map jsonMap = new HashMap<>(); Set stringSet = result.keySet(); for (String key : stringSet) { Object value = result.get(key); if ("V2".equals(key)) { continue; } jsonMap.put(key, parseJsonString(value)); } returnMap.put("json", jsonMap); return returnMap; } } } } private String parseJsonString(Object value) { if (value instanceof JSONArray) { List list = new ArrayList<>(); JSONArray jsonArray = (JSONArray) value; for (int i = 0; i < jsonArray.size(); i++) { Object obj = jsonArray.get(i); String s = parseJsonString(obj); if (StringUtils.isBlank(s)) { continue; } list.add(s); } return StringUtils.join(list, "\n"); } else if (value instanceof JSONObject) { JSONObject jsonObject = (JSONObject) value; Set stringSet = jsonObject.keySet(); StringBuilder sb = new StringBuilder(); for (String key : stringSet) { String objValue = jsonObject.getString(key).replaceAll("\\n", "\n\t"); sb.append(key).append(":").append(objValue).append("\n"); } return sb.toString(); } else if (value instanceof String) { return value.toString(); } return ""; } @Override public int saveResumeInDB(Map map) { String tablename = "uf_jg_rmk"; if ("1".equals(this.sfsymr)) { tablename = this.bb.getPropValue("resume_qianliling", "jlk.tablename"); } Map mainTableMap = (Map) map.get("mainTable"); Map>> detailMap = (Map>>) map.get("detailTable"); RecordSetTrans rst = new RecordSetTrans(); rst.setAutoCommit(false); List field = new ArrayList<>(); List value1 = new ArrayList<>(); List value = new ArrayList<>(); mainTableMap.forEach((key, v) -> { if (StringUtils.isNotEmpty(v)) { field.add(key); value.add(v); value1.add("?"); } }); String sql = "insert into " + tablename + "(" + String.join(",", field) + ") values(" + String.join(",", value1) + ")"; this.log.error("test--------------------"); this.log.error(sql); this.log.error("test--------------------"); try { boolean flag = rst.executeUpdate(sql, value); if (flag) { String idSql = "SELECT max(id) as mid from " + tablename; String id = Sql.querySingleField(idSql, "mid"); this.permissionReconstruction(Util.getIntValue(id)); // 插入明细表数据 List> workList = detailMap.get("gzjl"); insertDetailTableData(rst, workList, tablename + "_dt1", id); List> studyList = detailMap.get("jyjl"); insertDetailTableData(rst, studyList, tablename + "_dt2", id); rst.commit(); return Integer.parseInt(id); } else { return -1; } } catch (Exception var11) { var11.printStackTrace(); rst.rollback(); this.log.error(var11); throw new ECException("简历更新失败"); } } @Override public Map queryByDBId(String resumeid) { String tablename = "uf_jg_rmk"; if ("1".equals(this.sfsymr)) { tablename = this.bb.getPropValue("youyun", "tablename"); } String sql = "select * from " + tablename + " where id=" + resumeid; return Sql.querySingleRow(sql); } @Override public boolean deleteById(String resumeid) throws Exception { String tablename = "uf_jg_rmk"; if ("1".equals(this.sfsymr)) { tablename = this.bb.getPropValue("youyun", "tablename"); } String sql = "delete " + tablename + " where id=" + resumeid; RecordSetTrans rst = new RecordSetTrans(); rst.setAutoCommit(false); try { rst.executeUpdate(sql); rst.commit(); return true; } catch (Exception var6) { rst.rollback(); throw new Exception(var6); } } private void permissionReconstruction(int billId) { ModeRightInfo ModeRightInfo = new ModeRightInfo(); ModeRightInfo.setNewRight(true); ModeRightInfo.editModeDataShare(1, Util.getIntValue(this.formmodeid_tmp), billId); } private Map parseJsonToMap(JSONObject obj, int imageFileId) { Map returnMap = new HashMap<>(); Map rs = new HashMap<>(); if ("1".equals(this.sfsymr)) { String v; if (obj.containsKey("姓名")) { v = this.bb.getPropValue("resume_qianliling", "rmxm"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "rmxm"), this.parseArray(obj.getJSONArray("姓名"))); } } if (obj.containsKey("性别")) { v = this.bb.getPropValue("resume_qianliling", "xb"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "xb"), "男".equals(this.parseArray(obj.getJSONArray("性别"))) ? "0" : "1"); } } if (obj.containsKey("出生日期")) { v = this.bb.getPropValue("resume_qianliling", "csrq"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "csrq"), this.parseArray(obj.getJSONArray("出生日期"))); } } if (obj.containsKey("籍贯")) { v = this.bb.getPropValue("resume_qianliling", "jg"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "jg"), this.parseArray(obj.getJSONArray("籍贯"))); } } if (obj.containsKey("手机号")) { v = this.bb.getPropValue("resume_qianliling", "sjhm"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "sjhm"), this.parseArray(obj.getJSONArray("手机号"))); } } if (obj.containsKey("电子邮箱")) { v = this.bb.getPropValue("resume_qianliling", "email"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "email"), this.parseArray(obj.getJSONArray("电子邮箱"))); } } if (obj.containsKey("微信")) { v = this.bb.getPropValue("resume_qianliling", "wx"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "wx"), this.parseArray(obj.getJSONArray("微信"))); } } if (obj.containsKey("QQ")) { v = this.bb.getPropValue("resume_qianliling", "qq"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "qq"), this.parseArray(obj.getJSONArray("QQ"))); } } if (obj.containsKey("现居住地")) { v = this.bb.getPropValue("resume_qianliling", "jzd"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "jzd"), this.parseArray(obj.getJSONArray("现居住地"))); } } if (obj.containsKey("爱好")) { v = this.bb.getPropValue("resume_qianliling", "ah"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "ah"), this.parseArray(obj.getJSONArray("爱好"))); } } if (obj.containsKey("个人评价")) { v = this.bb.getPropValue("resume_qianliling", "grpj"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "grpj"), this.parseArray(obj.getJSONArray("个人评价"))); } } if (obj.containsKey("毕业时间")) { v = this.bb.getPropValue("resume_qianliling", "bysj"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "bysj"), this.parseArray(obj.getJSONArray("毕业时间"))); } } if (obj.containsKey("最高学历")) { v = this.bb.getPropValue("resume_qianliling", "zgxl"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "zgxl"), this.parseArray(obj.getJSONArray("最高学历"))); } } if (obj.containsKey("最高学位")) { v = this.bb.getPropValue("resume_qianliling", "zgxw"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "zgxw"), this.parseArray(obj.getJSONArray("最高学位"))); } } if (obj.containsKey("专业技能")) { v = this.bb.getPropValue("resume_qianliling", "zyjn"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "zyjn"), this.parseArray(obj.getJSONArray("专业技能"))); } } if (obj.containsKey("专业")) { v = this.bb.getPropValue("resume_qianliling", "zy"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "zy"), this.parseArray(obj.getJSONArray("专业"))); } } if (obj.containsKey("实习经历")) { v = this.bb.getPropValue("resume_qianliling", "sxjl"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "sxjl"), this.parseArray(obj.getJSONArray("实习经历"))); } } if (obj.containsKey("英语水平")) { v = this.bb.getPropValue("resume_qianliling", "yysp"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "yysp"), this.parseArray(obj.getJSONArray("英语水平"))); } } if (obj.containsKey("技能证书")) { v = this.bb.getPropValue("resume_qianliling", "jnzs"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "jnzs"), this.parseArray(obj.getJSONArray("技能证书"))); } } if (obj.containsKey("校园经历")) { v = this.bb.getPropValue("resume_qianliling", "xyjl"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "xyjl"), this.parseArray(obj.getJSONArray("校园经历"))); } } if (obj.containsKey("期望从事岗位")) { v = this.bb.getPropValue("resume_qianliling", "qwcsgw"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "qwcsgw"), this.parseArray(obj.getJSONArray("期望从事岗位"))); } } if (obj.containsKey("工作经验")) { v = this.bb.getPropValue("resume_qianliling", "gzjy1"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "gzjy1"), this.parseArray(obj.getJSONArray("工作经验"))); } } if (obj.containsKey("期望薪资")) { v = this.bb.getPropValue("resume_qianliling", "qwxz"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "qwxz"), this.parseArray(obj.getJSONArray("期望薪资"))); } } if (obj.containsKey("期望工作地点")) { v = this.bb.getPropValue("resume_qianliling", "qwgzdd"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "qwgzdd"), this.parseArray(obj.getJSONArray("期望工作地点"))); } } if (obj.containsKey("项目经历")) { v = this.bb.getPropValue("resume_qianliling", "xmjl"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "xmjl"), this.parseArray(obj.getJSONArray("项目经历"))); } } if (obj.containsKey("年龄")) { v = this.bb.getPropValue("resume_qianliling", "nl"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "nl"), this.parseArray(obj.getJSONArray("年龄"))); } } // 二开 处理明细表数据、补充主表数据 Map>> detailMap = new HashMap<>(); if (obj.containsKey("v2")) { JSONObject v2 = obj.getJSONObject("v2"); if(v2.containsKey("工作经历")) { JSONArray gzjl = v2.getJSONArray("工作经历"); List> workList = new ArrayList<>(); if (null != gzjl && gzjl.size() > 0) { //for (int i = 0; i < gzjl.size(); i++) { // 客户要求只要显示第一行明细记录 JSONObject o = (JSONObject) gzjl.get(0); Map workMap = new HashMap<>(); // 工作单位 workMap.put("gzdw", o.getString("工作单位")); // 岗位名称 workMap.put("gwmc", o.getString("岗位名称")); // 工作经历 workMap.put("gzjl", o.getString("工作内容")); // 工作年限 workMap.put("gznx", o.getString("工作时间")); // 工作经验 workMap.put("gzjy", o.getString("每段工作持续时间")); workList.add(workMap); //} } detailMap.put("gzjl", workList); } } if (obj.containsKey("学业信息")) { JSONArray jyjl = obj.getJSONArray("学业信息"); List> studyList = new ArrayList<>(); if (null != jyjl && jyjl.size() > 0) { for (int i = 0; i < jyjl.size(); i++) { JSONObject o = (JSONObject) jyjl.get(i); Map studyMap = new HashMap<>(); // 毕业院校 studyMap.put("byyx", o.getString("院校")); // 就读时期 String jdsq = o.getString("就读时期"); studyMap.put("jdsq", jdsq); // 专业 studyMap.put("zy", o.getString("专业")); // 学历 studyMap.put("xl", o.getString("学历")); // 学位 studyMap.put("xw", o.getString("学位")); // 毕业时间 String[] split = jdsq.split("-"); if (split.length == 2) { studyMap.put("bysj", split[1]); } studyList.add(studyMap); } } detailMap.put("jyjl", studyList); if (CollectionUtils.isNotEmpty(studyList)) { Map lastMap = studyList.get(0); Map firstMap = studyList.get(studyList.size() - 1); // 完善主表信息 // 第一学历 String xl = firstMap.get("xl"); String xlId = getEducationLevelId(xl); rs.put("dyxl", xlId); // 第一学位 rs.put("dyxw", firstMap.get("xw")); // 第一学历专业 rs.put("dyxlzy", firstMap.get("zy")); // 第一学历就读时期 rs.put("dyxljdsq", firstMap.get("jdsq")); // 第一学历毕业时间 rs.put("dyxlbysj", getFormatDate(firstMap.get("bysj"))); // 第一学历毕业院校 rs.put("dyxlbyyx", firstMap.get("byyx")); // 最高学历就读时期 rs.put("zgxljdsq", lastMap.get("jdsq")); // 最高学历毕业时间 rs.put("zgxlbysj", lastMap.get("bysj")); // 最高学历毕业院校 rs.put("zgxlbyyx", lastMap.get("byyx")); // 最高学历专业 rs.put("zgxlzy", lastMap.get("zy")); // 最高学历 String zgxl = lastMap.get("xl"); rs.put("zgxl", zgxl); // 最高学位 rs.put("zgxw", lastMap.get("xw")); // 原始简历ID int secCategory = Convert.toInt(bb.getPropValue("resume_qianliling", "RESUMES_CATEGORY")); int docId = createDocId(secCategory, imageFileId, user); rs.put("jlfj", Convert.toStr(docId)); } } returnMap.put("mainTable", rs); returnMap.put("detailTable", detailMap); } else { if (obj.containsKey("姓名")) { rs.put("rmxm", this.parseArray(obj.getJSONArray("姓名"))); } if (obj.containsKey("性别")) { rs.put("xb", "男".equals(this.parseArray(obj.getJSONArray("性别"))) ? "0" : "1"); } if (obj.containsKey("出生日期")) { rs.put("csrq", this.parseArray(obj.getJSONArray("出生日期"))); } if (obj.containsKey("籍贯")) { rs.put("jg", this.parseArray(obj.getJSONArray("籍贯"))); } if (obj.containsKey("手机号")) { rs.put("sjhm", this.parseArray(obj.getJSONArray("手机号"))); } if (obj.containsKey("电子邮箱")) { rs.put("email", this.parseArray(obj.getJSONArray("电子邮箱"))); } if (obj.containsKey("微信")) { rs.put("wx", this.parseArray(obj.getJSONArray("微信"))); } if (obj.containsKey("QQ")) { rs.put("qq", this.parseArray(obj.getJSONArray("QQ"))); } if (obj.containsKey("现居住地")) { rs.put("jzd", this.parseArray(obj.getJSONArray("现居住地"))); } if (obj.containsKey("爱好")) { rs.put("ah", this.parseArray(obj.getJSONArray("爱好"))); } if (obj.containsKey("个人评价")) { rs.put("grpj", this.parseArray(obj.getJSONArray("个人评价"))); } if (obj.containsKey("学业信息")) { rs.put("xyxg", obj.getJSONArray("学业信息").toJSONString()); } if (obj.containsKey("毕业时间")) { rs.put("bysj", this.parseArray(obj.getJSONArray("毕业时间"))); } if (obj.containsKey("最高学历")) { rs.put("zgxlwb", this.parseArray(obj.getJSONArray("最高学历"))); } if (obj.containsKey("最高学位")) { rs.put("zgxw", this.parseArray(obj.getJSONArray("最高学位"))); } if (obj.containsKey("专业技能")) { rs.put("zyjn", this.parseArray(obj.getJSONArray("专业技能"))); } if (obj.containsKey("实习经历")) { rs.put("sxjl", this.parseArray(obj.getJSONArray("实习经历"))); } if (obj.containsKey("英语水平")) { rs.put("yysp", this.parseArray(obj.getJSONArray("英语水平"))); } if (obj.containsKey("技能证书")) { rs.put("jnzs", this.parseArray(obj.getJSONArray("技能证书"))); } if (obj.containsKey("校园经历")) { rs.put("xyjl", this.parseArray(obj.getJSONArray("校园经历"))); } if (obj.containsKey("工作信息")) { rs.put("gzxg", obj.getJSONArray("工作信息").toJSONString()); } if (obj.containsKey("期望从事岗位")) { rs.put("qwcsgw", this.parseArray(obj.getJSONArray("期望从事岗位"))); } if (obj.containsKey("工作经验")) { rs.put("gzjy1", this.parseArray(obj.getJSONArray("工作经验"))); } if (obj.containsKey("期望薪资")) { rs.put("qwxz", this.parseArray(obj.getJSONArray("期望薪资"))); } if (obj.containsKey("期望工作地点")) { rs.put("qwgzdd", this.parseArray(obj.getJSONArray("期望工作地点"))); } if (obj.containsKey("项目经历")) { rs.put("xmjl", this.parseArray(obj.getJSONArray("项目经历"))); } } rs.put("formmodeid", this.formmodeid_tmp); rs.put("modedatacreater", String.valueOf(user.getUID())); rs.put("modedatacreatertype", "0"); rs.put("modedatacreatedate", DateUtil.today()); rs.put("modedatacreatetime", DateUtil.formatTime(new Date())); return returnMap; } /** * 转换JSONArray为字符串类型 * * @param value * @return */ private String parseArray(Object value) { if (value instanceof JSONArray) { List list = new ArrayList<>(); JSONArray jsonArray = (JSONArray) value; for (int i = 0; i < jsonArray.size(); i++) { Object obj = jsonArray.get(i); String s = parseArray(obj); if (StringUtils.isBlank(s)) { continue; } list.add(s); } return StringUtils.join(list, ","); } else if (value instanceof JSONObject) { JSONObject jsonObject = (JSONObject) value; Set stringSet = jsonObject.keySet(); StringBuilder sb = new StringBuilder(); for (String key : stringSet) { String objValue = jsonObject.getString(key).replaceAll("\\n", ","); sb.append(key).append(":").append(objValue); } return sb.toString(); } else if (value instanceof String) { return value.toString(); } return ""; } /** * 获取yyyy-MM-dd时间格式日期 * * @param dateStr * @return */ private String getFormatDate(String dateStr) { if(StringUtils.isBlank(dateStr)){ return null; } dateStr = dateStr.replace(".", "-"); if (dateStr.length() == 7) { return dateStr + "-01"; } else if (dateStr.length() == 10) { return dateStr; } return ""; } /** * 获取学历ID * * @param name * @return */ public static String getEducationLevelId(String name) { if (StringUtils.isBlank(name)) { return null; } String id = null; RecordSet rs = new RecordSet(); rs.executeQuery("select id from hrmeducationlevel where name like '%" + name + "%'"); if (rs.next()) { id = rs.getString("id"); } return id; } /** * 附件imageFieldId生成docId * * @param secCategory * @param imageFieldId * @param user * @return * @throws Exception */ public static int createDocId(int secCategory, int imageFieldId, User user) { try { ImageFileManager manager = new ImageFileManager(); manager.getImageFileInfoById(imageFieldId); String filenameqc = manager.getImageFileName(); String filenamebc = filenameqc.substring(0, filenameqc.lastIndexOf(".")); RecordSet rs = new RecordSet(); DocManager dm = new DocManager(); DocImageManager imgManger = new DocImageManager(); imgManger.setDocfiletype("2"); int docId = dm.getNextDocId(rs); imgManger.setDocid(docId); imgManger.setImagefileid(imageFieldId); imgManger.setImagefilename(filenameqc); imgManger.setIsextfile("1"); imgManger.AddDocImageInfo(); String date = TimeUtil.getCurrentDateString(); String time = TimeUtil.getOnlyCurrentTimeString(); dm.setId(docId); dm.setMaincategory(0); dm.setSubcategory(0); dm.setSeccategory(secCategory); dm.setLanguageid(user.getLanguage()); dm.setDocstatus("1"); dm.setDocsubject(filenamebc); dm.setDoccreaterid(user.getUID()); dm.setDocCreaterType(user.getLogintype()); dm.setUsertype(user.getLogintype()); dm.setOwnerid(user.getUID()); dm.setOwnerType(user.getLogintype()); dm.setDoclastmoduserid(user.getUID()); dm.setDocLastModUserType(user.getLogintype()); dm.setDoccreatedate(date); dm.setDoclastmoddate(date); dm.setDoccreatetime(time); dm.setDoclastmodtime(time); dm.setDoclangurage(user.getLanguage()); dm.setKeyword(filenameqc); dm.setIsapprover("0"); dm.setIsreply(""); dm.setDocdepartmentid(user.getUserDepartment()); dm.setDocreplyable("1"); dm.setAccessorycount(1); dm.setParentids("" + docId); dm.setUserid(user.getUID()); DocCoder docCoder = new DocCoder(); dm.setDocCode(docCoder.getDocCoder("" + secCategory)); dm.setDocEditionId(dm.getNextEditionId(rs)); dm.setDocEdition(1); dm.AddDocInfo(); dm.AddShareInfo(); DocComInfo dc = new DocComInfo(); dc.addDocInfoCache("" + docId); return docId; } catch (Exception e) { throw new RuntimeException(e); } } /** * 插入明细表数据 * * @param rst * @param dataList * @param tableName * @param mainId * @throws Exception */ private void insertDetailTableData(RecordSetTrans rst, List> dataList, String tableName, String mainId) throws Exception { if (CollectionUtils.isEmpty(dataList)) { return; } for (Map dataMap : dataList) { List field = new ArrayList<>(); List value1 = new ArrayList<>(); List value = new ArrayList<>(); dataMap.put("mainid", mainId); dataMap.forEach((key, v) -> { if (StringUtils.isNotEmpty(v)) { field.add(key); value.add(v); value1.add("?"); } }); String sql = "insert into " + tableName + "(" + String.join(",", field) + ") values(" + String.join(",", value1) + ")"; rst.executeUpdate(sql, value); } } }