1.完成生成简历
This commit is contained in:
12
pom.xml
12
pom.xml
@@ -27,7 +27,7 @@
|
||||
<fastjson.version>2.0.43</fastjson.version>
|
||||
<oshi.version>6.6.1</oshi.version>
|
||||
<commons.io.version>2.13.0</commons.io.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<poi.version>5.2.2</poi.version>
|
||||
<velocity.version>2.3</velocity.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<mybatis-plus.version>3.5.1</mybatis-plus.version>
|
||||
@@ -121,6 +121,16 @@
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- velocity代码生成使用模板 -->
|
||||
<dependency>
|
||||
|
||||
@@ -111,6 +111,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.deepoove</groupId>
|
||||
<artifactId>poi-tl</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,6 +1,13 @@
|
||||
package com.ruoyi.cms.controller.app;
|
||||
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.deepoove.poi.util.PoitlIOUtils;
|
||||
import com.ruoyi.cms.domain.AppReviewJob;
|
||||
import com.ruoyi.cms.util.DictUtils;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.common.core.domain.entity.AppSkill;
|
||||
import com.ruoyi.common.core.domain.entity.AppUser;
|
||||
import com.ruoyi.common.core.domain.entity.Company;
|
||||
import com.ruoyi.cms.domain.Job;
|
||||
@@ -11,6 +18,7 @@ import com.ruoyi.common.annotation.BussinessLog;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.cms.domain.vo.AppUserLky;
|
||||
import com.ruoyi.common.core.domain.entity.UserWorkExperiences;
|
||||
import com.ruoyi.common.core.domain.model.RegisterBody;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
@@ -21,9 +29,13 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* app用户Controller
|
||||
@@ -180,4 +192,63 @@ public class AppUserController extends BaseController
|
||||
appReviewJob.setUserId(SiteSecurityUtils.getUserId());
|
||||
return toAjax(appReviewJobService.insertAppReviewJob(appReviewJob));
|
||||
}
|
||||
|
||||
@ApiOperation("生成简历")
|
||||
@GetMapping("/createResume")
|
||||
public void createResume(HttpServletResponse response){
|
||||
try {
|
||||
Long userId=null;
|
||||
if(SiteSecurityUtils.isLogin()){
|
||||
userId=SiteSecurityUtils.getUserId();
|
||||
}
|
||||
String templatePath="/data/downloadmodel/简历.docx";
|
||||
AppUser result=appUserService.selectAppUserByUserId(userId);
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("name", result.getName());
|
||||
dataMap.put("sex", DictUtils.getDictLabel("app_sex",result.getSex()));
|
||||
dataMap.put("birthDate", StringUtil.getBirthDateFromIdCard(result.getIdCard()));
|
||||
dataMap.put("education", DictUtils.getDictLabel("education",result.getEducation()));
|
||||
dataMap.put("politicalAffiliation", DictUtils.getDictLabel("political_affiliation",result.getPoliticalAffiliation()));
|
||||
dataMap.put("nation", DictUtils.getDictLabel("nation",result.getNation()));
|
||||
dataMap.put("domicileAddress", result.getDomicileAddress());
|
||||
dataMap.put("address", result.getAddress());
|
||||
String salary=result.getSalaryMin()+"-"+result.getSalaryMax();
|
||||
dataMap.put("salary", salary);
|
||||
dataMap.put("area", DictUtils.getDictLabel("area",result.getArea()));
|
||||
dataMap.put("jobTitle", String.join(",",result.getJobTitle()));
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
Configure builder = Configure.builder()
|
||||
.bind("workExperiences",policy)
|
||||
.bind("skillList",policy)
|
||||
.build();
|
||||
|
||||
List<UserWorkExperiences> userWorkExperiences = result.getExperiencesList();
|
||||
List<AppSkill> skillList=result.getAppSkillsList();
|
||||
skillList.forEach(it->it.setLevels(DictUtils.getDictLabel("skill_level",it.getLevels())));
|
||||
|
||||
dataMap.put("workExperiences", userWorkExperiences);
|
||||
dataMap.put("skillList", skillList);
|
||||
|
||||
String name=result.getName();
|
||||
name = new String(name.getBytes("gb2312"), "ISO8859-1");
|
||||
XWPFTemplate template = XWPFTemplate.compile(templatePath,builder).render(dataMap);
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename="+ name);
|
||||
response.setHeader("Pragma", "public");
|
||||
response.setHeader("Cache-Control", "max-age=0");
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
BufferedOutputStream bos = new BufferedOutputStream(out);
|
||||
template.write(bos);
|
||||
bos.flush();
|
||||
out.flush();
|
||||
PoitlIOUtils.closeQuietlyMulti(template, bos, out);
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.ruoyi.cms.controller.cms;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.deepoove.poi.util.PoitlIOUtils;
|
||||
import com.ruoyi.cms.domain.AppReviewJob;
|
||||
import com.ruoyi.cms.domain.vo.AppUserLky;
|
||||
import com.ruoyi.cms.service.IAppReviewJobService;
|
||||
@@ -13,11 +17,13 @@ import com.ruoyi.cms.util.RoleUtils;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.annotation.BussinessLog;
|
||||
import com.ruoyi.common.core.domain.entity.AppSkill;
|
||||
import com.ruoyi.common.core.domain.entity.AppUserShow;
|
||||
import com.ruoyi.common.core.domain.entity.UserWorkExperiences;
|
||||
import com.ruoyi.common.core.domain.model.RegisterBody;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.SiteSecurityUtils;
|
||||
import com.ruoyi.cms.util.DictUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -297,4 +303,63 @@ public class CmsAppUserController extends BaseController
|
||||
return error("查询简历失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("生成简历")
|
||||
@GetMapping("/createResume")
|
||||
public void createResume(HttpServletResponse response){
|
||||
try {
|
||||
Long userId=null;
|
||||
if(SecurityUtils.isLogin()){
|
||||
userId=SecurityUtils.getUserId();
|
||||
}
|
||||
String templatePath="/data/downloadmodel/简历.docx";
|
||||
AppUser result=appUserService.selectAppUserByUserId(userId);
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("name", result.getName());
|
||||
dataMap.put("sex", DictUtils.getDictLabel("app_sex",result.getSex()));
|
||||
dataMap.put("birthDate", StringUtil.getBirthDateFromIdCard(result.getIdCard()));
|
||||
dataMap.put("education", DictUtils.getDictLabel("education",result.getEducation()));
|
||||
dataMap.put("politicalAffiliation", DictUtils.getDictLabel("political_affiliation",result.getPoliticalAffiliation()));
|
||||
dataMap.put("nation", DictUtils.getDictLabel("nation",result.getNation()));
|
||||
dataMap.put("domicileAddress", result.getDomicileAddress());
|
||||
dataMap.put("address", result.getAddress());
|
||||
String salary=result.getSalaryMin()+"-"+result.getSalaryMax();
|
||||
dataMap.put("salary", salary);
|
||||
dataMap.put("area", DictUtils.getDictLabel("area",result.getArea()));
|
||||
dataMap.put("jobTitle", String.join(",",result.getJobTitle()));
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
Configure builder = Configure.builder()
|
||||
.bind("workExperiences",policy)
|
||||
.bind("skillList",policy)
|
||||
.build();
|
||||
|
||||
List<UserWorkExperiences> userWorkExperiences = result.getExperiencesList();
|
||||
List<AppSkill> skillList=result.getAppSkillsList();
|
||||
skillList.forEach(it->it.setLevels(DictUtils.getDictLabel("skill_level",it.getLevels())));
|
||||
|
||||
dataMap.put("workExperiences", userWorkExperiences);
|
||||
dataMap.put("skillList", skillList);
|
||||
|
||||
String name=result.getName();
|
||||
name = new String(name.getBytes("gb2312"), "ISO8859-1");
|
||||
XWPFTemplate template = XWPFTemplate.compile(templatePath,builder).render(dataMap);
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename="+ name);
|
||||
response.setHeader("Pragma", "public");
|
||||
response.setHeader("Cache-Control", "max-age=0");
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
BufferedOutputStream bos = new BufferedOutputStream(out);
|
||||
template.write(bos);
|
||||
bos.flush();
|
||||
out.flush();
|
||||
PoitlIOUtils.closeQuietlyMulti(template, bos, out);
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class DictUtils
|
||||
{
|
||||
for (String value : dictValue.split(separator))
|
||||
{
|
||||
if (value.equals(dict.getDictValue()))
|
||||
if (value.trim().equals(dict.getDictValue().trim()))
|
||||
{
|
||||
propertyString.append(dict.getDictLabel()).append(separator);
|
||||
break;
|
||||
@@ -115,7 +115,7 @@ public class DictUtils
|
||||
{
|
||||
for (BussinessDictData dict : datas)
|
||||
{
|
||||
if (dictValue.equals(dict.getDictValue()))
|
||||
if (dictValue.trim().equals(dict.getDictValue().trim()))
|
||||
{
|
||||
return dict.getDictLabel();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.cms.util;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -315,4 +316,31 @@ public class StringUtil {
|
||||
.filter(StringUtils::hasText)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 从身份证号码中提取出生日期,格式化为 YYYY-MM-DD
|
||||
* @param idCard 身份证号码(15位或18位)
|
||||
* @return 格式化后的出生日期,解析失败返回空字符串
|
||||
*/
|
||||
public static String getBirthDateFromIdCard(String idCard) {
|
||||
if (idCard == null || (idCard.length() != 15 && idCard.length() != 18)) {
|
||||
return "";
|
||||
}
|
||||
String birthDateStr = "";
|
||||
try {
|
||||
if (idCard.length() == 18) {
|
||||
birthDateStr = idCard.substring(6, 14);
|
||||
} else if (idCard.length() == 15) {
|
||||
birthDateStr = "20" + idCard.substring(6, 12);
|
||||
}
|
||||
|
||||
SimpleDateFormat sdfInput = new SimpleDateFormat("yyyyMMdd");
|
||||
SimpleDateFormat sdfOutput = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date birthDate = sdfInput.parse(birthDateStr);
|
||||
return sdfOutput.format(birthDate);
|
||||
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user