OCR简历识别兼容SqlServer数据库

This commit is contained in:
dxfeng 2023-12-15 17:11:31 +08:00
parent c285b90059
commit ed74a91e30
2 changed files with 447 additions and 5 deletions

View File

@ -0,0 +1,447 @@
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 java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
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");
}
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<String, String> saveResume = this.parseJsonToMap(result);
return this.saveResumeInDB(saveResume);
}
}
}
}
public int saveResumeInDB(Map<String, String> 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<String> field = new ArrayList();
List<String> value1 = new ArrayList();
List<String> 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);
}
public Map<String, String> 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);
}
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<String, String> parseJsonToMap(JSONObject obj) {
Map<String, String> 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", "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;
}
}

View File

@ -1,8 +1,3 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package com.engine.resumestorage.service.impl; package com.engine.resumestorage.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;