Quellcode durchsuchen

优化招聘计划代码

java71- 张威豹 vor 3 Jahren
Ursprung
Commit
3b9637a8a3

+ 6 - 12
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/controller/RecruitPlanMainController.java

@@ -165,8 +165,9 @@ public class RecruitPlanMainController extends BaseController
     @GetMapping("/edit/{recruitPlanMainId}")
     public String edit(@PathVariable("recruitPlanMainId") Long recruitPlanMainId, ModelMap mmap)
     {
-        //默认生成一个岗位代码
+
         RecruitPlanMain recruitPM = recruitPlanMainService.selectRecruitPlanMainById(recruitPlanMainId);
+        //默认生成一个岗位代码
         double number = Math.random()*10000000;
         String mathCode = String.valueOf(new Double(number).intValue());
         String postNumIdStr = mathCode;
@@ -211,17 +212,10 @@ public class RecruitPlanMainController extends BaseController
     public AjaxResult remove(String ids)
     {
        String[] mIds = Convert.toStrArray(ids);
-       try {
-           for (String id : mIds){
-               Long idL = Long.valueOf(id);
-               RecruitPlanMain recruitPlanMain = recruitPlanMainService.selectRecruitPlanMainById(idL);
-               recruitPlanMain.setVersion(recruitPlanMain.getVersion()+1);
-               recruitPlanMain.setDelFlag("2");
-               recruitPlanMainService.insertRecruitPlanMainForUpdate(recruitPlanMain);
-           }
-       }catch (Exception e){
-           return toAjax(false);
-       }
+        int resultNum = recruitPlanMainService.allToDeal(mIds);
+        if (resultNum != 1){
+            return toAjax(false);
+        }
         return toAjax(true);
     }
 

+ 21 - 7
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/service/impl/RecruitPlanMainServiceImpl.java

@@ -48,10 +48,8 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
     @Override
     public RecruitPlanMain selectRecruitPlanMainById(Long recruitPlanMainId) {
         RecruitPlanMain recruitPlanMain = recruitPlanMainMapper.selectRecruitPlanMainById(recruitPlanMainId);
-        RecruitPlanMain recruitPM = new RecruitPlanMain();
-
-        List<RecruitPlanChild> recruitPlanMainList = recruitPlanMain.getAhrsRecruitPlanChildList();
-        for (RecruitPlanChild recruitPlanChild : recruitPlanMainList){
+        List<RecruitPlanChild> recruitPlanChildList = recruitPlanMain.getAhrsRecruitPlanChildList();
+        for (RecruitPlanChild recruitPlanChild : recruitPlanChildList){
             String personnelCount = recruitPersonnelMapper.selectRecruitPersonnelNumByPostCode(recruitPlanChild.getPostNumId());
             recruitPlanChild.setYprs(personnelCount);
             //给majorValue赋值
@@ -71,7 +69,7 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
                 }
             }
         }
-       recruitPlanMain.setColumns(recruitPlanMain.getAhrsRecruitPlanChildList());
+       recruitPlanMain.setColumns(recruitPlanChildList);
         return  recruitPlanMain;
     }
 
@@ -237,7 +235,6 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         return rows;
     }
 
-
     /*修改recruit
     * */
     public int insertRecruitPlanMainToEdit(RecruitPlanMain recruitPM){
@@ -283,7 +280,6 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
 
         //第二步将已存在的子计划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);
@@ -342,6 +338,24 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         return rows;
     }
 
+    /**
+     * 删除 逻辑删除  事务管理
+     * @param String[] mIds
+     * @return 结果
+     */
+    @Transactional
+    public int allToDeal(String[] mIds) {
+        int resultNum = 1;
+        for (String id : mIds) {
+            Long idL = Long.valueOf(id);
+            RecruitPlanMain recruitPlanMain = selectRecruitPlanMainById(idL);
+            recruitPlanMain.setVersion(recruitPlanMain.getVersion() + 1);
+            recruitPlanMain.setDelFlag("2");
+            resultNum=  insertRecruitPlanMainForUpdate(recruitPlanMain);
+        }
+        return resultNum;
+    }
+
     /**
      * 修改recruitplan
      *

+ 2 - 2
ruoyi-ahrs/src/main/resources/mapper/ahrs/recruitplan/RecruitPlanMainMapper.xml

@@ -243,9 +243,9 @@
     </update>
 
     <insert id="batchAhrsRecruitPlanChild">
-        insert into ahrs_recruit_plan_child( recruit_plan_child_id, recruit_plan_main_id, post_id, post_num_id, nprs, major, education, degree, age, rests, public_course, major_course, remark, phone, attachment, version, del_flag, create_by, create_time, update_by, update_time) values
+        insert into ahrs_recruit_plan_child( recruit_plan_main_id, post_id, post_num_id, nprs, major, education, degree, age, rests, public_course, major_course, remark, phone, attachment, version, del_flag, create_by, create_time, update_by, update_time) values
         <foreach item="item" index="index" collection="list" separator=",">
-            ( #{item.recruitPlanChildId}, #{item.recruitPlanMainId}, #{item.postId}, #{item.postNumId}, #{item.nprs}, #{item.major}, #{item.education}, #{item.degree}, #{item.age}, #{item.rests}, #{item.publicCourse}, #{item.majorCourse}, #{item.remark}, #{item.phone}, #{item.attachment}, #{item.version}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
+            ( #{item.recruitPlanMainId}, #{item.postId}, #{item.postNumId}, #{item.nprs}, #{item.major}, #{item.education}, #{item.degree}, #{item.age}, #{item.rests}, #{item.publicCourse}, #{item.majorCourse}, #{item.remark}, #{item.phone}, #{item.attachment}, #{item.version}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
         </foreach>
     </insert>