3
0

2 Коміти ebc72db6df ... c08792b520

Автор SHA1 Опис Дата
  java71- 张威豹 c08792b520 Merge remote-tracking branch 'origin/dev' into dev 3 роки тому
  java71- 张威豹 ba26b3f32f 调整controller和service,新增界面可以修改岗位代码 3 роки тому

+ 15 - 219
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/controller/RecruitPlanMainController.java

@@ -72,31 +72,6 @@ public class RecruitPlanMainController extends BaseController
         startPage();
         recruitPlanMain.setDeptId(getDeptId());
         List<RecruitPlanMain> list = recruitPlanMainService.selectRecruitPlanMainList(recruitPlanMain);
-        for (RecruitPlanMain recruitPlanMain1 : list){
-        long    mId = recruitPlanMain1.getRecruitPlanMainId();
-            RecruitPlanChild recruitPlanChild = new RecruitPlanChild();
-            recruitPlanChild.setRecruitPlanMainId(mId);
-            List<RecruitPlanChild> recruitPlanChildList = recruitPlanChildService.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 = recruitPersonnelService.selectRecruitPersonnelNumByPostCode(recruitPlanChild2.getPostNumId());
-                int yprs = Integer.parseInt(personnelCount);
-                countPersonnel = countPersonnel+yprs;
-            }
-            //赋值yprs
-            recruitPlanMain1.setYprs(String.valueOf(countPersonnel));
-        }
         return getDataTable(list);
     }
 
@@ -135,9 +110,6 @@ public class RecruitPlanMainController extends BaseController
     {
         Long deptId = getDeptId();
         SysDept sysDept = sysDeptService.selectDeptById(deptId);
-        String deptName = sysDept.getDeptName();
-        List<Integer> yearsList = getRecruitYear();
-
         //默认生成一个岗位代码
         String deptId1 =String.valueOf(getDeptId().intValue()) ;
         double number = Math.random()*1000000;
@@ -160,38 +132,21 @@ public class RecruitPlanMainController extends BaseController
     public AjaxResult selectRecruitplanmainidBydeptId(){
         StringBuilder msg = new StringBuilder();
         Long deptId = getDeptId();
-        SysDept sysDept = sysDeptService.selectDeptById(deptId);
-        String deptName = sysDept.getDeptName();
         List<Integer> yearsList = getRecruitYear();
-        //校验同单位今年和明年是否已有招聘计划
-        Long a = Long.valueOf(yearsList.get(0));
-        Long b = Long.valueOf(yearsList.get(1));
-        RecruitPlanMain  recruitPlanMain1 = new RecruitPlanMain();
-        recruitPlanMain1.setDeptId(getDeptId());
-        List<RecruitPlanMain> recruitPlanMainList = recruitPlanMainService.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);
-                }
-            }
-            }
-        }
+
+        List<Integer> yearsListThen = recruitPlanMainService.selectRecruitPlanMainIdByDeptidForMain(deptId,yearsList);
         if (yearsList.size()==0){
             msg.append(0);
-            mapNeed.put("yearForAdd",yearsList);
+            mapNeed.put("yearForAdd",yearsListThen);
             return AjaxResult.success(msg.toString());
         }
         List<Integer> yearsListNew = getRecruitYear();
         if (yearsList.size()==1 &&yearsList.get(0).equals(yearsListNew.get(0))){
             msg.append(1);
-            mapNeed.put("yearForAdd",yearsList);
+            mapNeed.put("yearForAdd",yearsListThen);
             return AjaxResult.success(msg.toString());
         }
-
-        mapNeed.put("yearForAdd",yearsList);
+        mapNeed.put("yearForAdd",yearsListThen);
         return AjaxResult.success(msg.toString());
     }
 
@@ -205,48 +160,7 @@ public class RecruitPlanMainController extends BaseController
     {
         try {
             recruitPM.setDeptId(getDeptId());
-            //给新增计划中的子计划delFlag赋值为"0''
-            List<RecruitPlanChild> recruitPlanChildList = recruitPM.getColumns();
-            List<String> postNumIdList = recruitPlanMainService.selectRecruitPlanMainListForCheckPostNumId(recruitPM);
-            //再次校验子计划中的岗位代码是否与已有重复,概率为零
-            for (RecruitPlanChild recruitPlanChild : recruitPlanChildList){
-                if (postNumIdList.contains(recruitPlanChild.getPostNumId())){
-                    return AjaxResult.error("招聘计划中生成的岗位代码重复,请修改");
-                }
-            }
-            recruitPlanChildList.forEach(recruitPlanChild -> recruitPlanChild.setDelFlag("0"));
-            recruitPM.setAhrsRecruitPlanChildList(recruitPlanChildList);
-            recruitPM.setCreateBy(ShiroUtils.getSysUser().getUserName());
-            recruitPM.setCreateTime(DateUtils.getNowDate());
-            recruitPM.setDelFlag("0");
-            //查看本单位本年是否有申报历史
-            RecruitPlanMain recruitPlanMainMemory = recruitPlanMainService.selectRecruitPlanMainByDeptIdAndYear(recruitPM.getRecruitPlanYear(),recruitPM.getDeptId());
-            if (recruitPlanMainMemory!=null){
-                recruitPM.setVersion(recruitPlanMainMemory.getVersion()+1);
-            }
-            //给所有子计划版本赋值
-            for (int i=0;i<recruitPlanChildList.size();i++){
-                recruitPlanChildList.get(0).setVersion(1L);
-            }
-            //转换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);
-                }
-            });
+
             int result = recruitPlanMainService.insertRecruitPlanMain(recruitPM);
             if (result == 11){
                 return AjaxResult.error("招聘计划中的岗位代码重复");
@@ -258,15 +172,9 @@ public class RecruitPlanMainController extends BaseController
         }
     }
 
-
-    private void 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());
+    private RecruitPlanChild splicingMajor(RecruitPlanChild recruitPlanChildToMajor){
+     recruitPlanChildToMajor = recruitPlanMainService.splicingMajor(recruitPlanChildToMajor);
+     return  recruitPlanChildToMajor;
     }
 
     /**
@@ -275,47 +183,11 @@ public class RecruitPlanMainController extends BaseController
     @GetMapping("/edit/{recruitPlanMainId}")
     public String edit(@PathVariable("recruitPlanMainId") Long recruitPlanMainId, ModelMap mmap)
     {
-
-        RecruitPlanMain recruitPlanMain = recruitPlanMainService.selectRecruitPlanMainById(recruitPlanMainId);
         //默认生成一个岗位代码
-        String deptIdStr =String.valueOf(getDeptId().intValue()) ;
+        RecruitPlanMain recruitPM = recruitPlanMainService.selectRecruitPlanMainById(recruitPlanMainId);
         double number = Math.random()*1000000;
         String mathCode = String.valueOf(new Double(number).intValue());
-        String postNumIdStr = deptIdStr+mathCode;
-        int countNum = 0;
-
-        RecruitPlanMain recruitPM = new RecruitPlanMain();
-
-        List<RecruitPlanChild> recruitPlanMainList = recruitPlanMain.getAhrsRecruitPlanChildList();
-        for (RecruitPlanChild recruitPlanChild : recruitPlanMainList){
-            countNum = (int)(Math.random()*10);
-            postNumIdStr = postNumIdStr+ countNum;
-            String personnelCount = recruitPersonnelService.selectRecruitPersonnelNumByPostCode(recruitPlanChild.getPostNumId());
-            recruitPlanChild.setYprs(personnelCount);
-            countNum++;
-            //给majorValue赋值
-            recruitPlanChild.setMajorValue(recruitPlanMainService.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());
+        String postNumIdStr = mathCode;
 
         mmap.put("RecruitPlanMain",recruitPM);
         mmap.put("recruitPlanYears",recruitPM.getRecruitPlanYear());
@@ -334,86 +206,10 @@ public class RecruitPlanMainController extends BaseController
     public AjaxResult editSave(RecruitPlanMain recruitPM)
     {
         try {
-            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 = recruitPlanMainService.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 = recruitPlanChildService.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 = recruitPlanChildService.selectRecruitPlanChildById(indexNum);
-                    recruitPlanChild.setVersion(recruitPlanChild.getVersion()+1);
-                    recruitPlanChild.setRecruitPlanChildId(null);
-                    recruitPlanChildService.insertRecruitPlanChild(recruitPlanChild);
-                    isChange = true;
-                }
-            }
-
-            //第五步 更新recruitPlanMain,
-            if (isChange){
-                recruitPM.setVersion(recruitPMT.getVersion()+1);
-                recruitPM.setDeptId(recruitPMT.getDeptId());
-                recruitPM.setCreateBy(recruitPMT.getCreateBy());
-                recruitPM.setDelFlag("0");
-                recruitPM.setAhrsRecruitPlanChildList(recruitPlanChildList);
-                recruitPlanMainService.insertRecruitPlanMain(recruitPM);
-            }
+              int result =   recruitPlanMainService.insertRecruitPlanMainToEdit(recruitPM);
+              if (result==0){
+                  return  toAjax(false);
+              }
             return toAjax(true);
         }catch (Exception e){
             System.out.println(e);

+ 12 - 1
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/service/IRecruitPlanMainService.java

@@ -1,7 +1,7 @@
 package com.ruoyi.ahrs.recruitplan.service;
 
+import com.ruoyi.ahrs.recruitplan.domian.RecruitPlanChild;
 import com.ruoyi.ahrs.recruitplan.domian.RecruitPlanMain;
-import com.ruoyi.ahrs.recruittime.domain.RecruitTime;
 
 import java.util.List;
 
@@ -91,6 +91,17 @@ public interface IRecruitPlanMainService {
      */
     public Long selectRecruitPlanMainIdByDeptid(Long deptId);
 
+    /**
+     * 根据单位id判断是否可以新增
+     *
+     * @param deptId 单位id
+     * @return 结果
+     */
+    List<Integer> selectRecruitPlanMainIdByDeptidForMain(Long deptId, List<Integer> yearsList);
+
+    //转换major
+    RecruitPlanChild splicingMajor(RecruitPlanChild recruitPlanChildToMajor);
+
     /**
      * 根据年份查询招聘计划id
      * @param year

+ 246 - 10
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/service/impl/RecruitPlanMainServiceImpl.java

@@ -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

+ 1 - 1
ruoyi-ahrs/src/main/resources/templates/ahrs/recruitplan/add.html

@@ -171,7 +171,7 @@
                         if (value == null) {
                             value = ''
                         }
-                        var html = $.common.sprintf("<input class='form-control' readonly style='border: 0px;outline: none' type='text' name='columns[%s].postNumId' value='%s'>", index, value);
+                        var html = $.common.sprintf("<input class='form-control'   style='width: 40px;padding-left: 4px' type='text'   name='columns[%s].postNumId' onblur='changeData(" + index + ",this)'  value='%s' onchange='changeNumber(" + index + ",this.value)'>", index, value);
                         return html;
                     }
                 },