Browse Source

修改岗位代码生成规则,查询同年招聘计划,找到岗位代码最大加一;若同年招聘计划无,则按年份+随机生活5位数,依次递增。

java71- 张威豹 3 years ago
parent
commit
4c2f57aa22

+ 25 - 7
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/controller/RecruitPlanMainController.java

@@ -104,15 +104,9 @@ public class RecruitPlanMainController extends BaseController
         Long deptId = getDeptId();
         SysDept sysDept = sysDeptService.selectDeptById(deptId);
         //默认生成一个岗位代码
-        String deptId1 =String.valueOf(getDeptId().intValue()) ;
-        double number = Math.random()*10000000;
-        String mathCode = String.valueOf(new Double(number).intValue());
-        String postNumId2 = mathCode+deptId1;
-
         mmap.put("deptId", sysDept.getDeptId());
         mmap.put("deptName", sysDept.getDeptName());
         mmap.put("recruitPlanYears",mapNeed.get("yearForAdd"));
-        mmap.put("postNumId",postNumId2);
         return prefix + "/add";
     }
 
@@ -232,7 +226,7 @@ public class RecruitPlanMainController extends BaseController
         return toAjax(true);
     }
 
-    /**
+        /**
      * 专业
      * @param major
      * @return
@@ -242,6 +236,30 @@ public class RecruitPlanMainController extends BaseController
     public AjaxResult setMajorValue(String major){
         return success(recruitPlanMainService.setMajorValue(major));
     }
+
+    /**
+     * 专业
+     * @param year
+     * @return
+     */
+    @PostMapping("/searchPostNumId")
+    @ResponseBody
+    public AjaxResult searchPostNumId(String year){
+         List<RecruitPlanMain> recruitPlanMainList = recruitPlanMainService.selectRecruitPlanByYear(year);
+         List<String> yearList = new ArrayList<>();
+         if (recruitPlanMainList.size()==0){
+             return error();
+         }
+         recruitPlanMainList.forEach(r->r.getAhrsRecruitPlanChildList().forEach(c->yearList.add(c.getPostNumId())));
+        String MAX = yearList.stream().max(String::compareTo).get();
+        if (MAX == null){
+            return error();
+        }
+         System.out.println(MAX);
+         return success(MAX);
+
+    }
+
     /**
      * 手写专业页面
      * @param mmap

+ 9 - 0
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/mapper/RecruitPlanMainMapper.java

@@ -21,6 +21,15 @@ public interface RecruitPlanMainMapper {
      */
     public RecruitPlanMain selectRecruitPlanMainById(Long recruitPlanMainId);
 
+    /**
+     * 根据招聘年份查询招聘计划
+     *
+     * @param year 招聘年份
+     * @return 招聘计划
+     */
+    public List<RecruitPlanMain> selectRecruitPlanByYear(String year);
+
+
     /**
      * 查询招聘计划列表
      *

+ 9 - 0
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/service/IRecruitPlanMainService.java

@@ -20,6 +20,15 @@ public interface IRecruitPlanMainService {
      */
     public RecruitPlanMain selectRecruitPlanMainById(Long recruitPlanMainId);
 
+
+    /**
+     * 根据招聘年份查询招聘计划
+     *
+     * @param year 招聘年份
+     * @return 招聘计划
+     */
+    public List<RecruitPlanMain> selectRecruitPlanByYear(String year);
+
     /**
      * 查询招聘计划列表
      *

+ 50 - 2
ruoyi-ahrs/src/main/java/com/ruoyi/ahrs/recruitplan/service/impl/RecruitPlanMainServiceImpl.java

@@ -75,6 +75,11 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         return  recruitPlanMain;
     }
 
+    @Override
+    public List<RecruitPlanMain> selectRecruitPlanByYear(String year) {
+        return recruitPlanMainMapper.selectRecruitPlanByYear(year);
+    }
+
     /**
      * 查询招聘计划列表
      *
@@ -185,6 +190,51 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         return rows;
     }
 
+    /**
+     * 新增recruitplan 定制 CJ
+     *
+     * @param recruitPlanMain recruitCJ
+     * @return 结果
+     */
+    @Transactional
+    public int insertRecruitPlanMainToCJ(RecruitPlanMain recruitCJ)
+    {
+        List<RecruitPlanChild> recruitPlanChildList = recruitCJ.getColumns();
+        List<String> postNumIdList = recruitPlanMainMapper.selectRecruitPlanMainListForCheckPostNumId(recruitCJ);
+        //再次校验子计划中的岗位代码是否与已有重复,概率为零
+        for (RecruitPlanChild recruitPlanChild : recruitPlanChildList){
+            if (postNumIdList.contains(recruitPlanChild.getPostNumId())){
+                return 11;
+            }
+        }
+        //给新增计划中的子计划delFlag赋值为"0''
+        recruitPlanChildList.forEach(recruitPlanChild -> recruitPlanChild.setDelFlag("0"));
+        recruitCJ.setAhrsRecruitPlanChildList(recruitPlanChildList);
+        recruitCJ.setCreateBy(ShiroUtils.getSysUser().getUserName());
+        recruitCJ.setCreateTime(DateUtils.getNowDate());
+        recruitCJ.setDelFlag("0");
+        //查看本单位本年是否有申报历史
+        RecruitPlanMain recruitPlanMainMemory = recruitPlanMainMapper.selectRecruitPlanMainByDeptIdAndYear(recruitCJ.getRecruitPlanYear(),recruitCJ.getDeptId());
+        if (recruitPlanMainMemory!=null){
+            recruitCJ.setVersion(recruitPlanMainMemory.getVersion()+1);
+        }
+        //给所有子计划版本赋值
+        for (int i=0;i<recruitPlanChildList.size();i++){
+            recruitPlanChildList.get(i).setVersion(1L);
+            recruitPlanChildList.get(i).setCreateBy(ShiroUtils.getSysUser().getUserName());
+            recruitPlanChildList.get(i).setCreateTime(DateUtils.getNowDate());
+        }
+
+        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;
+        }
+        recruitCJ.setCreateTime(DateUtils.getNowDate());
+        int rows = recruitPlanMainMapper.insertRecruitPlanMain(recruitCJ);
+        insertAhrsRecruitPlanChild(recruitCJ);
+        return rows;
+    }
 
 
     /*修改recruit
@@ -223,7 +273,6 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
         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);
@@ -437,7 +486,6 @@ public class RecruitPlanMainServiceImpl implements IRecruitPlanMainService {
 
     @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());

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

@@ -282,4 +282,22 @@
         )
     </select>
 
+    <select id="selectRecruitPlanByYear" parameterType="String" resultMap="RecruitPlanMainAhrsRecruitPlanChildResult">
+        select a.recruit_plan_main_id, a.declaration_id, a.dept_id, a.dept_name, a.recruit_plan_year, a.remark, a.attachment, a.version, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time,
+            b.recruit_plan_child_id as sub_recruit_plan_child_id, b.recruit_plan_main_id as sub_recruit_plan_main_id, b.post_id as sub_post_id, b.post_num_id as sub_post_num_id, b.nprs as sub_nprs, b.major as sub_major, b.education as sub_education, b.degree as sub_degree, b.age as sub_age, b.rests as sub_rests, b.public_course as sub_public_course, b.major_course as sub_major_course, b.remark as sub_remark, b.phone as sub_phone, b.attachment as sub_attachment, b.version as sub_version, b.del_flag as sub_del_flag, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time
+        from ahrs_recruit_plan_main a
+        left join ahrs_recruit_plan_child b on b.recruit_plan_main_id = a.recruit_plan_main_id
+        where a.recruit_plan_year = #{recruitPlanYear} and b.del_flag = '0'
+        and   a.version =(
+            SELECT
+            MAX( c.version )
+            FROM
+            ahrs_recruit_plan_main AS c
+            WHERE
+             a.dept_id = c.dept_id
+            and
+            a.recruit_plan_year = c.recruit_plan_year
+            )
+    </select>
+
 </mapper>

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

@@ -61,7 +61,7 @@
                 <div class="col-sm-4" >
                     <div class="form-group" style="width: 80%;margin: auto;" >
                         <label><span  >招聘计划年份</span></label>
-                            <select name="recruitPlanYear" id="recruitPlanYear" class="form-control">
+                            <select name="recruitPlanYear" id="recruitPlanYear" onclick="toPostNumId()" class="form-control">
                                 <option th:each="value : ${recruitPlanYears}" th:text="${value}" th:value="${value}" th:selected="${recruitPlanYear == value}"></option>
                             </select>
                     </div>
@@ -104,11 +104,9 @@
     var recruit_major = [[${@dict.getType('recruit_major')}]]; //专业科目
     var recruit_education = [[${@dict.getType('recruit_education')}]]; //学历
     var per_post_type = [[${@dict.getType('recruit_post_type')}]]; //岗位
-    var pnI = [[${postNumId}]];
-    var countNum =0;
     var prefix = ctx + "recruitplan/recruit";
-    var columnName;
     var columnId,options,specialtyMajor,undergraduateMajor,graduateMajor,otherMajor;
+    var PostIdToSearch;
     $(function () {
         options = {
             showRefresh: false,
@@ -345,7 +343,7 @@
                   }
                 }]
         };
-
+            toPostNumId();
             $.table.init(options);
     });
     var ggObj = null;
@@ -536,8 +534,26 @@
          }
     }
 
+    function toPostNumId() {
+            var year = $("#recruitPlanYear").val();
+            $.ajax({
+                url:prefix+"/searchPostNumId",
+                type:"post",
+                data: {"year": year},
+                success:function (data) {
+                    if(data.code == web_status.SUCCESS){
+                        PostIdToSearch = parseInt(data.msg) ;
+                    }else {
+                        var year = $("#recruitPlanYear").val();
+                        var number = parseInt(Math.random()*100000);
+                        PostIdToSearch = parseInt(year+number);
+                    }
+                }
+            });
+    }
+
     function insertRow() {
-        pnI = parseInt(pnI)+parseInt(countNum);
+        PostIdToSearch = PostIdToSearch + 1;
         var row;
         var rows = $("#bootstrap-table tr").bootstrapTable("getData");
         if (rows.length == '2' && $(rows[1]).find('td').text() === '没有找到匹配的记录') {
@@ -570,7 +586,7 @@
                 deptId: "",
                 deptName: "",
                 postId: "",
-                postNumId: pnI,
+                postNumId: PostIdToSearch,
                 nprs: "",
                 major: majorValue,
                 rests: "",
@@ -579,7 +595,6 @@
                 majorValue: "",
             }
         })
-        countNum++;
     }
 
     function remove(index, obj) {

+ 23 - 5
ruoyi-ahrs/src/main/resources/templates/ahrs/recruitplan/edit.html

@@ -96,8 +96,8 @@
     var deletNum = 0 ;
     var prefix = ctx + "recruitplan/recruit"; ///recruitplan/recruit
     var columnId;
-    var columnName;
     var options;
+    var PostIdToSearch;
     $(function () {
         options = {
             url: prefix+"/editList",
@@ -318,6 +318,7 @@
                     }
                 }]
         };
+        toPostNumId();
         $.table.init(options);
 
     });
@@ -544,8 +545,26 @@
     }
 */
 
