Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
9d942a37
Commit
9d942a37
authored
Mar 30, 2022
by
284718418@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
百度简历解析TIC
parent
3b46bc9e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
157 additions
and
22 deletions
+157
-22
src/main/java/cn/timer/api/controller/zpgl/ZpglController.java
+45
-0
src/main/java/cn/timer/api/dto/baidu/BasicInfos.java
+21
-0
src/main/java/cn/timer/api/dto/baidu/EducationInfos.java
+20
-0
src/main/java/cn/timer/api/dto/baidu/ProjectInfos.java
+21
-0
src/main/java/cn/timer/api/dto/baidu/ResumeExtract.java
+21
-0
src/main/java/cn/timer/api/dto/baidu/WorkInfos.java
+21
-0
src/main/java/cn/timer/api/utils/baidu/BaiduTicUtil.java
+4
-9
src/main/java/cn/timer/api/utils/baidu/Base64.java
+4
-13
No files found.
src/main/java/cn/timer/api/controller/zpgl/ZpglController.java
View file @
9d942a37
...
...
@@ -22,13 +22,18 @@ import cn.timer.api.dao.kqmk.KqglAssoKqzdkfsMapper;
import
cn.timer.api.dao.qyzx.QyzxEmpLoginMapper
;
import
cn.timer.api.dao.yggl.YgglMainEmpMapper
;
import
cn.timer.api.dao.zpgl.ZpglRcxxMapper
;
import
cn.timer.api.dto.baidu.BaiduTicResumeDto
;
import
cn.timer.api.dto.baidu.BasicInfos
;
import
cn.timer.api.dto.zpgl.ZpglRcxxDto
;
import
cn.timer.api.dto.zpgl.ZpglRcxxEntryDto
;
import
cn.timer.api.utils.Md5
;
import
cn.timer.api.utils.Result
;
import
cn.timer.api.utils.ResultUtil
;
import
cn.timer.api.utils.baidu.BaiduTicUtil
;
import
cn.timer.api.utils.baidu.Base64
;
import
cn.timer.api.utils.query.BaseQuery
;
import
cn.timer.api.config.enuminterface.YgEnumInterface.jobStatus
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper
;
...
...
@@ -51,7 +56,10 @@ import org.springframework.util.StringUtils;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.multipart.MultipartFile
;
import
sun.misc.BASE64Encoder
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.transaction.Transactional
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
...
...
@@ -74,6 +82,9 @@ import java.util.Map;
@Slf4j
public
class
ZpglController
{
@Autowired
private
BaiduTicUtil
baiduTicUtil
;
@Value
(
value
=
"${config-8timer.init-password}"
)
private
String
pwd
;
// 回调地址
...
...
@@ -417,6 +428,40 @@ public class ZpglController {
}
/**
* 招聘-导入候选人简历
* @param userBean
* @param file
* @param request
* @return
*/
@ResponseBody
@PostMapping
(
"/resume_import_candidate"
)
@ApiOperation
(
value
=
"招聘-导入候选人简历"
,
httpMethod
=
"POST"
,
notes
=
"招聘-导入候选人简历"
)
public
Result
<
Object
>
resumeImportCandidate
(
@CurrentUser
UserBean
userBean
,
@RequestParam
(
required
=
true
)
MultipartFile
file
,
HttpServletRequest
request
)
{
try
{
BaiduTicResumeDto
baiduTicResumeDto
=
BaiduTicResumeDto
.
builder
().
filename
(
"邓志鸿.docx"
).
filetype
(
"docx"
).
filedata
(
Base64
.
getStrFromPath
(
file
)).
build
();
ResponseEntity
<
String
>
resumeString
=
baiduTicUtil
.
getResumeByCvParser
(
baiduTicResumeDto
);
log
.
info
(
"resumeString:{}"
,
resumeString
.
getBody
());
JSONObject
json
=
(
JSONObject
)
JSONObject
.
parse
(
resumeString
.
getBody
());
if
(
"success"
.
equals
(
json
.
get
(
"error_msg"
))){
BasicInfos
asicInfos
=
JSONObject
.
toJavaObject
(
JSONObject
.
parse
(
json
.
get
(
"results"
).
toString
()),
BasicInfos
.
class
);
}
else
{
return
ResultUtil
.
error
(
"操作失败"
);
}
return
ResultUtil
.
success
(
"操作成功"
);
// return ZpglRcxx.builder().build().updateById()?ResultUtil.success("操作成功"):ResultUtil.error("操作失败");
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
CustomException
(
"招聘-导入候选人简历失败"
);
}
}
/**
* 获取统计数据
* @param queryWrapper
* @param status
...
...
src/main/java/cn/timer/api/dto/baidu/BasicInfos.java
0 → 100644
View file @
9d942a37
package
cn
.
timer
.
api
.
dto
.
baidu
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022/3/30
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
BasicInfos
implements
Serializable
{
}
src/main/java/cn/timer/api/dto/baidu/EducationInfos.java
0 → 100644
View file @
9d942a37
package
cn
.
timer
.
api
.
dto
.
baidu
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022/3/30
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
EducationInfos
implements
Serializable
{
}
src/main/java/cn/timer/api/dto/baidu/ProjectInfos.java
0 → 100644
View file @
9d942a37
package
cn
.
timer
.
api
.
dto
.
baidu
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022/3/30
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
ProjectInfos
implements
Serializable
{
}
src/main/java/cn/timer/api/dto/baidu/ResumeExtract.java
0 → 100644
View file @
9d942a37
package
cn
.
timer
.
api
.
dto
.
baidu
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022/3/30
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
ResumeExtract
implements
Serializable
{
}
src/main/java/cn/timer/api/dto/baidu/WorkInfos.java
0 → 100644
View file @
9d942a37
package
cn
.
timer
.
api
.
dto
.
baidu
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022/3/30
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
WorkInfos
implements
Serializable
{
}
src/main/java/cn/timer/api/utils/baidu/BaiduTicUtil.java
View file @
9d942a37
...
...
@@ -26,15 +26,15 @@ import java.util.Map;
public
class
BaiduTicUtil
{
@Value
(
"${config-8timer.baidu-tic.appid}"
)
private
static
String
appid
=
"XOATkGqX6LvCW3i3Eqd5rg6h"
;
private
String
appid
;
@Value
(
"${config-8timer.baidu-tic.secret}"
)
private
static
String
secret
=
"UqqNAF1nltMjAOz9yxqHPjZlnjtC2gSS"
;
private
String
secret
;
/**
* 获取百度token
* @return
*/
public
static
String
getBaiduAccessToken
(){
public
String
getBaiduAccessToken
(){
StringBuffer
url
=
new
StringBuffer
(
"https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id="
);
url
=
url
.
append
(
appid
).
append
(
"&client_secret="
).
append
(
secret
);
ResponseEntity
<
String
>
response
=
new
RestTemplate
().
exchange
(
url
.
toString
(),
HttpMethod
.
GET
,
null
,
String
.
class
);
...
...
@@ -42,7 +42,7 @@ public class BaiduTicUtil {
return
new
Gson
().
fromJson
(
response
.
getBody
(),
HashMap
.
class
).
get
(
"access_token"
).
toString
();
}
public
static
ResponseEntity
<
String
>
getResumeByCvParser
(
BaiduTicResumeDto
baiduTicResumeDto
){
public
ResponseEntity
<
String
>
getResumeByCvParser
(
BaiduTicResumeDto
baiduTicResumeDto
){
String
url
=
"https://aip.baidubce.com/rpc/2.0/recruitment/v1/cvparser?access_token="
+
getBaiduAccessToken
();
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"resume"
,
baiduTicResumeDto
);
...
...
@@ -55,9 +55,4 @@ public class BaiduTicUtil {
return
new
RestTemplate
().
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
}
public
static
void
main
(
String
[]
args
)
{
BaiduTicResumeDto
baiduTicResumeDto
=
BaiduTicResumeDto
.
builder
().
filename
(
"邓志鸿.docx"
).
filetype
(
"docx"
).
filedata
(
Base64
.
getStrFromPath
(
"https://test-img.8timer.cn/6b8c7ec7-14b0-45e7-aa21-7acd0d45e612.docx"
)).
build
();
ResponseEntity
<
String
>
responseEntity
=
getResumeByCvParser
(
baiduTicResumeDto
);
System
.
out
.
println
(
responseEntity
.
getBody
());
}
}
src/main/java/cn/timer/api/utils/baidu/Base64.java
View file @
9d942a37
package
cn
.
timer
.
api
.
utils
.
baidu
;
import
org.springframework.web.multipart.MultipartFile
;
import
sun.misc.BASE64Encoder
;
import
java.io.FileInputStream
;
...
...
@@ -21,22 +22,12 @@ public class Base64 {
/**
* 转化成Base64字符串
*/
public
static
String
getStrFromPath
(
String
imgPath
)
{
public
static
String
getStrFromPath
(
MultipartFile
file
)
{
URL
url
=
null
;
InputStream
in
=
null
;
byte
[]
data
=
null
;
try
{
url
=
new
URL
(
imgPath
);
httpUrl
=
(
HttpURLConnection
)
url
.
openConnection
();
httpUrl
.
connect
();
httpUrl
.
getInputStream
();
in
=
httpUrl
.
getInputStream
();
in
=
file
.
getInputStream
();
data
=
new
byte
[
in
.
available
()];
in
.
read
(
data
);
in
.
close
();
...
...
@@ -46,6 +37,6 @@ public class Base64 {
// 对字节数组Base64编码
BASE64Encoder
encoder
=
new
BASE64Encoder
();
// 返回Base64编码过再URLEncode的字节数组字符串
return
URLEncoder
.
encode
(
encoder
.
encode
(
data
)
);
return
encoder
.
encode
(
data
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment