Commit 1eb5d791 by 284718418@qq.com

ResumeSDK 本地测试

parent b4dcec11
......@@ -467,7 +467,8 @@ public class ZpglController {
return ResultUtil.error("导入简历失败,目前支持pdf,doc,docx,wps,txt,jpg,jpeg,png,bmp,tif格式~");
}
importCandidateDto.setSuffix(suffix);
return zpglService.addResumeImportCandidate(userBean, file, importCandidateDto);
// return zpglService.addResumeImportCandidate(userBean, file, importCandidateDto);
return zpglService.addCandidateByResumeSDK(userBean, file, importCandidateDto);
} catch (CustomException e) {
e.printStackTrace();
throw e;
......
......@@ -30,12 +30,19 @@ public interface ZpglService {
SysRegion getSysRegion(Integer keyId);
/**
*
* BaiduTicResume
* @param file
* @return
*/
Result<Object> addResumeImportCandidate(UserBean userBean, MultipartFile file, ImportCandidateDto importCandidateDto);
/**
* ResumeSDK
* @param file
* @return
*/
Result<Object> addCandidateByResumeSDK(UserBean userBean, MultipartFile file, ImportCandidateDto importCandidateDto);
/**
* 招聘-更改招聘职位
......
package cn.timer.api.controller.zpgl.sevice;
import cn.timer.api.bean.clazz.SysRegion;
import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.bean.wechat.MessageTemplate;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.bean.zpgl.*;
......@@ -11,8 +10,8 @@ import cn.timer.api.config.enuminterface.JxglEnumInterface;
import cn.timer.api.controller.kqgl.ClockInTool;
import cn.timer.api.dto.baidu.*;
import cn.timer.api.bean.clazz.NationClass;
import cn.timer.api.dto.email.SendMessageDto;
import cn.timer.api.dto.resumesdk.ResumeSdkDto;
import cn.timer.api.dto.resumesdk.*;
import cn.timer.api.dto.resumesdk.enumresume.ResumeSdk;
import cn.timer.api.dto.template.InterviewNotice;
import cn.timer.api.dto.zpgl.ImportCandidateDto;
import cn.timer.api.dto.zpgl.ZpglRcxxDto;
......@@ -35,7 +34,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
......@@ -266,21 +264,11 @@ public class ZpglServiceImpl implements ZpglService {
@Override
public Result<Object> addResumeImportCandidate(UserBean userBean, MultipartFile file, ImportCandidateDto importCandidateDto) {
/*BaiduTicResumeDto baiduTicResumeDto = BaiduTicResumeDto.builder().filename(file.getOriginalFilename()).filetype(importCandidateDto.getSuffix()).filedata(Base64.getStrFromPath(file)).build();
ResponseEntity<String> resumeString = baiduTicUtil.getResumeByCvParser(baiduTicResumeDto);*/
ResumeSdkDto resumeSdkDto = ResumeSdkDto.builder().ocr_type(1).need_avatar(0).file_name(file.getOriginalFilename()).file_cont(Base64.getStrFromPath(file)).build();
String resumeString = "";
try {
resumeString = resumeSDKUtil.getResumeByCvParser(resumeSdkDto, RESUMESDK_APPCODE);
}catch (Exception e){
e.printStackTrace();
}
JSONObject json = (JSONObject) JSONObject.parse(resumeString);
log.info("招聘-导入候选人简历{}", resumeString);
return ResultUtil.success();
/*ResumeExtract resumeExtract = null;
BaiduTicResumeDto baiduTicResumeDto = BaiduTicResumeDto.builder().filename(file.getOriginalFilename()).filetype(importCandidateDto.getSuffix()).filedata(Base64.getStrFromPath(file)).build();
ResponseEntity<String> resumeString = baiduTicUtil.getResumeByCvParser(baiduTicResumeDto);
JSONObject json = (JSONObject) JSONObject.parse(resumeString.getBody());
log.info("招聘-导入候选人简历{}", resumeString.getBody());
ResumeExtract resumeExtract = null;
if ("success".equals(json.get("error_msg"))) {
if (StringUtils.isEmpty(json.get("results"))) {
log.info("招聘-导入候选人简历:results is null");
......@@ -304,10 +292,37 @@ public class ZpglServiceImpl implements ZpglService {
importCandidateDto.setFilePath(data.getData());
importCandidateDto.setFileName(file.getOriginalFilename());
}
return this.addZpglRcxx(userBean, resumeExtract, importCandidateDto);*/
return this.addZpglRcxx(userBean, resumeExtract, importCandidateDto);
}
@Override
public Result<Object> addCandidateByResumeSDK(UserBean userBean, MultipartFile file, ImportCandidateDto importCandidateDto) {
ResumeSdkDto resumeSdkDto = ResumeSdkDto.builder().ocr_type(1).need_avatar(0).file_name(file.getOriginalFilename()).file_cont(Base64.getStrFromPath(file)).build();
String resumeString = "";
try {
resumeString = resumeSDKUtil.getResumeByCvParser(resumeSdkDto, RESUMESDK_APPCODE);
}catch (Exception e){
e.printStackTrace();
}
JSONObject json = (JSONObject) JSONObject.parse(resumeString);
log.info("招聘-导入候选人简历{}", resumeString);
if(StringUtils.isEmpty(json)){
log.error("招聘-导入候选人简历: resumeSDKUtil.getResumeByCvParser return null. ");
return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
}
Status statusEntity = JSONObject.toJavaObject((JSONObject) json.get("status"), Status.class);
if(StringUtils.isEmpty(statusEntity) || !ResumeSdk.StatusCodeEnum.SUCCESSS.getType().equals(statusEntity.getCode())){
log.error("招聘-导入候选人简历:{}",ResumeSdk.StatusCodeEnum.getName(statusEntity.getCode()));
return ResultUtil.error("导入简历失败,请联系管理员~("+ResumeSdk.StatusCodeEnum.getName(statusEntity.getCode())+")");
}
Result<String> data = ossService.upload(userBean.getOrgCode(), "zpgl", file);
if(!StringUtils.isEmpty(data) && !StringUtils.isEmpty(data.getData())){
importCandidateDto.setFilePath(data.getData());
importCandidateDto.setFileName(file.getOriginalFilename());
}
return this.addZpglRcxx(userBean, json, importCandidateDto);
}
@Override
public boolean updateZpglRcxxZwxx(UserBean userBean, ZpglRcxxDto zpglRcxxDto) {
ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(zpglRcxxDto.getId()).zpglZwxxId(zpglRcxxDto.getZpglZwxxId()).build();
ZpglMslcLog zpglMslcLog = new ZpglMslcLog();
......@@ -439,6 +454,164 @@ public class ZpglServiceImpl implements ZpglService {
}
/**
* 导入简历
* 同步人才信息 教育资讯 基本信息 其他信息 项目信息 工作信息
* @sdkdocs http://www.resumesdk.com/docs/rs-parser.html
* @param json
* @param importCandidateDto
*/
private Result<Object> addZpglRcxx(UserBean userBean, JSONObject json, ImportCandidateDto importCandidateDto) {
ReumeSdkResult reumeSdkResult = JSONObject.toJavaObject((JSONObject) json.get("result"), ReumeSdkResult.class);
if(StringUtils.isEmpty(reumeSdkResult)){
log.info("招聘-导入候选人简历:results is null");
return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
}
ZpglRcxx zpglRcxx = ZpglRcxx.builder().build();
zpglRcxx.setZpglZwxxId(importCandidateDto.getZpglZwxxId());
zpglRcxx.setStatus(importCandidateDto.getStatus());
zpglRcxx.setZpglZpqdId(importCandidateDto.getZpglZpqdId());
zpglRcxx.setOrgCode(userBean.getOrgCode().toString());
zpglRcxx.setFileName(importCandidateDto.getFileName());
zpglRcxx.setFilePath(importCandidateDto.getFilePath());
// 添加人才信息
zpglRcxx.setName(reumeSdkResult.getName());
String phone = reumeSdkResult.getPhone();
if (StringUtils.isEmpty(phone)) {
return ResultUtil.error("导入简历失败,手机号码不存在~");
}
// 查询简历是否重复导入
ZpglRcxx zpglRcxxEntiyt = ZpglRcxx.builder().build().selectOne(new QueryWrapper<ZpglRcxx>().lambda().eq(ZpglRcxx::getMobile, phone).eq(ZpglRcxx::getDeleteFlag, 0));
if (!StringUtils.isEmpty(zpglRcxxEntiyt)) {
return ResultUtil.error("简历已入库,请勿重复导入");
}
zpglRcxx.setMobile(phone);
zpglRcxx.setMail(reumeSdkResult.getEmail());
zpglRcxx.setWeixin(reumeSdkResult.getWeixin());
zpglRcxx.setIdCard(reumeSdkResult.getId_card());
if (!StringUtils.isEmpty(reumeSdkResult.getGender())) {
zpglRcxx.setSex(reumeSdkResult.getGender().indexOf("男") != -1 ? 0 : 1);
}
//出生日期,格式化为 年.月,如2000.01,若只有年,则只显示年,如2000
if (!StringUtils.isEmpty(reumeSdkResult.getBirthday()) && reumeSdkResult.getBirthday().length() > 0) {
zpglRcxx.setDatebirth(this.getDate(reumeSdkResult.getBirthday()));
}
if (!StringUtils.isEmpty(reumeSdkResult.getRace())) {
NationClass nationClass = NationClass.builder().build().selectOne(new QueryWrapper<NationClass>().lambda().like(NationClass::getName, reumeSdkResult.getRace()));
if (!StringUtils.isEmpty(nationClass)) {
zpglRcxx.setNationClassId(nationClass.getId());
}
}
// 身高
if(!StringUtils.isEmpty(reumeSdkResult.getHeight())){
String[] height = reumeSdkResult.getHeight().split("cm");
if(height.length > 0){
zpglRcxx.setHeight(Integer.parseInt(height[0]));
}
}
// 体重
if(!StringUtils.isEmpty(reumeSdkResult.getWeight())){
String[] height = reumeSdkResult.getWeight().split("kg");
if(height.length > 0){
zpglRcxx.setWeight(Integer.parseInt(height[0]));
}
}
zpglRcxx.setNativePlace(reumeSdkResult.getNationality());
zpglRcxx.setAddress(reumeSdkResult.getLiving_address());
zpglRcxx.setUniversitie(reumeSdkResult.getCollege());
if(!StringUtils.isEmpty(reumeSdkResult.getDegree())){
zpglRcxx.setHighesteducation(this.getEducation(reumeSdkResult.getDegree())+"");
}
if (!StringUtils.isEmpty(reumeSdkResult.getWork_year_norm())) {
if(reumeSdkResult.getWork_year_norm().indexOf(".") != -1){
zpglRcxx.setWorkyears(Integer.parseInt(reumeSdkResult.getWork_year_norm().split(".")[0])+1);
}else {
zpglRcxx.setWorkyears(Integer.parseInt(reumeSdkResult.getWork_year_norm()));
}
}
if(!StringUtils.isEmpty(reumeSdkResult.getExpect_salary_max())){
zpglRcxx.setSalary(Integer.parseInt(reumeSdkResult.getExpect_salary_max()));
}
zpglRcxx.setCompany(reumeSdkResult.getWork_company());
zpglRcxx.setZjzw(reumeSdkResult.getWork_position());
zpglRcxx.insert();
if (!StringUtils.isEmpty(zpglRcxx.getId())) {
// 添加教育经历
if (!StringUtils.isEmpty(reumeSdkResult.getEducation_objs())) {
ZpglRcxxStudy zpglRcxxStudy = ZpglRcxxStudy.builder().zpglRcxxId(zpglRcxx.getId()).build();
List<Education_objs> list = reumeSdkResult.getEducation_objs();
for (Education_objs entity : list) {
if (!StringUtils.isEmpty(entity.getStart_date()) && entity.getStart_date().length() > 0) {
zpglRcxxStudy.setStartTime(this.getDate(entity.getStart_date()));
}
if (!StringUtils.isEmpty(entity.getEnd_date()) && entity.getEnd_date().length() > 0) {
zpglRcxxStudy.setEndTime(this.getDate(entity.getEnd_date()));
}
zpglRcxxStudy.setSubject(entity.getEdu_major());
zpglRcxxStudy.setSchoolName(entity.getEdu_college());
zpglRcxxStudy.setEducation(this.getEducation(entity.getEdu_degree_norm()));
zpglRcxxStudy.insert();
}
}
// 添加工作经验
if (!StringUtils.isEmpty(reumeSdkResult.getJob_exp_objs())) {
ZpglRcxxExperience zpglRcxxExperience = ZpglRcxxExperience.builder().zpglRcxxId(zpglRcxx.getId()).build();
List<Job_exp_objs> list = reumeSdkResult.getJob_exp_objs();
for (Job_exp_objs entity : list) {
zpglRcxxExperience.setCompany(entity.getJob_cpy());
zpglRcxxExperience.setJobName(entity.getJob_position());
zpglRcxxExperience.setDepartment(entity.getJob_dept());
zpglRcxxExperience.setWorkContent(entity.getJob_content());
zpglRcxxExperience.setReason(entity.getJob_why_leave());
if (!StringUtils.isEmpty(entity.getEnd_date()) && entity.getEnd_date().length() > 0) {
zpglRcxxExperience.setEndTime(this.getDate(entity.getEnd_date()));
}
if (!StringUtils.isEmpty(entity.getStart_date()) && entity.getStart_date().length() > 0) {
zpglRcxxExperience.setStartTime(this.getDate(entity.getStart_date()));
}
zpglRcxxExperience.insert();
}
}
// 添加项目信息
if (!StringUtils.isEmpty(reumeSdkResult.getProj_exp_objs())) {
ZpglRcxxProject zpglRcxxProject = ZpglRcxxProject.builder().zpglRcxxId(zpglRcxx.getId()).build();
List<Proj_exp_objs> list = reumeSdkResult.getProj_exp_objs();
for (Proj_exp_objs entity : list) {
zpglRcxxProject.setProjectDescribe(entity.getProj_content());
zpglRcxxProject.setDuty(entity.getProj_resp());
zpglRcxxProject.setJob(entity.getProj_position());
zpglRcxxProject.setProjectName(entity.getProj_name());
if (!StringUtils.isEmpty(entity.getStart_date()) && entity.getStart_date().length() > 0) {
zpglRcxxProject.setStartTime(this.getDate(entity.getStart_date()));
}
if (!StringUtils.isEmpty(entity.getEnd_date()) && entity.getEnd_date().length() > 0) {
zpglRcxxProject.setEndTime(this.getDate(entity.getEnd_date()));
}
zpglRcxxProject.insert();
}
}
// 添加培训经历
if (!StringUtils.isEmpty(reumeSdkResult.getTraining_objs())) {
ZpglRcxxTrain zpglRcxxTrain = ZpglRcxxTrain.builder().zpglRcxxId(zpglRcxx.getId()).build();
List<Training_objs> list = reumeSdkResult.getTraining_objs();
for (Training_objs entity : list) {
zpglRcxxTrain.setTrainCompany(entity.getTrain_org());
zpglRcxxTrain.setTrainContent(entity.getTrain_cont());
if (!StringUtils.isEmpty(entity.getStart_date()) && entity.getStart_date().length() > 0) {
zpglRcxxTrain.setStartTime(this.getDate(entity.getStart_date()));
}
if (!StringUtils.isEmpty(entity.getEnd_date()) && entity.getEnd_date().length() > 0) {
zpglRcxxTrain.setEndTime(this.getDate(entity.getEnd_date()));
}
zpglRcxxTrain.insert();
}
}
}
return ResultUtil.success();
}
/**
* 根据string时间获取date(2019-10或2019)
*
* @param date
......@@ -446,6 +619,7 @@ public class ZpglServiceImpl implements ZpglService {
*/
private Date getDate(String date) {
String datebirth = "";
date.replace(".","-");
String[] num = date.split("-");
if (num.length == 1) {
datebirth = num[0] + "-1-1";
......@@ -467,13 +641,16 @@ public class ZpglServiceImpl implements ZpglService {
return education;
}
// 博士研究生/硕士研究生/本科/专科/高中/中专/初中
// 小学、初中、高中、中专、大专、本科、硕士研究生、博士研究生、博士后、mba
if (str.indexOf("初中") != -1) {
education = 2;
} else if (str.indexOf("中专") != -1) {
} else if (str.indexOf("小学") != -1) {
education = 1;
}else if (str.indexOf("中专") != -1) {
education = 4;
} else if (str.indexOf("高中") != -1) {
education = 3;
} else if (str.indexOf("专科") != -1) {
} else if (str.indexOf("专科") != -1 || str.indexOf("大专") != -1) {
education = 5;
} else if (str.indexOf("本科") != -1) {
education = 6;
......
......@@ -55,7 +55,12 @@ public class Job_exp_objs implements Serializable {
* 工作性质 全职、兼职、实习
*/
private String job_nature;
/**
* 所在部门,部门名称
*/
private String job_dept;
/**
* 离职原因
*/
private String job_why_leave;
}
......@@ -19,7 +19,7 @@ import java.io.Serializable;
public class JsonRootBean implements Serializable {
private Status status;
private Result result;
private ReumeSdkResult result;
private Eval eval;
private Tags tags;
......
......@@ -18,7 +18,7 @@ import java.util.List;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Result implements Serializable {
public class ReumeSdkResult implements Serializable {
private String name;
private String gender;
......@@ -29,7 +29,7 @@ public class Result implements Serializable {
private String surname;
private String height;
private String weight;
private Date birthday;
private String birthday;
private String city_norm;
private String college;
private String college_type;
......@@ -39,6 +39,7 @@ public class Result implements Serializable {
private String city;
private String grad_time;
private String degree;
private String id_card;
private String race;
private String nationality;
private String english_level;
......
package cn.timer.api.dto.resumesdk.enumresume;
import lombok.Getter;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.springframework.util.StringUtils;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022/4/24
*/
public interface ResumeSdk {
/**
* 200 正常状态,表示解析成功
* 250 账号(uid)或密码(pwd)错误
* 251 账号剩余用量为0(需及时充值)
* 260 请求参数错误
* 261 简历内容为空
* 262 简历内容过长
* 263 不支持的简历文件格式
* 264 base64解码出错
* 265 图片文件过大,或者长宽大小超过限制
* 266 输入参数file_name缺少文件后缀名(请带上正确的文件后缀,如果是纯文本则为.txt)
* 267 输入的json结构体有误(即解码失败)
* 240 简历解析内部错误
* 280 人岗匹配内部错误
*/
@Getter
enum StatusCodeEnum implements ResumeSdk {
SUCCESSS(200, "解析成功"),
ERROR250(250, "账号(uid)或密码(pwd)错误"),
ERROR251(251, "账号剩余用量为0(需及时充值)"),
ERROR260(260, "请求参数错误"),
ERROR261(261, "简历内容为空"),
ERROR262(262, "简历内容过长"),
ERROR263(263, "不支持的简历文件格式"),
ERROR264(264, "base64解码出错"),
ERROR265(265, "图片文件过大,或者长宽大小超过限制"),
ERROR266(266, "输入参数file_name缺少文件后缀名(请带上正确的文件后缀,如果是纯文本则为.txt)"),
ERROR267(267, "输入的json结构体有误(即解码失败)"),
ERROR240(240, "简历解析内部错误"),
ERROR280(280, "人岗匹配内部错误");
private Integer type;
private String name;
StatusCodeEnum(Integer type, String name) {
this.type = type;
this.name = name;
}
public static String getName(Integer type){
if(type < 0){
return "";
}
for(StatusCodeEnum.StatusCodeEnum statusCodeEnum : StatusCodeEnum.StatusCodeEnum.values()){
if(statusCodeEnum.getType() == type){
return statusCodeEnum.name;
}
}
return "";
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment