|
@@ -1,15 +1,18 @@
|
|
|
package com.ruoyi.ahrs.recruitplan.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ruoyi.ahrs.recruitPersonnel.mapper.RecruitPersonnelMapper;
|
|
|
import com.ruoyi.ahrs.recruitplan.domian.RecruitPlanChild;
|
|
|
import com.ruoyi.ahrs.recruitplan.domian.RecruitPlanMain;
|
|
|
import com.ruoyi.ahrs.recruitplan.mapper.RecruitPlanChildMapper;
|
|
|
import com.ruoyi.ahrs.recruitplan.mapper.RecruitPlanMainMapper;
|
|
|
import com.ruoyi.ahrs.recruitplan.service.IRecruitPlanMainService;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
import com.ruoyi.common.enums.UserEnums;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.framework.util.ShiroUtils;
|
|
|
import com.ruoyi.system.service.ISysDictDataService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -32,6 +35,8 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
|
|
|
private RecruitPlanMainMapper recruitPlanMainMapper;
|
|
|
@Autowired
|
|
|
private RecruitPlanChildMapper recruitPlanChildMapper;
|
|
|
+ @Autowired
|
|
|
+ private RecruitPersonnelMapper recruitPersonnelMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ISysDictDataService sysDictDataService;
|
|
@@ -44,7 +49,37 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
|
|
|
*/
|
|
|
@Override
|
|
|
public RecruitPlanMain selectRecruitPlanMainById(Long recruitPlanMainId) {
|
|
|
- return recruitPlanMainMapper.selectRecruitPlanMainById(recruitPlanMainId);
|
|
|
+ RecruitPlanMain recruitPlanMain = recruitPlanMainMapper.selectRecruitPlanMainById(recruitPlanMainId);
|
|
|
+ RecruitPlanMain recruitPM = new RecruitPlanMain();
|
|
|
+
|
|
|
+ List<RecruitPlanChild> recruitPlanMainList = recruitPlanMain.getAhrsRecruitPlanChildList();
|
|
|
+ for (RecruitPlanChild recruitPlanChild : recruitPlanMainList){
|
|
|
+ String personnelCount = recruitPersonnelMapper.selectRecruitPersonnelNumByPostCode(recruitPlanChild.getPostNumId());
|
|
|
+ recruitPlanChild.setYprs(personnelCount);
|
|
|
+ //给majorValue赋值
|
|
|
+ recruitPlanChild.setMajorValue(setMajorValue(recruitPlanChild.getMajor()));
|
|
|
+ //转换age
|
|
|
+ if (recruitPlanChild.getAge()!=null&& recruitPlanChild.getAge().length()!=0 &&recruitPlanChild.getAge()!="" ){
|
|
|
+ String[] strArray = recruitPlanChild.getAge().split("-");
|
|
|
+ if (strArray.length!=0){
|
|
|
+ for (int i=0;i<strArray.length;i++){
|
|
|
+ if (i==0){
|
|
|
+ recruitPlanChild.setStartAge(strArray[0]);
|
|
|
+ }
|
|
|
+ if (i==1){
|
|
|
+ recruitPlanChild.setEndAge(strArray[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ recruitPM.setRecruitPlanYear(recruitPlanMain.getRecruitPlanYear());
|
|
|
+ recruitPM.setRecruitPlanMainId(recruitPlanMainId);
|
|
|
+ recruitPM.setDeptName(recruitPlanMain.getDeptName());
|
|
|
+ recruitPM.setColumns(recruitPlanMain.getAhrsRecruitPlanChildList());
|
|
|
+ recruitPM.setAttachment(recruitPlanMain.getAttachment());
|
|
|
+ recruitPM.setRemark(recruitPlanMain.getRemark());
|
|
|
+ return recruitPM;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -55,7 +90,34 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<RecruitPlanMain> selectRecruitPlanMainList(RecruitPlanMain recruitPlanMain) {
|
|
|
- return recruitPlanMainMapper.selectRecruitPlanMainList(recruitPlanMain);
|
|
|
+
|
|
|
+ List<RecruitPlanMain> list = recruitPlanMainMapper.selectRecruitPlanMainList(recruitPlanMain);
|
|
|
+ for (RecruitPlanMain recruitPlanMain1 : list){
|
|
|
+ long mId = recruitPlanMain1.getRecruitPlanMainId();
|
|
|
+ RecruitPlanChild recruitPlanChild = new RecruitPlanChild();
|
|
|
+ recruitPlanChild.setRecruitPlanMainId(mId);
|
|
|
+ List<RecruitPlanChild> recruitPlanChildList = recruitPlanChildMapper.selectRecruitPlanChildList(recruitPlanChild);
|
|
|
+ String nprs ;
|
|
|
+ int count = 0;
|
|
|
+ int countPersonnel = 0;
|
|
|
+ for (RecruitPlanChild recruitPlanChild2 :recruitPlanChildList){
|
|
|
+ if (recruitPlanChild2.getNprs()!= null){
|
|
|
+ nprs = recruitPlanChild2.getNprs();
|
|
|
+ int number = Integer.parseInt(nprs);
|
|
|
+ count = count+number;
|
|
|
+ //赋值nprs
|
|
|
+ if (count!=0){
|
|
|
+ recruitPlanMain1.setNprs(String.valueOf(count));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String personnelCount = recruitPersonnelMapper.selectRecruitPersonnelNumByPostCode(recruitPlanChild2.getPostNumId());
|
|
|
+ int yprs = Integer.parseInt(personnelCount);
|
|
|
+ countPersonnel = countPersonnel+yprs;
|
|
|
+ }
|
|
|
+ //赋值yprs
|
|
|
+ recruitPlanMain1.setYprs(String.valueOf(countPersonnel));
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -66,28 +128,168 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
|
|
|
/**
|
|
|
* 新增recruitplan
|
|
|
*
|
|
|
- * @param recruitPlanMain recruitplan
|
|
|
+ * @param recruitPlanMain recruitPM
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public int insertRecruitPlanMain(RecruitPlanMain recruitPlanMain)
|
|
|
+ public int insertRecruitPlanMain(RecruitPlanMain recruitPM)
|
|
|
{
|
|
|
- List<RecruitPlanChild> recruitPlanChildList = recruitPlanMain.getAhrsRecruitPlanChildList();
|
|
|
+
|
|
|
+ List<RecruitPlanChild> recruitPlanChildList = recruitPM.getColumns();
|
|
|
+ List<String> postNumIdList = recruitPlanMainMapper.selectRecruitPlanMainListForCheckPostNumId(recruitPM);
|
|
|
+ //再次校验子计划中的岗位代码是否与已有重复,概率为零
|
|
|
+ for (RecruitPlanChild recruitPlanChild : recruitPlanChildList){
|
|
|
+ if (postNumIdList.contains(recruitPlanChild.getPostNumId())){
|
|
|
+ return 11;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //给新增计划中的子计划delFlag赋值为"0''
|
|
|
+ recruitPlanChildList.forEach(recruitPlanChild -> recruitPlanChild.setDelFlag("0"));
|
|
|
+ recruitPM.setAhrsRecruitPlanChildList(recruitPlanChildList);
|
|
|
+ recruitPM.setCreateBy(ShiroUtils.getSysUser().getUserName());
|
|
|
+ recruitPM.setCreateTime(DateUtils.getNowDate());
|
|
|
+ recruitPM.setDelFlag("0");
|
|
|
+ //查看本单位本年是否有申报历史
|
|
|
+ RecruitPlanMain recruitPlanMainMemory = recruitPlanMainMapper.selectRecruitPlanMainByDeptIdAndYear(recruitPM.getRecruitPlanYear(),recruitPM.getDeptId());
|
|
|
+ if (recruitPlanMainMemory!=null){
|
|
|
+ recruitPM.setVersion(recruitPlanMainMemory.getVersion()+1);
|
|
|
+ }
|
|
|
+ //给所有子计划版本赋值
|
|
|
+ for (int i=0;i<recruitPlanChildList.size();i++){
|
|
|
+ recruitPlanChildList.get(i).setVersion(1L);
|
|
|
+ recruitPlanChildList.get(i).setCreateBy(ShiroUtils.getSysUser().getCreateBy());
|
|
|
+ recruitPlanChildList.get(i).setCreateTime(DateUtils.getNowDate());
|
|
|
+ }
|
|
|
+ //转换age
|
|
|
+ recruitPlanChildList.forEach(recruitPlanChild -> {
|
|
|
+ if (recruitPlanChild.getStartAge()!= null && recruitPlanChild.getStartAge().length()!= 0 && recruitPlanChild.getEndAge()!=null&& recruitPlanChild.getEndAge().length()!= 0 ){
|
|
|
+ recruitPlanChild.setAge(recruitPlanChild.getStartAge() + "-" + recruitPlanChild.getEndAge());
|
|
|
+ }
|
|
|
+ if (recruitPlanChild.getStartAge()!="" && recruitPlanChild.getEndAge() == ""){
|
|
|
+ recruitPlanChild.setAge(recruitPlanChild.getStartAge() + "-" + "65");
|
|
|
+ }
|
|
|
+ if (recruitPlanChild.getStartAge()== "" && recruitPlanChild.getEndAge()!= ""){
|
|
|
+ recruitPlanChild.setAge("0" + "-" + recruitPlanChild.getEndAge());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ //转换major
|
|
|
+ recruitPlanChildList.forEach(recruitPlanChild -> {
|
|
|
+ if (StringUtils.isNotEmpty(recruitPlanChild.getMajor()) || StringUtils.isNotEmpty(recruitPlanChild.getMajorValue())){
|
|
|
+ splicingMajor(recruitPlanChild);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
List<String> collect1 = recruitPlanChildList.stream().map(RecruitPlanChild::getPostNumId).distinct().collect(Collectors.toList());
|
|
|
int check = collect1.size()!=recruitPlanChildList.size()?11:22;
|
|
|
if (check == 11){
|
|
|
return 11;
|
|
|
}
|
|
|
- recruitPlanMain.setCreateTime(DateUtils.getNowDate());
|
|
|
- int rows = recruitPlanMainMapper.insertRecruitPlanMain(recruitPlanMain);
|
|
|
- insertAhrsRecruitPlanChild(recruitPlanMain);
|
|
|
+ recruitPM.setCreateTime(DateUtils.getNowDate());
|
|
|
+ int rows = recruitPlanMainMapper.insertRecruitPlanMain(recruitPM);
|
|
|
+ insertAhrsRecruitPlanChild(recruitPM);
|
|
|
return rows;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /*修改recruit
|
|
|
+ * */
|
|
|
+ public int insertRecruitPlanMainToEdit(RecruitPlanMain recruitPM){
|
|
|
+ boolean isChange = true;
|
|
|
+ //修改界面传过来的对象
|
|
|
+ List<RecruitPlanChild> recruitPlanChildList = recruitPM.getColumns();
|
|
|
+ int beanLongNum = recruitPlanChildList.size();
|
|
|
+
|
|
|
+ //给修改招聘计划中的子计划delFlag赋值为"0''--并且进行转换age
|
|
|
+ recruitPlanChildList.forEach(recruitPlanChild -> {
|
|
|
+ recruitPlanChild.setDelFlag("0");
|
|
|
+ if (recruitPlanChild.getStartAge()!= null && recruitPlanChild.getStartAge().length()!= 0 && recruitPlanChild.getEndAge()!=null&& recruitPlanChild.getEndAge().length()!= 0 ){
|
|
|
+ recruitPlanChild.setAge(recruitPlanChild.getStartAge() + "-" + recruitPlanChild.getEndAge());
|
|
|
+ }
|
|
|
+ if (recruitPlanChild.getStartAge()!="" && recruitPlanChild.getEndAge() == ""){
|
|
|
+ recruitPlanChild.setAge(recruitPlanChild.getStartAge() + "-" + "65");
|
|
|
+ }
|
|
|
+ if (recruitPlanChild.getStartAge()== "" && recruitPlanChild.getEndAge()!= ""){
|
|
|
+ recruitPlanChild.setAge("0" + "-" + recruitPlanChild.getEndAge());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ //转换major
|
|
|
+ recruitPlanChildList.forEach(recruitPlanChild -> {
|
|
|
+ if (StringUtils.isNotEmpty(recruitPlanChild.getMajor()) || StringUtils.isNotEmpty(recruitPlanChild.getMajorValue())){
|
|
|
+ splicingMajor(recruitPlanChild);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ recruitPM.setAhrsRecruitPlanChildList(recruitPlanChildList);
|
|
|
+ recruitPM.setUpdateBy(ShiroUtils.getSysUser().getUserName());
|
|
|
+ recruitPM.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //数据库中的对象
|
|
|
+ RecruitPlanMain recruitPMT = recruitPlanMainMapper.selectRecruitPlanMainById(recruitPM.getRecruitPlanMainId());
|
|
|
+ List<RecruitPlanChild> recruitPlanChildListTwo = recruitPMT.getAhrsRecruitPlanChildList();
|
|
|
+ //2. 获取list集合中的某个元素
|
|
|
+ List<Long> idsOld = recruitPlanChildListTwo.stream().map(recruitPlanChild -> recruitPlanChild.getRecruitPlanChildId()).collect(Collectors.toList());
|
|
|
+ List<Long> idsNew = recruitPM.getRecruitPlanChildIds();
|
|
|
+
|
|
|
+
|
|
|
+ //第一步,将传过来的的子计划全部赋值vesion为1
|
|
|
+ for (int i=0; i<recruitPlanChildList.size();i++){
|
|
|
+ recruitPlanChildList.get(i).setVersion(1L);
|
|
|
+ recruitPlanChildList.get(i).setRecruitPlanMainId(recruitPM.getRecruitPlanMainId());
|
|
|
+ recruitPlanChildList.get(i).setCreateBy(ShiroUtils.getSysUser().getCreateBy());
|
|
|
+ recruitPlanChildList.get(i).setCreateTime(DateUtils.getNowDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ //第二步将已存在的子计划version+1
|
|
|
+ for (int i=0;i<idsNew.size();i++){
|
|
|
+ System.out.println("--------|-----"+idsNew.get(i));
|
|
|
+ RecruitPlanChild recruitPlanChild = recruitPlanChildMapper.selectRecruitPlanChildById(idsNew.get(i));
|
|
|
+ //将穿过来的子计划集合中的子计划修改
|
|
|
+ recruitPlanChildList.get(i).setVersion(recruitPlanChild.getVersion()+1);
|
|
|
+ recruitPlanChildList.get(i).setRecruitPlanMainId(recruitPM.getRecruitPlanMainId());
|
|
|
+ recruitPlanChildList.get(i).setCreateBy(recruitPlanChild.getCreateBy());
|
|
|
+ recruitPlanChildList.get(i).setCreateTime(recruitPlanChild.getCreateTime());
|
|
|
+ recruitPlanChildList.get(i).setUpdateBy(ShiroUtils.getSysUser().getUserName());
|
|
|
+ recruitPlanChildList.get(i).setUpdateTime(DateUtils.getNowDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ //第三步,将删除的子计划版本加一且逻辑删除
|
|
|
+ for (int i=0;i<idsOld.size();i++){
|
|
|
+ Long indexNum = idsOld.get(i);
|
|
|
+ if (!idsNew.contains(indexNum)){
|
|
|
+ //删除,
|
|
|
+ RecruitPlanChild recruitPlanChild = recruitPlanChildMapper.selectRecruitPlanChildById(indexNum);
|
|
|
+ recruitPlanChild.setVersion(recruitPlanChild.getVersion()+1);
|
|
|
+ recruitPlanChild.setDelFlag("2");
|
|
|
+ recruitPlanChild.setRecruitPlanChildId(null);
|
|
|
+ recruitPlanChildMapper.insertRecruitPlanChild(recruitPlanChild);
|
|
|
+ isChange = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //第五步 更新recruitPlanMain,
|
|
|
+ if (isChange) {
|
|
|
+ recruitPM.setRecruitPlanMainId(null);
|
|
|
+ recruitPM.setVersion(recruitPMT.getVersion() + 1);
|
|
|
+ recruitPM.setDeptId(recruitPMT.getDeptId());
|
|
|
+ recruitPM.setCreateBy(recruitPMT.getCreateBy());
|
|
|
+ recruitPM.setCreateTime(recruitPMT.getCreateTime());
|
|
|
+ recruitPM.setUpdateBy(ShiroUtils.getSysUser().getUserName());
|
|
|
+ recruitPM.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ recruitPM.setDelFlag("0");
|
|
|
+ recruitPM.setAhrsRecruitPlanChildList(recruitPlanChildList);
|
|
|
+ }
|
|
|
+ int result = recruitPlanMainMapper.insertRecruitPlanMain(recruitPM);
|
|
|
+ insertAhrsRecruitPlanChild(recruitPM);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 新增recruitplan
|
|
|
- *
|
|
|
+ * 删除 逻辑删除
|
|
|
* @param recruitPlanMain recruitplan
|
|
|
* @return 结果
|
|
|
*/
|
|
@@ -159,6 +361,27 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
|
|
|
return recruitPlanMainMapper.selectRecruitPlanMainIdByDeptid(deptId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Integer> selectRecruitPlanMainIdByDeptidForMain(Long deptId, List<Integer> yearsList) {
|
|
|
+ //校验同单位今年和明年是否已有招聘计划
|
|
|
+ Long a = Long.valueOf(yearsList.get(0));
|
|
|
+ Long b = Long.valueOf(yearsList.get(1));
|
|
|
+ RecruitPlanMain recruitPlanMain1 = new RecruitPlanMain();
|
|
|
+ recruitPlanMain1.setDeptId(deptId);
|
|
|
+ List<RecruitPlanMain> recruitPlanMainList = recruitPlanMainMapper.selectRecruitPlanMainList(recruitPlanMain1);
|
|
|
+ for (RecruitPlanMain recruitPlanMain :recruitPlanMainList){
|
|
|
+ for (int i=0;i<yearsList.size();i++){
|
|
|
+ if (recruitPlanMain!=null){
|
|
|
+ Long num = yearsList.get(i).longValue();
|
|
|
+ if (recruitPlanMain.getRecruitPlanYear().equals(num)){
|
|
|
+ yearsList.remove(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return yearsList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据年份查询招聘计划id
|
|
|
* @param year
|
|
@@ -218,6 +441,19 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
|
|
|
return result.toString();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RecruitPlanChild splicingMajor(RecruitPlanChild recruitPlanChildToMajor) {
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put(UserEnums.majorType.tree.getStatus(),recruitPlanChildToMajor.getMajor());
|
|
|
+ jsonObject.put(UserEnums.majorType.dz.getStatus(),recruitPlanChildToMajor.getSpecialtyMajor());
|
|
|
+ jsonObject.put(UserEnums.majorType.bk.getStatus(),recruitPlanChildToMajor.getUndergraduateMajor());
|
|
|
+ jsonObject.put(UserEnums.majorType.yjs.getStatus(),recruitPlanChildToMajor.getGraduateMajor());
|
|
|
+ jsonObject.put(UserEnums.majorType.qt.getStatus(),recruitPlanChildToMajor.getOtherMajor());
|
|
|
+ recruitPlanChildToMajor.setMajor(jsonObject.toJSONString());
|
|
|
+ return recruitPlanChildToMajor;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据年份查询招聘计划
|
|
|
* @param year
|