|
@@ -22,6 +22,8 @@ import java.util.*;
|
|
public class TenUtil {
|
|
public class TenUtil {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(TenUtil.class);
|
|
private static final Logger log = LoggerFactory.getLogger(TenUtil.class);
|
|
|
|
+ // url参数拼接
|
|
|
|
+ private static String url = "https://service-9wsy8usn-1302482110.bj.apigw.tencentcs.com/release/ResumeParser";
|
|
|
|
|
|
public static String calcAuthorization(String source, String secretId, String secretKey, String datetime)
|
|
public static String calcAuthorization(String source, String secretId, String secretKey, String datetime)
|
|
throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
|
|
throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
|
|
@@ -50,31 +52,27 @@ public class TenUtil {
|
|
return sb.toString();
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
|
|
- // url参数拼接
|
|
|
|
- private static final String url = "https://service-9wsy8usn-1302482110.bj.apigw.tencentcs.com/release/ResumeParser";
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
- * @param secretId 云市场分配的密钥Id
|
|
|
|
- * @param secretKey 云市场分配的密钥Key
|
|
|
|
- * @param fileName 简历文件名。请务必带上正确的文件后缀名,否则部分简历可能解析失败。
|
|
|
|
- * @param fileCount 简历文件内容(以base64编码),其中:
|
|
|
|
- * 1)图片简历:based64编码后大小不超过8M,最短边至少100px,支持jpg/jpeg/png/bmp/tif/gif格式。
|
|
|
|
- * 图片越大OCR超时风险越高,建议大小不超过4M、长宽比小于4、分辨率600*800以上;
|
|
|
|
- * 2)非图片简历:based64编码后大小不超过10M(注:阿里云接口是不超过8M);
|
|
|
|
- * @param needAvatar 是否需要解析头像,0为不需要,1为需要,默认为0。(注:解析头像会增加1倍左右耗时,如不需头像建议不开启)
|
|
|
|
|
|
+ * @param secretId 云市场分配的密钥Id
|
|
|
|
+ * @param secretKey 云市场分配的密钥Key
|
|
|
|
+ * @param fileName 简历文件名。请务必带上正确的文件后缀名,否则部分简历可能解析失败。
|
|
|
|
+ * @param fileCount 简历文件内容(以base64编码),其中:
|
|
|
|
+ * 1)图片简历:based64编码后大小不超过8M,最短边至少100px,支持jpg/jpeg/png/bmp/tif/gif格式。
|
|
|
|
+ * 图片越大OCR超时风险越高,建议大小不超过4M、长宽比小于4、分辨率600*800以上;
|
|
|
|
+ * 2)非图片简历:based64编码后大小不超过10M(注:阿里云接口是不超过8M);
|
|
|
|
+ * @param needAvatar 是否需要解析头像,0为不需要,1为需要,默认为0。(注:解析头像会增加1倍左右耗时,如不需头像建议不开启)
|
|
* @param needSocialExp 是否需要解析实践经历,0为不需要,1为需要,默认为0:
|
|
* @param needSocialExp 是否需要解析实践经历,0为不需要,1为需要,默认为0:
|
|
* 1)若需要解析,则对“社会实践”及“在校活动”文本进行解析,解析结果放置在social_exp_objs字段中
|
|
* 1)若需要解析,则对“社会实践”及“在校活动”文本进行解析,解析结果放置在social_exp_objs字段中
|
|
- * @param version 接口版本,当前取值为0和1,默认为0:
|
|
|
|
- * 1)version=0:仅当字段在简历中有出现,才会在json结果中返回;
|
|
|
|
- * 2)version=1:不管字段在简历中有无出现,均在json结果中返回,若无出现则该字段取值为空;
|
|
|
|
|
|
+ * @param version 接口版本,当前取值为0和1,默认为0:
|
|
|
|
+ * 1)version=0:仅当字段在简历中有出现,才会在json结果中返回;
|
|
|
|
+ * 2)version=1:不管字段在简历中有无出现,均在json结果中返回,若无出现则该字段取值为空;
|
|
* @return
|
|
* @return
|
|
* @throws NoSuchAlgorithmException
|
|
* @throws NoSuchAlgorithmException
|
|
* @throws UnsupportedEncodingException
|
|
* @throws UnsupportedEncodingException
|
|
* @throws InvalidKeyException
|
|
* @throws InvalidKeyException
|
|
*/
|
|
*/
|
|
- public static String resume(String secretId,String secretKey,String fileName,String fileCount,Integer needAvatar
|
|
|
|
- ,Integer needSocialExp,Integer version) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
|
|
|
|
|
|
+ public static String resume(String secretId, String secretKey, String fileName, String fileCount, Integer needAvatar
|
|
|
|
+ , Integer needSocialExp, Integer version) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
|
|
|
|
|
|
String source = "market";
|
|
String source = "market";
|
|
Calendar cd = Calendar.getInstance();
|
|
Calendar cd = Calendar.getInstance();
|
|
@@ -90,18 +88,18 @@ public class TenUtil {
|
|
headers.put("X-Date", datetime);
|
|
headers.put("X-Date", datetime);
|
|
// 签名
|
|
// 签名
|
|
headers.put("Authorization", calcAuthorization(source, secretId, secretKey, datetime));
|
|
headers.put("Authorization", calcAuthorization(source, secretId, secretKey, datetime));
|
|
- headers.put("Content-Type","application/json");
|
|
|
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
// 查询参数
|
|
// 查询参数
|
|
Map<String, String> queryParams = new HashMap<String, String>();
|
|
Map<String, String> queryParams = new HashMap<String, String>();
|
|
|
|
|
|
// body参数
|
|
// body参数
|
|
Map<String, String> bodyParams = new HashMap<String, String>();
|
|
Map<String, String> bodyParams = new HashMap<String, String>();
|
|
- bodyParams.put("body","");
|
|
|
|
- bodyParams.put("file_name",fileName);
|
|
|
|
- bodyParams.put("file_count",fileCount);
|
|
|
|
- bodyParams.put("need_avatar",needAvatar.toString());
|
|
|
|
- bodyParams.put("need_social_exp",needSocialExp.toString());
|
|
|
|
- bodyParams.put("version",version.toString());
|
|
|
|
|
|
+ bodyParams.put("body", "");
|
|
|
|
+ bodyParams.put("file_name", fileName);
|
|
|
|
+ bodyParams.put("file_count", fileCount);
|
|
|
|
+ bodyParams.put("need_avatar", needAvatar.toString());
|
|
|
|
+ bodyParams.put("need_social_exp", needSocialExp.toString());
|
|
|
|
+ bodyParams.put("version", version.toString());
|
|
|
|
|
|
|
|
|
|
if (!queryParams.isEmpty()) {
|
|
if (!queryParams.isEmpty()) {
|
|
@@ -144,7 +142,7 @@ public class TenUtil {
|
|
result += line;
|
|
result += line;
|
|
}
|
|
}
|
|
|
|
|
|
- return result;
|
|
|
|
|
|
+ return result;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(String.valueOf(e));
|
|
log.error(String.valueOf(e));
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|