Explorar o código

1、优化求职意向返回

rayson hai 7 meses
pai
achega
55d8f271d7

+ 90 - 1
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/controller/admin/job/JobInterestedController.java

@@ -10,7 +10,10 @@ import com.citu.module.menduner.system.controller.base.job.interested.JobInteres
 import com.citu.module.menduner.system.controller.base.job.interested.JobInterestedRespVO;
 import com.citu.module.menduner.system.controller.base.job.interested.JobInterestedSaveReqVO;
 import com.citu.module.menduner.system.dal.dataobject.job.JobInterestedDO;
+import com.citu.module.menduner.system.service.area.AreaService;
+import com.citu.module.menduner.system.service.industry.IndustryService;
 import com.citu.module.menduner.system.service.job.JobInterestedService;
+import com.citu.module.menduner.system.service.position.PositionService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -23,6 +26,11 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import static com.citu.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static com.citu.framework.common.pojo.CommonResult.success;
@@ -36,6 +44,15 @@ public class JobInterestedController {
     @Resource
     private JobInterestedService jobInterestedService;
 
+    @Resource
+    private PositionService positionService;
+
+    @Resource
+    private IndustryService industryService;
+
+    @Resource
+    private AreaService areaService;
+
     @PostMapping("/create")
     @Operation(summary = "创建求职意向")
     @PreAuthorize("@ss.hasPermission('menduner:system:job-interested:create')")
@@ -74,7 +91,79 @@ public class JobInterestedController {
     @PreAuthorize("@ss.hasPermission('menduner:system:job-interested:query')")
     public CommonResult<PageResult<JobInterestedRespVO>> getJobInterestedPage(@Valid JobInterestedPageReqVO pageReqVO) {
         PageResult<JobInterestedDO> pageResult = jobInterestedService.getJobInterestedPage(pageReqVO);
-        return success(BeanUtils.toBean(pageResult, JobInterestedRespVO.class));
+        PageResult<JobInterestedRespVO> result = BeanUtils.toBean(pageResult, JobInterestedRespVO.class);
+        // 职位类型
+        Map<Long, String> positionMap = positionService.getNameByIds(
+                result.getList().stream().map(JobInterestedRespVO::getPositionId)
+                        .collect(Collectors.toSet()));
+
+        // 行业
+        Set<Long> industryIds = result.getList().stream()
+                .flatMap(resp -> resp.getIndustryIdList().stream())
+                .map(s -> {
+                    try {
+                        return Long.parseLong(s);  // 将字符串转换为 Long
+                    } catch (NumberFormatException e) {
+                        // 忽略无法转换的字符串
+                        return null;
+                    }
+                })
+                .filter(java.util.Objects::nonNull)
+                .collect(Collectors.toSet());
+        Map<Long, String> industryMap = industryService.getIndustryTitleByIds(industryIds);
+
+
+        // 区域
+        Set<Long> areaIds = result.getList().stream()
+                .flatMap(resp -> Stream.concat(
+                        resp.getInterestedAreaIdList().stream()
+                                .map(s -> {
+                                    try {
+                                        return Long.parseLong(s);  // 将字符串转换为 Long
+                                    } catch (NumberFormatException e) {
+                                        // 忽略无法转换的字符串
+                                        return null;
+                                    }
+                                }),
+                        Stream.of(resp.getWorkAreaId())  // 添加 areaId 字段
+                ))
+                .filter(java.util.Objects::nonNull)  // 过滤掉 null 值
+                .collect(Collectors.toSet());  // 收集结果到 Set<Long>
+
+        Map<Long, String> areaMap = areaService.getNameByIds(areaIds);
+
+        result.getList().forEach(item -> {
+            if (null != item.getPositionId()) {
+                String positionName = positionMap.get(item.getPositionId());
+                if (null != positionName) {
+                    item.setPositionName(positionName);
+                }
+
+                if (null != item.getWorkAreaId()) {
+                    String workaroundId = areaMap.get(item.getWorkAreaId());
+                    if (null != workaroundId) {
+                        item.setWorkAreaName(workaroundId);
+                    }
+                }
+
+                if(!item.getIndustryIdList().isEmpty()) {
+                    item.setIndustryNameList(item.getIndustryIdList().stream()
+                            .map(industry-> industryMap.get(Long.valueOf(industry)))
+                            .filter(Objects::nonNull)
+                            .collect(Collectors.toList()));
+                }
+
+                if(!item.getInterestedAreaIdList().isEmpty()) {
+                    item.setInterestedAreaNameList(item.getInterestedAreaIdList().stream()
+                            .map(area-> areaMap.get(Long.valueOf(area)))
+                            .filter(Objects::nonNull)
+                            .collect(Collectors.toList()));
+                }
+
+            }
+
+        });
+        return success(result);
     }
 
     @GetMapping("/export-excel")

+ 16 - 0
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/controller/base/job/interested/JobInterestedRespVO.java

@@ -33,10 +33,18 @@ public class JobInterestedRespVO {
     @ExcelProperty("期望职位")
     private Long positionId;
 
+    @Schema(description = "期望职位名称", example = "20359")
+    @ExcelProperty("期望职位名称")
+    private String positionName;
+
     @Schema(description = "期望行业")
     @ExcelProperty("期望行业")
     private List<String> industryIdList;
 
+    @Schema(description = "期望行业名称")
+    @ExcelProperty("期望行业名称")
+    private List<String> industryNameList;
+
     @Schema(description = "薪酬最低要求")
     @ExcelProperty("薪酬最低要求")
     private BigDecimal payFrom;
@@ -49,10 +57,18 @@ public class JobInterestedRespVO {
     @ExcelProperty("工作城市")
     private Long workAreaId;
 
+    @Schema(description = "工作城市名称", example = "15253")
+    @ExcelProperty("工作城市名称")
+    private String workAreaName;
+
     @Schema(description = "感兴趣城市")
     @ExcelProperty("感兴趣城市")
     private List<String> interestedAreaIdList;
 
+    @Schema(description = "感兴趣城市名称")
+    @ExcelProperty("感兴趣城市名称")
+    private List<String> interestedAreaNameList;
+
     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("创建时间")
     private LocalDateTime createTime;

+ 5 - 0
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/area/AreaService.java

@@ -125,4 +125,9 @@ public interface AreaService {
      * 获取热门城市
      **/
     List<AppAreaHotRespVO> getHotArea();
+
+    /**
+     * 根据id集合获取名称集合
+     **/
+    Map<Long, String> getNameByIds(Set<Long> ids);
 }

+ 12 - 2
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/area/AreaServiceImpl.java

@@ -200,13 +200,13 @@ public class AreaServiceImpl implements AreaService {
     @Override
     @Cacheable(cacheNames = RedisKeyConstants.MDE_AREA_MAP, unless = "#result.size==0")
     public Map<Long, AppAreaSimpleRespVO> getAreaMap() {
-        List<AppAreaSimpleRespVO> list= AreaConvert.INSTANCE.convertList2(areaMapper.selectList());
+        List<AppAreaSimpleRespVO> list = AreaConvert.INSTANCE.convertList2(areaMapper.selectList());
         return list.stream().collect(Collectors.toMap(AppAreaSimpleRespVO::getId, Function.identity()));
     }
 
     @Override
     /** 30分钟过期一次 {@link TimeoutRedisCacheManager} **/
-    @Cacheable(cacheNames = RedisKeyConstants.MDE_AREA_HOT_LIST+"#30m", unless = "#result.size==0")
+    @Cacheable(cacheNames = RedisKeyConstants.MDE_AREA_HOT_LIST + "#30m", unless = "#result.size==0")
     public List<AppAreaHotRespVO> getHotArea() {
         List<AreaHotDO> hotList = hotMapper.selectList();
         if (CollUtil.isEmpty(hotList)) {
@@ -279,4 +279,14 @@ public class AreaServiceImpl implements AreaService {
     public void removeHotArea(Long id) {
         hotMapper.deleteById(id);
     }
+
+    @Override
+    public Map<Long, String> getNameByIds(Set<Long> ids) {
+        if (ids.isEmpty()) {
+            return new HashMap<>();
+        }
+
+        List<AreaDO> areaList = areaMapper.selectBatchIds(ids);
+        return areaList.stream().collect(Collectors.toMap(AreaDO::getId, AreaDO::getName));
+    }
 }

+ 12 - 4
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/position/PositionService.java

@@ -1,18 +1,19 @@
 package com.citu.module.menduner.system.service.position;
 
 import com.citu.framework.common.pojo.PageResult;
-
 import com.citu.module.menduner.system.controller.app.jobhunt.position.vo.AppPositionChildrenRespVO;
-import com.citu.module.menduner.system.controller.base.position.PositionListReqVO;
-import com.citu.module.menduner.system.controller.base.position.PositionPageReqVO;
-import com.citu.module.menduner.system.controller.base.position.PositionSaveReqVO;
 import com.citu.module.menduner.system.controller.app.jobhunt.position.vo.AppPositionClickReqVO;
 import com.citu.module.menduner.system.controller.app.jobhunt.position.vo.AppPositionListReqVO;
 import com.citu.module.menduner.system.controller.app.jobhunt.position.vo.AppPositionSimpleRespVO;
+import com.citu.module.menduner.system.controller.base.position.PositionListReqVO;
+import com.citu.module.menduner.system.controller.base.position.PositionPageReqVO;
+import com.citu.module.menduner.system.controller.base.position.PositionSaveReqVO;
 import com.citu.module.menduner.system.dal.dataobject.position.PositionDO;
 
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * 职位信息 Service 接口
@@ -83,6 +84,7 @@ public interface PositionService {
     void syncVeryeastPosition();
 
     // ========== 求职端 ==========
+
     /**
      * 根据职位id获得职位列表
      *
@@ -101,6 +103,7 @@ public interface PositionService {
 
     /**
      * 获取职位信息
+     *
      * @return 热门职位列表
      **/
     List<AppPositionSimpleRespVO> getHotPosition();
@@ -112,4 +115,9 @@ public interface PositionService {
      **/
     List<AppPositionSimpleRespVO> getPositionList(AppPositionListReqVO reqVO);
 
+
+    /**
+     * 获取职位名称集合
+     **/
+    Map<Long, String> getNameByIds(Set<Long> ids);
 }

+ 11 - 0
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/position/PositionServiceImpl.java

@@ -12,6 +12,7 @@ import com.citu.module.menduner.system.controller.base.position.PositionListReqV
 import com.citu.module.menduner.system.controller.base.position.PositionPageReqVO;
 import com.citu.module.menduner.system.controller.base.position.PositionSaveReqVO;
 import com.citu.module.menduner.system.convert.PositionConvert;
+import com.citu.module.menduner.system.dal.dataobject.industry.IndustryDO;
 import com.citu.module.menduner.system.dal.dataobject.position.PositionDO;
 import com.citu.module.menduner.system.dal.mysql.job.JobAdvertisedMapper;
 import com.citu.module.menduner.system.dal.mysql.position.PositionMapper;
@@ -385,4 +386,14 @@ public class PositionServiceImpl implements PositionService {
     public List<AppPositionSimpleRespVO> getPositionList(AppPositionListReqVO reqVO) {
         return PositionConvert.INSTANCE.convertList2(positionMapper.selectList(reqVO));
     }
+
+    @Override
+    public Map<Long, String> getNameByIds(Set<Long> ids) {
+        if(ids.isEmpty()){
+            return new HashMap<>();
+        }
+
+        List<PositionDO> positionList = positionMapper.selectBatchIds(ids);
+        return positionList.stream().collect(Collectors.toMap(PositionDO::getId, PositionDO::getNameCn));
+    }
 }

+ 28 - 37
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/resume/TenResumeServiceImpl.java

@@ -14,12 +14,7 @@ import org.springframework.stereotype.Service;
 
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.URL;
 import java.net.URLEncoder;
 import java.security.InvalidKeyException;
 import java.security.Key;
@@ -30,7 +25,7 @@ import java.util.*;
 @Service
 public class TenResumeServiceImpl implements TenResumeService {
 
-    private  final Logger log = LoggerFactory.getLogger(TenResumeServiceImpl.class);
+    private final Logger log = LoggerFactory.getLogger(TenResumeServiceImpl.class);
 
     @Value("${ten.resume.secretid:AKID9zQ0cC08nOPi3R8iWSXHPn4n01HZoawovA0}")
     private String tenResumeSecretId;
@@ -48,32 +43,31 @@ public class TenResumeServiceImpl implements TenResumeService {
         try {
             TemResumeResVo resume = resume(fileName, fileContent, 1, 1, 1);
             return CommonResult.success(resume);
-        }catch (Exception e){
-            log.error("tenResumeService error:{}",e.getMessage());
-            throw  new RuntimeException("简历解析异常!");
+        } catch (Exception e) {
+            log.error("tenResumeService error:{}", e.getMessage());
+            throw new RuntimeException("简历解析异常!");
         }
     }
 
     /**
-     *
-     * @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 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:
      *                      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
      * @throws NoSuchAlgorithmException
      * @throws UnsupportedEncodingException
      * @throws InvalidKeyException
      */
-    public  TemResumeResVo resume(String fileName,String fileCount,Integer needAvatar
-            ,Integer needSocialExp,Integer version) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
+    public TemResumeResVo resume(String fileName, String fileCount, Integer needAvatar
+            , Integer needSocialExp, Integer version) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
 
         String url = resumeReqUrl;
         String source = "market";
@@ -84,35 +78,33 @@ public class TenResumeServiceImpl implements TenResumeService {
 
         // body参数
         Map<String, String> bodyParams = new HashMap<String, String>();
-        bodyParams.put("body","");
-        bodyParams.put("file_name",fileName);
-        bodyParams.put("file_cont",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_cont", fileCount);
+        bodyParams.put("need_avatar", needAvatar.toString());
+        bodyParams.put("need_social_exp", needSocialExp.toString());
+        bodyParams.put("version", version.toString());
 
         HttpRequest post = HttpUtil.createPost(url);
         post.header("X-Source", source);
         post.header("X-Date", datetime);
         // 签名
         post.header("Authorization", calcAuthorization(source, this.tenResumeSecretId, this.tenResumeSecretKey, datetime));
-        post.header("Content-Type","application/json");
+        post.header("Content-Type", "application/json");
         post.body(JSON.toJSONString(bodyParams));
         HttpResponse execute = post.execute();
         String body = execute.body();
-        log.info("parse resume  res->{}",body);
+        log.info("parse resume  res->{}", body);
         System.out.println(body);
         TemResumeResVo temResumeResVo = JSON.parseObject(body, TemResumeResVo.class);
-        if(temResumeResVo.getStatus().getCode()!=200){
-           throw  new RuntimeException("简历解析失败");
+        if (temResumeResVo.getStatus().getCode() != 200) {
+            throw new RuntimeException("简历解析失败");
         }
-        return  temResumeResVo;
+        return temResumeResVo;
     }
 
 
-
-
-    private   String calcAuthorization(String source, String secretId, String secretKey, String datetime)
+    private String calcAuthorization(String source, String secretId, String secretKey, String datetime)
             throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
         String signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
         Mac mac = Mac.getInstance("HmacSHA1");
@@ -125,7 +117,7 @@ public class TenResumeServiceImpl implements TenResumeService {
         return auth;
     }
 
-    private  String urlencode(Map<?, ?> map) throws UnsupportedEncodingException {
+    private String urlencode(Map<?, ?> map) throws UnsupportedEncodingException {
         StringBuilder sb = new StringBuilder();
         for (Map.Entry<?, ?> entry : map.entrySet()) {
             if (sb.length() > 0) {
@@ -140,5 +132,4 @@ public class TenResumeServiceImpl implements TenResumeService {
     }
 
 
-
 }