|
@@ -2,6 +2,7 @@ package com.citu.module.menduner.system.old;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import com.citu.framework.common.util.date.DateUtils;
|
|
|
+import com.citu.framework.common.util.object.ObjectUtils;
|
|
|
import com.citu.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
import com.citu.framework.tenant.core.aop.TenantIgnore;
|
|
|
import com.citu.framework.tenant.core.db.TenantBaseDO;
|
|
@@ -47,6 +48,8 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -129,26 +132,30 @@ public class MdeOldSyncService {
|
|
|
private JobInterestedMapper jobInterestedMapper;
|
|
|
@Resource
|
|
|
private OldInterestedAddsMapper oldInterestedAddsMapper;
|
|
|
+ @Resource
|
|
|
+ private OldMdeSubscribedPositionsMapper oldSubscribedPositionsMapper;
|
|
|
|
|
|
private String url = "https://www.mendunerhr.com/";
|
|
|
|
|
|
@Async
|
|
|
@TenantIgnore
|
|
|
public void run() {
|
|
|
- // 同步区域
|
|
|
- syncArea();
|
|
|
- // 同步感兴趣城市
|
|
|
+// // 同步区域
|
|
|
+// syncArea();
|
|
|
+ // 同步感兴趣城市 or 订阅的职位类型
|
|
|
syncInterested();
|
|
|
- // 同步职位信息
|
|
|
- syncPosition();
|
|
|
- // 同步用户信息
|
|
|
- syncUser();
|
|
|
- // 同步发布职位
|
|
|
- syncJob();
|
|
|
- // 同步人才工作经历、教育经历
|
|
|
- syncPersonExtend();
|
|
|
- // 同步人才简历附件、投递简历
|
|
|
- syncCv();
|
|
|
+// // 同步职位信息
|
|
|
+// syncPosition();
|
|
|
+// // 同步用户信息
|
|
|
+// syncUser();
|
|
|
+// // 同步发布职位
|
|
|
+// syncJob();
|
|
|
+// // 同步人才工作经历、教育经历
|
|
|
+// syncPersonExtend();
|
|
|
+// // 同步人才简历附件、投递简历
|
|
|
+// syncCv();
|
|
|
+// // 计算工作年限和最高学历
|
|
|
+// syncEduAndWork();
|
|
|
}
|
|
|
|
|
|
public void syncArea() {
|
|
@@ -190,36 +197,77 @@ public class MdeOldSyncService {
|
|
|
Map<Long, List<OldInterestedAdds>> groupByUser = oldInterestedAddsList.stream()
|
|
|
.collect(Collectors.groupingBy(OldInterestedAdds::getUserCode));
|
|
|
|
|
|
- groupByUser.entrySet().forEach(user -> {
|
|
|
|
|
|
+ List<OldMdeSubscribedPositions> oldSubscribedPositionsList =
|
|
|
+ oldSubscribedPositionsMapper.selectList(new LambdaQueryWrapperX<OldMdeSubscribedPositions>()
|
|
|
+ .eq(OldMdeSubscribedPositions::getDelFlag, 0));
|
|
|
|
|
|
+ oldSubscribedPositionsList.forEach(oldSubscribedPositions -> {
|
|
|
+ // 查找求职意向
|
|
|
JobInterestedDO jobInterested = jobInterestedMapper
|
|
|
.selectOne(new LambdaQueryWrapperX<JobInterestedDO>()
|
|
|
- .eq(JobInterestedDO::getUserId, user.getKey())
|
|
|
+ .eq(JobInterestedDO::getUserId, oldSubscribedPositions.getUserCode())
|
|
|
+ .eq(JobInterestedDO::getPositionId, oldSubscribedPositions.getPositionId())
|
|
|
);
|
|
|
|
|
|
Set<String> interestedAreaIdList = new HashSet<>();
|
|
|
|
|
|
- for (OldInterestedAdds oldInterestedAdds : user.getValue()) {
|
|
|
- interestedAreaIdList.add(oldInterestedAdds.getIntdCity());
|
|
|
+ if (groupByUser.containsKey(oldSubscribedPositions.getUserCode())) {
|
|
|
+ for (OldInterestedAdds oldInterestedAdds : groupByUser.get(oldSubscribedPositions.getUserCode())) {
|
|
|
+ interestedAreaIdList.add(oldInterestedAdds.getIntdCity());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (null != jobInterested&& CollUtil.isNotEmpty(jobInterested.getIndustryIdList())) {
|
|
|
- interestedAreaIdList.addAll(jobInterested.getIndustryIdList());
|
|
|
+
|
|
|
+ if (null != jobInterested && CollUtil.isNotEmpty(jobInterested.getInterestedAreaIdList())) {
|
|
|
+ interestedAreaIdList.addAll(jobInterested.getInterestedAreaIdList());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
JobInterestedDO insert = JobInterestedDO.builder()
|
|
|
- .id(null == jobInterested ? user.getKey() : jobInterested.getId())
|
|
|
- .userId(user.getKey())
|
|
|
+ .id(null == jobInterested ? oldSubscribedPositions.getUserCode()+oldSubscribedPositions.getPositionId()
|
|
|
+ : jobInterested.getId())
|
|
|
+ .userId( oldSubscribedPositions.getUserCode())
|
|
|
+ .positionId(oldSubscribedPositions.getPositionId())
|
|
|
.jobType(JobTypeEnum.FULL_TIME.getType())
|
|
|
- .interestedAreaIdList(new ArrayList<>(interestedAreaIdList))
|
|
|
+ .interestedAreaIdList(interestedAreaIdList.size()>0?new ArrayList<>(interestedAreaIdList):null)
|
|
|
.build();
|
|
|
|
|
|
setCommon(insert);
|
|
|
|
|
|
jobInterestedMapper.insertOrUpdate(insert);
|
|
|
-
|
|
|
});
|
|
|
+
|
|
|
+// groupByUser.entrySet().forEach(user -> {
|
|
|
+//
|
|
|
+//
|
|
|
+// JobInterestedDO jobInterested = jobInterestedMapper
|
|
|
+// .selectOne(new LambdaQueryWrapperX<JobInterestedDO>()
|
|
|
+// .eq(JobInterestedDO::getUserId, user.getKey())
|
|
|
+// );
|
|
|
+//
|
|
|
+// Set<String> interestedAreaIdList = new HashSet<>();
|
|
|
+//
|
|
|
+// for (OldInterestedAdds oldInterestedAdds : user.getValue()) {
|
|
|
+// interestedAreaIdList.add(oldInterestedAdds.getIntdCity());
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (null != jobInterested && CollUtil.isNotEmpty(jobInterested.getInterestedAreaIdList())) {
|
|
|
+// interestedAreaIdList.addAll(jobInterested.getInterestedAreaIdList());
|
|
|
+// }
|
|
|
+//
|
|
|
+// JobInterestedDO insert = JobInterestedDO.builder()
|
|
|
+// .id(null == jobInterested ? user.getKey() : jobInterested.getId())
|
|
|
+// .userId(user.getKey())
|
|
|
+// .jobType(JobTypeEnum.FULL_TIME.getType())
|
|
|
+// .interestedAreaIdList(new ArrayList<>(interestedAreaIdList))
|
|
|
+// .build();
|
|
|
+//
|
|
|
+// setCommon(insert);
|
|
|
+//
|
|
|
+// jobInterestedMapper.insertOrUpdate(insert);
|
|
|
+//
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
@Async
|
|
@@ -258,7 +306,7 @@ public class MdeOldSyncService {
|
|
|
if (null != positionDO) {
|
|
|
return;
|
|
|
}
|
|
|
- if("领导".equals(oldMdeDepartment.getDepdNameCn())) {
|
|
|
+ if ("领导".equals(oldMdeDepartment.getDepdNameCn())) {
|
|
|
oldMdeDepartment.setDepdNameCn("高层");
|
|
|
}
|
|
|
PositionDO insertionDO = PositionDO.builder()
|
|
@@ -305,7 +353,6 @@ public class MdeOldSyncService {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public void syncUser() {
|
|
|
|
|
|
// 个人用户
|
|
@@ -455,7 +502,6 @@ public class MdeOldSyncService {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public void syncJob() {
|
|
|
// 职位信息
|
|
|
List<OldMdeJobAdvertised> jobList = oldJobAdvertisedMapper.selectList();
|
|
@@ -609,6 +655,68 @@ public class MdeOldSyncService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public void syncEduAndWork() {
|
|
|
+ List<PersonInfoDO> personList = personInfoMapper.selectList();
|
|
|
+ personList.forEach(person -> {
|
|
|
+ boolean isUpdate = false;
|
|
|
+ EduExpDO eduMax = eduExpMapper.selectMaxEducationByUserId(person.getUserId());
|
|
|
+ if (null != eduMax) {
|
|
|
+ isUpdate = true;
|
|
|
+ person.setEduType(eduMax.getEducationType());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WorkExpDO> workList = workExpMapper.selectByUserIdList(person.getUserId());
|
|
|
+ if (CollUtil.isNotEmpty(workList)) {
|
|
|
+ isUpdate = true;
|
|
|
+ // 计算工龄
|
|
|
+ // 计算总工龄
|
|
|
+ long totalMonthsOfWork = 0;
|
|
|
+ for (WorkExpDO workExp : workList) {
|
|
|
+ LocalDateTime startDate = workExp.getStartTime();
|
|
|
+ LocalDateTime endDate = ObjectUtils.defaultIfNull(workExp.getEndTime(), LocalDateTime.now());
|
|
|
+
|
|
|
+ // 检查开始日期是否为空
|
|
|
+ if (startDate == null) {
|
|
|
+ log.warn("Start date is null for work experience of user: {}", person.getUserId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算工作时长(以月为单位)
|
|
|
+ long monthsOfWork = ChronoUnit.MONTHS.between(startDate, endDate);
|
|
|
+ totalMonthsOfWork += monthsOfWork;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确定工作经验类型
|
|
|
+ double totalYearsOfWork = totalMonthsOfWork / 12.0; // 转换年
|
|
|
+ ExpTypeEnum expType = null;
|
|
|
+ if (totalYearsOfWork < 1) {
|
|
|
+ expType = ExpTypeEnum.LESS_THAN_ONE_YEAR;
|
|
|
+ } else if (totalYearsOfWork >= 1 && totalYearsOfWork < 3) {
|
|
|
+ expType = ExpTypeEnum.ONE_TO_THREE_YEARS;
|
|
|
+ } else if (totalYearsOfWork >= 3 && totalYearsOfWork < 5) {
|
|
|
+ expType = ExpTypeEnum.THREE_TO_FIVE_YEARS;
|
|
|
+ } else if (totalYearsOfWork >= 5 && totalYearsOfWork < 10) {
|
|
|
+ expType = ExpTypeEnum.FIVE_TO_TEN_YEARS;
|
|
|
+ } else if (totalYearsOfWork >= 10 && totalYearsOfWork < 20) {
|
|
|
+ expType = ExpTypeEnum.MORE_THAN_TEN_YEARS;
|
|
|
+ } else if (totalYearsOfWork >= 20) {
|
|
|
+ expType = ExpTypeEnum.MORE_THAN_TWENTY_YEARS;
|
|
|
+ }
|
|
|
+ person.setExpType(null == expType ? null : expType.getType());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (isUpdate) {
|
|
|
+ personInfoMapper.updateById(person);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void setCommon(TenantBaseDO tenantBaseDO) {
|
|
|
tenantBaseDO.setTenantId(155L);
|
|
|
}
|