-    function insertRow() {
-        pnI = parseInt(pnI)+parseInt(countNum);
+        function toPostNumId() {
+            var year = $("#recruitPlanYear").val();
+            $.ajax({
+                url:prefix+"/searchPostNumId",
+                type:"post",
+                data: {"year": year},
+                success:function (data) {
+                    if(data.code == web_status.SUCCESS){
+                        PostIdToSearch = parseInt(data.msg) ;
+                    }else {
+                        var year = $("#recruitPlanYear").val();
+                        var number = parseInt(Math.random()*100000);
+                        PostIdToSearch = parseInt(year+number);
+                    }
+                }
+            });
+        }
+
+       function insertRow() {
+        PostIdToSearch = PostIdToSearch + 1;
         var row;
         var rows = $("#bootstrap-table tr").bootstrapTable("getData");
         if (rows.length == '2' && $(rows[1]).find('td').text() === '没有找到匹配的记录') {
@@ -600,7 +619,7 @@
                     deptId: "",
                     deptName: "",
                     postId: "",
-                    postNumId: pnI,
+                    postNumId: PostIdToSearch,
                     nprs: "",
                     yprs:  0,
                     major: JSON.stringify(majorValue),
@@ -611,7 +630,6 @@
                 }
             })
         }
-        countNum++;
     }
 
     function remove(index, obj) {