generated from dxfeng/secondev-chapanda-feishu
MODIFY-OCR简历识别,对接V2版本接口
This commit is contained in:
parent
1887b0fdd1
commit
477635fad4
|
|
@ -11,7 +11,54 @@ import weaver.hrm.User;
|
|||
* @version: 1.0
|
||||
*/
|
||||
public class ModeBrowserCommonInfo {
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
public static final String TYPE_GENDER = "1";
|
||||
/**
|
||||
* 简历来源
|
||||
*/
|
||||
public static final String TYPE_RESUME_SOURCE = "2";
|
||||
/**
|
||||
* 招聘渠道
|
||||
*/
|
||||
public static final String TYPE_RECRUITMENT_CHANNELS = "3";
|
||||
/**
|
||||
* 职位性质
|
||||
*/
|
||||
public static final String TYPE_JOB_NATURE = "4";
|
||||
/**
|
||||
* 职位学历要求
|
||||
*/
|
||||
public static final String TYPE_JOB_EDUCATION_REQUIREMENTS = "5";
|
||||
/**
|
||||
* 婚姻状况
|
||||
*/
|
||||
public static final String TYPE_MARITAL_STATUS = "6";
|
||||
/**
|
||||
* 在职状态
|
||||
*/
|
||||
public static final String TYPE_ON_THE_JOB_STATUS = "7";
|
||||
/**
|
||||
* 招聘原因
|
||||
*/
|
||||
public static final String TYPE_RECRUITMENT_REASON = "8";
|
||||
/**
|
||||
* 工作年限
|
||||
*/
|
||||
public static final String TYPE_YEARS_OF_WORK = "9";
|
||||
/**
|
||||
* 工作经验
|
||||
*/
|
||||
public static final String TYPE_WORK_EXPERIENCE = "10";
|
||||
/**
|
||||
* 政治面貌
|
||||
*/
|
||||
public static final String TYPE_POLITICAL_LANDSCAPE = "11";
|
||||
/**
|
||||
* 学位
|
||||
*/
|
||||
public static final String TYPE_DEGREE = "12";
|
||||
|
||||
/**
|
||||
* 根据名称,获取简历来源ID
|
||||
|
|
@ -20,7 +67,7 @@ public class ModeBrowserCommonInfo {
|
|||
* @return
|
||||
*/
|
||||
public static String getResumeSource(String name) {
|
||||
return getBrowserId("2", name);
|
||||
return getBrowserId(TYPE_RESUME_SOURCE, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -30,7 +77,7 @@ public class ModeBrowserCommonInfo {
|
|||
* @return
|
||||
*/
|
||||
public static String getWorkExperience(String name) {
|
||||
return getBrowserId("10", name);
|
||||
return getBrowserId(TYPE_WORK_EXPERIENCE, name);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -41,7 +88,7 @@ public class ModeBrowserCommonInfo {
|
|||
* @return
|
||||
*/
|
||||
public static String getDegreeId(String name) {
|
||||
return getBrowserId("12", name);
|
||||
return getBrowserId(TYPE_DEGREE, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +129,7 @@ public class ModeBrowserCommonInfo {
|
|||
if (split.length == 4) {
|
||||
areaName = split[1] + "-" + split[2] + "-" + split[3];
|
||||
placeName = areaName + "-" + xxdz;
|
||||
}else if(split.length == 3){
|
||||
} else if (split.length == 3) {
|
||||
areaName = split[0] + "-" + split[1] + "-" + split[2];
|
||||
placeName = areaName + "-" + xxdz;
|
||||
}
|
||||
|
|
@ -94,7 +141,7 @@ public class ModeBrowserCommonInfo {
|
|||
}
|
||||
|
||||
|
||||
private static String getBrowserId(String zdlxmc, String xxnr) {
|
||||
public static String getBrowserId(String zdlxmc, String xxnr) {
|
||||
if (StringUtils.isBlank(xxnr)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,8 +136,8 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog
|
|||
|
||||
BaseBean baseBean = new BaseBean();
|
||||
JSONObject all = JSONObject.parseObject(response);
|
||||
baseBean.writeLog("千里聆相应数据:" + all);
|
||||
if (!all.getBoolean("isSuccess")) {
|
||||
baseBean.writeLog("千里聆响应数据:" + all);
|
||||
throw new CustomizeRunTimeException("千里聆接口调用失败,接口不通");
|
||||
}
|
||||
JSONObject resultall = all.getJSONObject("data");
|
||||
|
|
@ -147,7 +147,7 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog
|
|||
}
|
||||
JSONObject result = resultall.getJSONObject("result");
|
||||
baseBean.writeLog("千里聆OCR解析数据:" + result);
|
||||
Map<String, Object> dataMap = parseQllJsonToMap(result, isCard);
|
||||
Map<String, Object> dataMap = parseQllJsonToMapV2(result, isCard);
|
||||
returnMap.put("data", dataMap);
|
||||
}
|
||||
|
||||
|
|
@ -294,6 +294,190 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog
|
|||
return dataMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 千里聆解析字段内容处理(V2)
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> parseQllJsonToMapV2(JSONObject obj, boolean isCard) {
|
||||
new BaseBean().writeLog(obj.toJSONString());
|
||||
Map<String, Object> dataMap = new HashMap<>(16);
|
||||
JSONObject personalInformation = obj.getJSONObject("个人信息");
|
||||
|
||||
// 姓名
|
||||
String xm = personalInformation.getString("姓名");
|
||||
dataMap.put("xm", xm);
|
||||
// 电子邮箱
|
||||
String dzyx = personalInformation.getString("电子邮箱");
|
||||
dataMap.put("dzyx", dzyx);
|
||||
// 手机号码
|
||||
String sjhm = personalInformation.getString("手机号");
|
||||
dataMap.put("sjhm", sjhm);
|
||||
// 年龄
|
||||
String nl = personalInformation.getString("年龄");
|
||||
dataMap.put("nl", nl);
|
||||
// 出生日期
|
||||
String csrq = personalInformation.getString("出生日期");
|
||||
dataMap.put("csrq", parseDateObject(csrq));
|
||||
// 性别 默认为男
|
||||
String xb = "女".equals(personalInformation.getString("性别")) ? "1" : "0";
|
||||
dataMap.put("xb", xb);
|
||||
// 体重(KG)
|
||||
String tz = personalInformation.getString("体重");
|
||||
dataMap.put("tzkg", Convert.toDouble(tz));
|
||||
// 身高(CM)
|
||||
String sg = personalInformation.getString("身高");
|
||||
dataMap.put("sgcm", Convert.toDouble(sg));
|
||||
// 籍贯(字段类型不支持)
|
||||
String jg = personalInformation.getString("籍贯");
|
||||
//dataMap.put("jg", parseArray(obj.getJSONArray("籍贯")));
|
||||
// 婚姻状况
|
||||
List<Map<String, String>> hyzk = getBrowserArray(personalInformation.getString("婚姻状况"), ModeBrowserCommonInfo.TYPE_MARITAL_STATUS);
|
||||
if (CollectionUtils.isNotEmpty(hyzk)) {
|
||||
dataMap.put("hyzk", hyzk);
|
||||
if (!isCard) {
|
||||
dataMap.put("hyzk", hyzk.stream().map(item -> item.get("id")).collect(Collectors.joining(",")));
|
||||
}
|
||||
}
|
||||
// 当前所在地(字段类型不支持)
|
||||
String jdz = personalInformation.getString("现居住地");
|
||||
//dataMap.put("jzd", parseArray(obj.getJSONArray("现居住地")));
|
||||
// 政治面貌
|
||||
List<Map<String, String>> zzmm = getBrowserArray(personalInformation.getString("政治面貌"), ModeBrowserCommonInfo.TYPE_POLITICAL_LANDSCAPE);
|
||||
if (CollectionUtils.isNotEmpty(zzmm)) {
|
||||
dataMap.put("zzmm", zzmm);
|
||||
if (!isCard) {
|
||||
dataMap.put("zzmm", zzmm.stream().map(item -> item.get("id")).collect(Collectors.joining(",")));
|
||||
}
|
||||
}
|
||||
// 在职状态
|
||||
List<Map<String, String>> zzzt = getBrowserArray(personalInformation.getString("在职状态"), ModeBrowserCommonInfo.TYPE_ON_THE_JOB_STATUS);
|
||||
if (CollectionUtils.isNotEmpty(zzzt)) {
|
||||
dataMap.put("zzzt", zzzt);
|
||||
if (!isCard) {
|
||||
dataMap.put("zzzt", zzzt.stream().map(item -> item.get("id")).collect(Collectors.joining(",")));
|
||||
}
|
||||
}
|
||||
|
||||
// 工作经验
|
||||
String gzjyStr = personalInformation.getString("工作经验");
|
||||
if (gzjyStr.contains("到")) {
|
||||
String[] split = gzjyStr.split("到");
|
||||
if (split.length == 2) {
|
||||
gzjyStr = split[1];
|
||||
}
|
||||
}
|
||||
List<Map<String, String>> gzjy = getBrowserArray(gzjyStr, ModeBrowserCommonInfo.TYPE_WORK_EXPERIENCE);
|
||||
if (CollectionUtils.isNotEmpty(gzjy)) {
|
||||
dataMap.put("gzjy", gzjy);
|
||||
if (!isCard) {
|
||||
dataMap.put("gzjy", gzjy.stream().map(item -> item.get("id")).collect(Collectors.joining(",")));
|
||||
}
|
||||
}
|
||||
// 最高学位
|
||||
List<Map<String, String>> zgxw = getBrowserArray(personalInformation.getString("最高学位"), ModeBrowserCommonInfo.TYPE_DEGREE);
|
||||
if (CollectionUtils.isNotEmpty(zgxw)) {
|
||||
dataMap.put("zgxw", zgxw);
|
||||
if (!isCard) {
|
||||
dataMap.put("zgxw", zgxw.stream().map(item -> item.get("id")).collect(Collectors.joining(",")));
|
||||
}
|
||||
}
|
||||
// 最高学历
|
||||
String highestEduLevel = personalInformation.getString("最高学历");
|
||||
List<Map<String, String>> zgxl = getBrowserArray(highestEduLevel, this::getEducationLevelArray);
|
||||
if (CollectionUtils.isNotEmpty(zgxl)) {
|
||||
dataMap.put("zgxl", zgxl);
|
||||
if (!isCard) {
|
||||
dataMap.put("zgxl", zgxl.stream().map(item -> item.get("id")).collect(Collectors.joining(",")));
|
||||
}
|
||||
}
|
||||
|
||||
// 毕业院校
|
||||
String byyx = personalInformation.getString("毕业院校");
|
||||
dataMap.put("byyx", byyx);
|
||||
// 现税前月薪(K)
|
||||
// 自我评价
|
||||
String zwpj = personalInformation.getString("个人评价");
|
||||
dataMap.put("zwpj", zwpj);
|
||||
// 民族
|
||||
dataMap.put("mz", personalInformation.getString("民族"));
|
||||
|
||||
JSONObject jobSearchInformation = obj.getJSONObject("求职信息");
|
||||
// 期望税前月薪(K)
|
||||
String qwxz = jobSearchInformation.getString("期望薪资");
|
||||
dataMap.put("qwxz", qwxz);
|
||||
|
||||
|
||||
// 明细表数据
|
||||
// 教育经历
|
||||
JSONArray jyjl = obj.getJSONArray("学业信息");
|
||||
List<RecruitDataMap<Object>> studyList = new ArrayList<>();
|
||||
if (null != jyjl && jyjl.size() > 0) {
|
||||
for (int i = 0; i < jyjl.size(); i++) {
|
||||
JSONObject o = (JSONObject) jyjl.get(i);
|
||||
String studyDate = o.getString("就读时期");
|
||||
RecruitDataMap<Object> studyMap = new RecruitDataMap<>();
|
||||
studyMap.putAll(getDateRange(studyDate, true));
|
||||
String schoolName = o.getString("学校名称");
|
||||
studyMap.put("xxmc", schoolName);
|
||||
String educationLevel = o.getString("学历");
|
||||
List<Map<String, String>> xl = getBrowserArray(educationLevel, this::getEducationLevelArray);
|
||||
studyMap.put("xl", xl);
|
||||
if (!isCard && CollectionUtils.isNotEmpty(xl)) {
|
||||
studyMap.put("xl", xl.stream().map(item -> item.get("id")).collect(Collectors.joining(",")));
|
||||
}
|
||||
String professionalName = o.getString("专业名称");
|
||||
studyMap.put("zy", professionalName);
|
||||
// 主表 专业字段
|
||||
if (byyx.equals(schoolName) && highestEduLevel.equals(educationLevel)) {
|
||||
dataMap.put("zy", professionalName);
|
||||
}
|
||||
studyList.add(studyMap);
|
||||
}
|
||||
}
|
||||
dataMap.put("jyjl", studyList);
|
||||
|
||||
// 工作经历
|
||||
JSONArray gzjl = obj.getJSONArray("工作经历");
|
||||
List<RecruitDataMap<Object>> workList = new ArrayList<>();
|
||||
if (null != gzjl && gzjl.size() > 0) {
|
||||
for (int i = 0; i < gzjl.size(); i++) {
|
||||
JSONObject o = (JSONObject) gzjl.get(i);
|
||||
String workDate = o.getString("工作时间");
|
||||
RecruitDataMap<Object> workMap = new RecruitDataMap<>();
|
||||
workMap.putAll(getDateRange(workDate, false));
|
||||
workMap.put("gsmc", o.getString("工作单位"));
|
||||
workMap.put("gw", o.getString("岗位名称"));
|
||||
workMap.put("gzzz", o.getString("工作内容"));
|
||||
workList.add(workMap);
|
||||
}
|
||||
}
|
||||
|
||||
dataMap.put("gzjl", workList);
|
||||
// 项目经验
|
||||
// 语言能力
|
||||
|
||||
|
||||
// 目前表单暂无字段
|
||||
//dataMap.put("wx", parseArray(obj.getJSONArray("微信")));
|
||||
//dataMap.put("qq", parseArray(obj.getJSONArray("QQ")));
|
||||
//dataMap.put("ah", parseArray(obj.getJSONArray("爱好")));
|
||||
//dataMap.put("bysj", parseArray(obj.getJSONArray("毕业时间")));
|
||||
//
|
||||
//
|
||||
//dataMap.put("zyjn", parseArray(obj.getJSONArray("专业技能")));
|
||||
//dataMap.put("sxjl", parseArray(obj.getJSONArray("实习经历")));
|
||||
//dataMap.put("yysp", parseArray(obj.getJSONArray("英语水平")));
|
||||
//dataMap.put("jnzs", parseArray(obj.getJSONArray("技能证书")));
|
||||
//dataMap.put("xyjl", parseArray(obj.getJSONArray("校园经历")));
|
||||
//dataMap.put("qwcsgw", parseArray(obj.getJSONArray("期望从事岗位")));
|
||||
//
|
||||
//dataMap.put("qwgzdd", parseArray(obj.getJSONArray("期望工作地点")));
|
||||
//dataMap.put("xmjl", parseArray(obj.getJSONArray("项目经历")));
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resumeId
|
||||
|
|
@ -318,6 +502,8 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog
|
|||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
String fileName = manager.getImageFileName();
|
||||
builder.addTextBody("type", fileName.substring(fileName.lastIndexOf('.') + 1));
|
||||
// 对接新版抽取服务
|
||||
builder.addTextBody("version", "V2");
|
||||
builder.addBinaryBody("resume", manager.getInputStream(), ContentType.APPLICATION_OCTET_STREAM, manager.getImageFileName());
|
||||
HttpEntity entity = builder.build();
|
||||
postRequest.setEntity(entity);
|
||||
|
|
@ -393,6 +579,7 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog
|
|||
if (StringUtils.isBlank(value)) {
|
||||
return null;
|
||||
}
|
||||
value = value.replace(".", "-");
|
||||
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
sdf.setLenient(false);
|
||||
try {
|
||||
|
|
@ -412,6 +599,9 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog
|
|||
*/
|
||||
private RecruitDataMap<Object> getDateRange(String date, boolean isStudy) {
|
||||
RecruitDataMap<Object> dataRangeMap = new RecruitDataMap<>();
|
||||
if (StringUtils.isBlank(date)) {
|
||||
return dataRangeMap;
|
||||
}
|
||||
String[] split = date.split("-");
|
||||
if (split.length == 2) {
|
||||
String start = getFormatDate(split[0]);
|
||||
|
|
@ -511,6 +701,33 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建浏览按钮字段信息格式
|
||||
*
|
||||
* @param text
|
||||
* @param browserType
|
||||
* @return
|
||||
*/
|
||||
private List<Map<String, String>> getBrowserArray(String text, String browserType) {
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(text)) {
|
||||
String[] split = text.split(",");
|
||||
for (String s : split) {
|
||||
Map<String, String> map = new HashMap<>(2);
|
||||
if (StringUtils.isNotBlank(text)) {
|
||||
String id = ModeBrowserCommonInfo.getBrowserId(browserType, text);
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
map.put("id", id);
|
||||
map.put("name", text);
|
||||
}
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建学历字段信息
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue