|
|
@@ -1,6 +1,7 @@
|
|
|
package com.zhongzheng.modules.recruit.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.modules.recruit.bo.RecruitResumeAddBo;
|
|
|
@@ -10,12 +11,15 @@ import com.zhongzheng.modules.recruit.domain.RecruitResume;
|
|
|
import com.zhongzheng.modules.recruit.mapper.RecruitResumeMapper;
|
|
|
import com.zhongzheng.modules.recruit.service.IRecruitResumeService;
|
|
|
import com.zhongzheng.modules.recruit.vo.RecruitResumeVo;
|
|
|
+import com.zhongzheng.modules.user.bo.UserEditBo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
@@ -75,20 +79,35 @@ public class RecruitResumeServiceImpl extends ServiceImpl<RecruitResumeMapper, R
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean insertByAddBo(RecruitResumeAddBo bo) {
|
|
|
+ public Boolean insertByAddBo(RecruitResumeAddBo bo) throws IllegalAccessException {
|
|
|
RecruitResume add = BeanUtil.toBean(bo, RecruitResume.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ Field[] field = bo.getClass().getDeclaredFields();
|
|
|
+ Integer integer = countUser(add);
|
|
|
+ String num = String.valueOf(new BigDecimal(integer.toString())
|
|
|
+ .divide(new BigDecimal(Convert.toStr(field.length)),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")));
|
|
|
+ bo.setCompleteness(Convert.toInt(num));
|
|
|
return this.save(add);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
- public Boolean updateByEditBo(RecruitResumeEditBo bo) {
|
|
|
+ public Boolean updateByEditBo(RecruitResumeEditBo bo) throws IllegalAccessException {
|
|
|
RecruitResume update = BeanUtil.toBean(bo, RecruitResume.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.updateById(update);
|
|
|
+ Field[] field = update.getClass().getDeclaredFields();
|
|
|
+ boolean b = this.updateById(update);
|
|
|
+ RecruitResumeVo recruitResumeVo = this.queryById(update.getResumeId());
|
|
|
+ Integer integer = countUserEditBo(recruitResumeVo);
|
|
|
+ integer = integer+2;
|
|
|
+ String num = String.valueOf(new BigDecimal(integer.toString())
|
|
|
+ .divide(new BigDecimal(Convert.toStr(field.length)),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")));
|
|
|
+ update.setCompleteness(Convert.toInt(num));
|
|
|
+ boolean b1 = this.updateById(update);
|
|
|
+ return b1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -107,4 +126,33 @@ public class RecruitResumeServiceImpl extends ServiceImpl<RecruitResumeMapper, R
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public Integer countUser(RecruitResume userVo) throws IllegalAccessException {
|
|
|
+ // Java的反射
|
|
|
+ Field[] field = userVo.getClass().getDeclaredFields();
|
|
|
+ int count = 0;
|
|
|
+ for(int i=0; i<field.length; i++){
|
|
|
+ Field f = field[i];
|
|
|
+ f.setAccessible(true);
|
|
|
+ if (f.get(userVo) != null){
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer countUserEditBo(RecruitResumeVo userVo) throws IllegalAccessException {
|
|
|
+ // Java的反射
|
|
|
+ Field[] field = userVo.getClass().getDeclaredFields();
|
|
|
+ int count = 0;
|
|
|
+ for(int i=0; i<field.length; i++){
|
|
|
+ Field f = field[i];
|
|
|
+ f.setAccessible(true);
|
|
|
+ if (f.get(userVo) != null){
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
}
|