Przeglądaj źródła

主表删除时,子表也进行逻辑删除

java71- 张威豹 3 lat temu
rodzic
commit
175fb41f97

+ 2 - 4
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/controller/RecruitPlanMainController.java

@@ -105,7 +105,7 @@ public class RecruitPlanMainController extends BaseController
         SysDept sysDept = sysDeptService.selectDeptById(deptId);
         //默认生成一个岗位代码
         String deptId1 =String.valueOf(getDeptId().intValue()) ;
-        double number = Math.random()*1000000;
+        double number = Math.random()*10000000;
         String mathCode = String.valueOf(new Double(number).intValue());
         String postNumId2 = mathCode+deptId1;
 
@@ -173,7 +173,7 @@ public class RecruitPlanMainController extends BaseController
     {
         //默认生成一个岗位代码
         RecruitPlanMain recruitPM = recruitPlanMainService.selectRecruitPlanMainById(recruitPlanMainId);
-        double number = Math.random()*1000000;
+        double number = Math.random()*10000000;
         String mathCode = String.valueOf(new Double(number).intValue());
         String postNumIdStr = mathCode;
 
@@ -232,7 +232,6 @@ public class RecruitPlanMainController extends BaseController
         return toAjax(true);
     }
 
-
     /**
      * 专业
      * @param major
@@ -253,7 +252,6 @@ public class RecruitPlanMainController extends BaseController
         return prefix + "/insertMajor";
     }
 
-
     /**
      *
      * 校验recruitplan下是否有招聘人员

+ 16 - 15
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/service/impl/RecruitPlanMainServiceImpl.java

@@ -7,7 +7,6 @@ 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;
@@ -37,7 +36,6 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
     private RecruitPlanChildMapper recruitPlanChildMapper;
     @Autowired
     private RecruitPersonnelMapper recruitPersonnelMapper;
-
     @Autowired
     private ISysDictDataService sysDictDataService;
 
@@ -153,7 +151,7 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         //给所有子计划版本赋值
         for (int i=0;i<recruitPlanChildList.size();i++){
             recruitPlanChildList.get(i).setVersion(1L);
-            recruitPlanChildList.get(i).setCreateBy(ShiroUtils.getSysUser().getCreateBy());
+            recruitPlanChildList.get(i).setCreateBy(ShiroUtils.getSysUser().getUserName());
             recruitPlanChildList.get(i).setCreateTime(DateUtils.getNowDate());
         }
         //转换age
@@ -195,7 +193,6 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         boolean isChange = true;
         //修改界面传过来的对象
         List<RecruitPlanChild> recruitPlanChildList = recruitPM.getColumns();
-        int beanLongNum = recruitPlanChildList.size();
 
         //给修改招聘计划中的子计划delFlag赋值为"0''--并且进行转换age
         recruitPlanChildList.forEach(recruitPlanChild -> {
@@ -246,8 +243,7 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
             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());
+
         }
 
         //第三步,将删除的子计划版本加一且逻辑删除
@@ -269,10 +265,8 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
             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.setCreateBy(ShiroUtils.getSysUser().getUserName());
+            recruitPM.setCreateTime(DateUtils.getNowDate());
             recruitPM.setDelFlag("0");
             recruitPM.setAhrsRecruitPlanChildList(recruitPlanChildList);
         }
@@ -281,8 +275,6 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         return  result;
     }
 
-
-
     /**
      * 删除 逻辑删除
      * @param recruitPlanMain recruitplan
@@ -292,13 +284,19 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
     public int insertRecruitPlanMainForUpdate(RecruitPlanMain recruitPlanMain)
     {
         recruitPlanMain.setCreateTime(DateUtils.getNowDate());
+        List<RecruitPlanChild> recruitPlanChildList = recruitPlanMain.getAhrsRecruitPlanChildList();
+        recruitPlanChildList.forEach(recruitPlanChild -> {
+            recruitPlanChild.setVersion(recruitPlanChild.getVersion()+1);
+            recruitPlanChild.setDelFlag("2");
+            recruitPlanChild.setRecruitPlanChildId(null);
+            recruitPlanChild.setRecruitPlanMainId(null);
+        });
+        recruitPlanMain.setAhrsRecruitPlanChildList(recruitPlanChildList);
         int rows = recruitPlanMainMapper.insertRecruitPlanMain(recruitPlanMain);
+        insertAhrsRecruitPlanChild(recruitPlanMain);
         return rows;
     }
 
-
-
-
     @Override
     public int insertRecruitPlanMainApproval(RecruitPlanMain recruitPlanMain) {
         recruitPlanMain.setCreateTime(new Date());
@@ -356,6 +354,9 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         return recruitPlanMainMapper.selectRecruitPlanMainIdByDeptid(deptId);
     }
 
+    /*校验同单位今年和明年是否已有招聘计划
+      该年若有计划,yearList删除该年份,若yearList.size()=0,则无法新增,
+    * */
     @Override
     public List<Integer> selectRecruitPlanMainIdByDeptidForMain(Long deptId, List<Integer> yearsList) {
         //校验同单位今年和明年是否已有招聘计划