package com.engine.resumestorage.service.impl; 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.lang3.StringUtils; import weaver.conn.RecordSetTrans; import weaver.formmode.setup.ModeRightInfo; import weaver.general.BaseBean; import weaver.general.Util; 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 int saveResumeByImageFileId(int imageFileId) throws Exception { 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); return this.saveResumeInDB(saveResume); } } } } @Override public int saveResumeInDB(Map fields) throws Exception { String tablename = "uf_jg_rmk"; if ("1".equals(this.sfsymr)) { tablename = this.bb.getPropValue("resume_qianliling", "jlk.tablename"); } RecordSetTrans rst = new RecordSetTrans(); rst.setAutoCommit(false); List field = new ArrayList(); List value1 = new ArrayList(); List value = new ArrayList(); fields.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, new Object[]{value}); rst.commit(); if (flag) { String idSql = "SELECT max(id) as mid from " + tablename; String id = Sql.querySingleField(idSql, "mid"); this.permissionReconstruction(Util.getIntValue(id)); return Integer.parseInt(id); } else { return -1; } } catch (Exception var11) { var11.printStackTrace(); rst.rollback(); this.log.error(var11); throw new ECException("简历更新失败"); } } private void permissionReconstruction(int billId) { ModeRightInfo ModeRightInfo = new ModeRightInfo(); ModeRightInfo.setNewRight(true); ModeRightInfo.editModeDataShare(1, Util.getIntValue(this.formmodeid_tmp), billId); } @Override public Map queryByDBId(String resumeid) throws Exception { 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, new Object[0]); rst.commit(); return true; } catch (Exception var6) { rst.rollback(); throw new Exception(var6); } } private Map parseJsonToMap(JSONObject obj) { 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"), this.parseArray(obj.getJSONArray("性别")).equals("男") ? "0" : "1"); } } 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("年龄"))); } } if (obj.containsKey("身份证号")) { v = this.bb.getPropValue("resume_qianliling", "sfz"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "sfz"), this.parseArray(obj.getJSONArray("身份证号"))); } } 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", "xyxg"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "xyxg"), obj.getJSONArray("学业信息").toJSONString()); } } 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", "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", "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", "gzxg"); if (v != null && v.length() > 0) { rs.put(this.bb.getPropValue("resume_qianliling", "gzxg"), obj.getJSONArray("工作信息").toJSONString()); } } 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("项目经历"))); } } } else { if (obj.containsKey("姓名")) { rs.put("rmxm", this.parseArray(obj.getJSONArray("姓名"))); } if (obj.containsKey("性别")) { rs.put("xb", this.parseArray(obj.getJSONArray("性别")).equals("男") ? "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", "1"); rs.put("modedatacreatertype", "0"); rs.put("modedatacreatedate", DateUtil.today()); rs.put("modedatacreatetime", DateUtil.formatTime(new Date())); return rs; } private String parseArray(JSONArray ar) { String rs = ""; if (ar != null && ar.size() > 0) { for(int i = 0; i < ar.size(); ++i) { if (i == ar.size() - 1) { rs = rs + ar.get(i); } else { rs = rs + ar.get(i) + ","; } } } return rs; } }