AI 优化修改点逻辑处理

This commit is contained in:
2026-01-18 11:21:34 +08:00
parent 7ceeb37b92
commit 6fa40308ee
6 changed files with 149 additions and 48 deletions

View File

@@ -93,6 +93,9 @@ public class HotakeCvInfo extends BaseEntity
@ApiModelProperty("逻辑修正的数量")
private Integer logicCorrectionsNum;
@ApiModelProperty("数据类型(import:导入,manual:手动,Link:链接)")
private String dataType;
@ApiModelProperty("简历分析结果数据")
private HotakeCvOptimizeDto cvOptimizeDto;

View File

@@ -8,8 +8,10 @@ import cn.hutool.json.JSONUtil;
import com.vetti.common.ai.gpt.ChatGPTClient;
import com.vetti.common.config.RuoYiConfig;
import com.vetti.common.core.service.BaseServiceImpl;
import com.vetti.common.enums.CvOperDataTypeEnum;
import com.vetti.common.enums.FillTypeEnum;
import com.vetti.common.enums.MinioBucketNameEnum;
import com.vetti.common.exception.ServiceException;
import com.vetti.common.utils.*;
import com.vetti.common.utils.readFile.FileContentUtil;
import com.vetti.hotake.domain.HotakeCvInfo;
@@ -158,6 +160,20 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC
String resultStr = handleAnalyzedAttachment(hotakeCvInfo.getCvUrl(), fileSuffix);
hotakeCvInfo.setAnalyzedAttachmentJson(resultStr);
}
if("cv".equals(hotakeCvInfo.getCvFileType())) {
hotakeCvInfo.setCvTemplateJson(JSONUtil.toJsonStr(hotakeCvInfo.getCvInfoDto()));
//如果是手动创建的简历要生成简历的附件数据
if(CvOperDataTypeEnum.MANUAL.getCode().equals(hotakeCvInfo.getDataType())){
if(StrUtil.isNotEmpty(hotakeCvInfo.getCvTemplateJson())){
HotakeSysFile sysFile = createCvFile(hotakeCvInfo.getCvTemplateJson());
hotakeCvInfo.setCvName(sysFile.getFileName());
hotakeCvInfo.setFileSizeShow(sysFile.getFileSizeShow());
hotakeCvInfo.setCvUrl(sysFile.getStoragePath());
}
}
}
hotakeCvInfoMapper.insertHotakeCvInfo(hotakeCvInfo);
return hotakeCvInfo;
}
@@ -225,11 +241,19 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC
fill(FillTypeEnum.UPDATE.getCode(), hotakeCvInfo);
hotakeCvInfo.setCvTemplateJson(JSONUtil.toJsonStr(hotakeCvInfo.getCvInfoDto()));
//修改的时候重新生成问题和评分
//创建简历
if("cv".equals(hotakeCvInfo.getCvFileType())) {
//如果是手动创建的简历要生成简历的附件数据
if(CvOperDataTypeEnum.MANUAL.getCode().equals(hotakeCvInfo.getDataType())){
if(StrUtil.isNotEmpty(hotakeCvInfo.getCvTemplateJson())){
HotakeSysFile sysFile = createCvFile(hotakeCvInfo.getCvTemplateJson());
hotakeCvInfo.setCvName(sysFile.getFileName());
hotakeCvInfo.setFileSizeShow(sysFile.getFileSizeShow());
hotakeCvInfo.setCvUrl(sysFile.getStoragePath());
}
}
}
hotakeCvInfoMapper.updateHotakeCvInfo(hotakeCvInfo);
return hotakeCvInfo;
}
@@ -406,12 +430,12 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC
//个人介绍
cvInfoDto.setAbout(StringUtils.getObjectStr(dataMap.get("professional_summary")));
try{
try {
//技能工具
List<Map> skillsList = (List<Map>) dataMap.get("skills_certificates");
if(CollectionUtil.isNotEmpty(skillsList)){
if (CollectionUtil.isNotEmpty(skillsList)) {
Map map = skillsList.get(0);
if(map != null){
if (map != null) {
List<String> skillsAllList = (List<String>) map.get("skills");
//技能工具
List<VcSkillsToolsDto> skillsTools = new ArrayList<>();
@@ -426,10 +450,10 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC
}
}
}catch (Exception e){
} catch (Exception e) {
//技能工具
List<String> skillsList = (List<String>) dataMap.get("skills_certificates");
if(CollectionUtil.isNotEmpty(skillsList)){
if (CollectionUtil.isNotEmpty(skillsList)) {
//技能工具
List<VcSkillsToolsDto> skillsTools = new ArrayList<>();
if (CollectionUtil.isNotEmpty(skillsList)) {
@@ -501,44 +525,12 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC
cvInfo.setCvFileSuffix("pdf");
cvInfo.setStatus("1");
//生成简历PDF数据
String markdown = aiCommonToolsService.handleGenerateMarkdown(cvData);
markdown = markdown.replaceAll("markdown", "");
try {
String html = MarkdownUtil.markdownToHtml(markdown);
// 可注入 CSS
html = """
<html>
<head>
<style>
body { font-family: SimSun; }
h1 { color: #2c3e50; }
</style>
</head>
<body>
""" + html + """
</body>
</html>
""";
//生成PDF文件
String resultFileName = SecurityUtils.getUsername() + "_" + System.currentTimeMillis() + ".pdf";
cvInfo.setCvName(resultFileName);
String resultPathUrl = RuoYiConfig.getProfile() + SYSTEM_DIR + resultFileName;
HtmlToPdfUtil.htmlToPdf(html, resultPathUrl);
//上传到minio中
File pdf = new File(resultPathUrl);
MultipartFile multipartFile =
MultipartFileUtil.fileToMultipartFile(pdf);
HotakeSysFileVo fileVo = new HotakeSysFileVo();
fileVo.setMinioBucketName("cv-fs");
HotakeSysFile sysFile = sysFileService.insertHotakeSysFile(multipartFile, fileVo);
cvInfo.setFileSizeShow(sysFile.getFileSizeShow());
cvInfo.setCvUrl(sysFile.getStoragePath());
//创建简历对象数据
insertHotakeCvInfo(cvInfo);
//保存简历PDF附件数据
// log.info("Markdown数据为:{}",markdown);
} catch (Exception e) {
}
HotakeSysFile sysFile = createCvFile(cvData);
cvInfo.setCvName(sysFile.getFileName());
cvInfo.setFileSizeShow(sysFile.getFileSizeShow());
cvInfo.setCvUrl(sysFile.getStoragePath());
//创建简历对象数据
insertHotakeCvInfo(cvInfo);
return cvInfo;
}
@@ -742,5 +734,46 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC
return "";
}
/**
* 创建简历附件信息
*
* @param connect 简历内容
*/
private HotakeSysFile createCvFile(String connect) {
try {
String markdown = aiCommonToolsService.handleGenerateMarkdown(connect);
markdown = markdown.replaceAll("markdown", "");
String html = MarkdownUtil.markdownToHtml(markdown);
// 可注入 CSS
html = """
<html>
<head>
<style>
body { font-family: SimSun; }
h1 { color: #2c3e50; }
</style>
</head>
<body>
""" + html + """
</body>
</html>
""";
//生成PDF文件
String resultFileName = SecurityUtils.getUsername() + "_" + System.currentTimeMillis() + ".pdf";
String resultPathUrl = RuoYiConfig.getProfile() + SYSTEM_DIR + resultFileName;
HtmlToPdfUtil.htmlToPdf(html, resultPathUrl);
//上传到minio中
File pdf = new File(resultPathUrl);
MultipartFile multipartFile =
MultipartFileUtil.fileToMultipartFile(pdf);
HotakeSysFileVo fileVo = new HotakeSysFileVo();
fileVo.setMinioBucketName("cv-fs");
HotakeSysFile sysFile = sysFileService.insertHotakeSysFile(multipartFile, fileVo);
return sysFile;
} catch (Exception e) {
throw new ServiceException("Resume creation exception, please contact the administrator");
}
}
}