智慧保安后台管理-外网
Administrator
2021-08-16 767f8e4c5b8bdb9b87c7529fe01220f7fa3671b1
1.取消报名接口修改,
2.批量报名接口修改
8 files modified
86 ■■■■■ changed files
src/main/java/org/springblade/modules/apply/controller/ApplyController.java 45 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/excel/ApplyExcel.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml 7 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/service/ApplyService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/vo/ApplyVO.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -98,7 +98,7 @@
            if (1==user.getIsApply()){
                return R.data(201,"已报名,不能重复报名");
            }
            if (2==user.getIsApply()){
            if (2==user.getIsApply() || -1==user.getIsApply()){
                //默认通过
                apply.setApplyStatus(2);
                //默认为未考试状态
@@ -408,6 +408,44 @@
    /**
     * 公司报名列表取消报名,无applyId
     * @param apply 考试报名信息对象
     */
    @PostMapping("/cancelApplyNotApplyId")
    public R cancelApplyNotApplyId(@RequestBody Apply apply){
        //查询人员是否已报名
        User user = userService.getById(apply.getUserId());
        //查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录
        Apply apply1 = applyService.getMaxApplyIdByUserIdInfo(apply.getUserId());
        if(null==user.getIsApply()){
            apply1.setApplyStatus(4);
            boolean status = applyService.updateById(apply1);
            //修改保安报名状态
            user.setIsApply(2);
            userService.updateById(user);
            if (status){
                return R.data(200,"取消报名成功");
            }
        }else {
            if (user.getIsApply()==2) {
                return R.data(201,"尚未报名");
            }
            if(user.getIsApply()==1){
                apply1.setApplyStatus(4);
                boolean status = applyService.updateById(apply1);
                //修改保安报名状态
                user.setIsApply(2);
                userService.updateById(user);
                if (status){
                    return R.data(200,"取消报名成功");
                }
            }
        }
        return R.data(202,"取消报名失败");
    }
    /**
     * 批量报名
     * @param ids userIds 人员
     */
@@ -430,7 +468,7 @@
                    user.setIsApply(1);
                    userService.updateById(user);
                } else {
                    if (user.getIsApply() == 2) {
                    if (user.getIsApply() == 2 || -1==user.getIsApply()) {
                        Apply apply1 = new Apply();
                        apply1.setApplyStatus(2);
                        //默认为未考试状态
@@ -447,6 +485,7 @@
        }else {
            //查询所有未报名的人员
            List<User> users = userService.getNotApplyIdList(deptId);
            System.out.println("users = " + users.size());
            if (users.size()>0){
                users.forEach(user ->{
                    //未报名的新增,已报名的不做处理
@@ -462,7 +501,7 @@
                        user.setIsApply(1);
                        userService.updateById(user);
                    } else {
                        if (user.getIsApply() == 2) {
                        if (user.getIsApply() == 2 || -1==user.getIsApply()) {
                            Apply apply1 = new Apply();
                            apply1.setApplyStatus(2);
                            //默认为未考试状态
src/main/java/org/springblade/modules/apply/excel/ApplyExcel.java
@@ -37,6 +37,12 @@
    private static final long serialVersionUID = 1L;
    @ColumnWidth(25)
    @ExcelProperty("公司名称")
    private String deptName;
    @ColumnWidth(15)
    @ExcelProperty("保安姓名")
    private String realName;
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.java
@@ -125,4 +125,11 @@
     * @return
     */
    List<ApplyVO> getTrainDetailList(Long id);
    /**
     * 查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录
     * @param userId
     * @return
     */
    Apply getMaxApplyIdByUserIdInfo(@Param("userId") Long userId);
}
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
@@ -8,7 +8,7 @@
            sa.id,sa.apply_status applyStatus,sa.user_id userId,sa.candidate_no candidateNo,apply_time,exam_id examId,
            sa.examination_type examinationType,sa.examination_mx examinationMx,
            ke.total_score paperScore,ke.exam_type examType,ke.start_time examTime,ke.exam_name examName,
            bu.real_name realName,bu.is_apply isApply,
            bu.real_name realName,bu.is_apply isApply, TIMESTAMPDIFF(YEAR, bu.birthday, CURDATE()) age,
            bd.dept_name deptName,bu.cardid idCardNo,"保安证" applyCard
        FROM
            sys_apply sa
@@ -346,4 +346,9 @@
        </if>
    </select>
    <!--查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录-->
    <select id="getMaxApplyIdByUserIdInfo" resultType="org.springblade.modules.apply.entity.Apply">
        select MAX(id) id from sys_apply where user_id = #{userId}
    </select>
</mapper>
src/main/java/org/springblade/modules/apply/service/ApplyService.java
@@ -109,4 +109,11 @@
     * @return
     */
    void updateApplyStatus(ApplyVO apply);
    /**
     * 查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录
     * @param userId
     * @return
     */
    Apply getMaxApplyIdByUserIdInfo(Long userId);
}
src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
@@ -115,7 +115,7 @@
                    user1.setIsApply(1);
                    userService.updateById(user1);
                }else {
                    if (user1.getIsApply()==2) {
                    if (user1.getIsApply()==2 || -1==user.getIsApply()) {
                        Apply apply1 = new Apply();
                        apply1.setApplyStatus(2);
                        //默认为未考试状态
@@ -423,4 +423,14 @@
            trainingRegistrationService.updateById(trainingRegistration);
        }
    }
    /**
     * 查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录
     * @param userId
     * @return
     */
    @Override
    public Apply getMaxApplyIdByUserIdInfo(Long userId) {
        return baseMapper.getMaxApplyIdByUserIdInfo(userId);
    }
}
src/main/java/org/springblade/modules/apply/vo/ApplyVO.java
@@ -87,5 +87,4 @@
     * 性别 1:男  2:女
     */
    private Integer sex;
}
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -389,7 +389,6 @@
        sa.user_id = bu.id
        where 1=1
        and (hold=2 or hold = 3)
        and (sa.is_exam != 1 or sa.is_exam is null)
        and (bu.is_apply != 1 or bu.is_apply is null)
        and (sa.apply_status !=2 or sa.apply_status is null)
        and bu.dept_id = #{deptId}