ZpglH5Controller.java 7.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
package cn.timer.api.controller.zpgl;

import cn.timer.api.aspect.lang.annotation.Log;
import cn.timer.api.aspect.lang.enums.BusinessType;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.bean.zpgl.*;
import cn.timer.api.config.enuminterface.JxglEnumInterface;
import cn.timer.api.controller.zpgl.sevice.ZpglMslcLogService;
import cn.timer.api.dto.zpgl.InterviewApplicationDto;
import cn.timer.api.utils.DateFormatUtils;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import cn.timer.api.utils.ZpglMessageTemplate;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "招聘管理")
@Transactional(rollbackOn = Exception.class)
@RestController
@RequestMapping(value = "/zpgl/h5")
public class ZpglH5Controller {



    @Autowired
    private ZpglMslcLogService zpglMslcLogService;

    /**
     * 添加面试申请
     * @param
     * @return
     */
    @RequestMapping("/add_interview_application")
    @ApiOperation(value = "添加面试申请", httpMethod = "POST", notes = "添加面试申请")
    @Log(title = "addInterviewApplication", businessType = BusinessType.INSERT_UPDATE)
    public Result<Object> addInterviewApplication(@Validated @RequestBody InterviewApplicationDto dto) {

        System.out.println(dto);
        ZpglRcxx zpglRcxx = new ZpglRcxx();
        //复制到 ZpglRcxx 实体对象
        BeanUtils.copyProperties(dto,zpglRcxx);
        /**
         * 新增需要添加
         * 是否初始化面试流程记录
         */
        boolean insertZpglMslcLogFlag = StringUtils.isEmpty(zpglRcxx.getId());
        // 计算工作年限
        if(!StringUtils.isEmpty(zpglRcxx.getWorkBeginYear())){
            zpglRcxx.setWorkyears(DateFormatUtils.yearCompare(zpglRcxx.getWorkBeginYear(),new Date()));
        }
        zpglRcxx.insertOrUpdate();

        if(insertZpglMslcLogFlag){
            // 新增人才信息 初始化流程记录
            ZpglMslcLog zpglMslcLog = new ZpglMslcLog();
            zpglMslcLog.setZpglRcxxId(zpglRcxx.getId());
            zpglMslcLog.setUserId(0);
            zpglMslcLog.setUserName("");
            zpglMslcLog.setZpglRcxxStatus(JxglEnumInterface.MslcLogStatus.OTHER.getType());
            zpglMslcLog.setDetail(ZpglMessageTemplate.SYS_ADD);
            zpglMslcLogService.addZpglMslcLog(zpglMslcLog);
        }

        //添加紧急联系人
        if(dto.getZpglRcxxLxxxb() != null){
            ZpglRcxxLxxxb zpglRcxxLxxxb = dto.getZpglRcxxLxxxb();
            zpglRcxxLxxxb.setZpglRcxxId(zpglRcxx.getId());
            zpglRcxxLxxxb.insertOrUpdate();
        }

        //新增/修改工作经验
        if(dto.getZpglRcxxExperience() !=null && dto.getZpglRcxxExperience().size()>0){
            List<ZpglRcxxExperience> experiences = dto.getZpglRcxxExperience();
            for(ZpglRcxxExperience experience : experiences){
                if(experience.getCompany() != null){
                    experience.setZpglRcxxId(zpglRcxx.getId());
                    experience.insertOrUpdate();
                }
            }
        }

        //新增/修改教育经历
        if(dto.getZpglRcxxStudy() !=null && dto.getZpglRcxxStudy().size()>0){
            List<ZpglRcxxStudy> zpglRcxxStudys = dto.getZpglRcxxStudy();
            for(ZpglRcxxStudy study : zpglRcxxStudys){
                if(study.getSchoolName() != null){
                    study.setZpglRcxxId(zpglRcxx.getId());
                    study.insertOrUpdate();
                }
            }
        }
        //新增/修改家庭资料
        if(dto.getZpglRcxxJtzls() !=null && dto.getZpglRcxxJtzls().size()>0){
            List<ZpglRcxxJtzl> zpglRcxxJtzls = dto.getZpglRcxxJtzls();
            for(ZpglRcxxJtzl jtzl : zpglRcxxJtzls){
                if(jtzl.getName() != null){
                    jtzl.setZpglRcxxId(zpglRcxx.getId());
                    jtzl.insertOrUpdate();
                }
            }
        }


        return ResultUtil.success();
    }

    /**
     * 查询面试申请信息
     * @param
     * @return
     */
    @RequestMapping("/interview_application_info")
    @ApiOperation(value = "查询面试申请信息", httpMethod = "GET", notes = "查询面试申请信息")
    @Log(title = "interviewApplicationIofo", businessType = BusinessType.INSERT_UPDATE)
    public Result<InterviewApplicationDto> interviewApplicationIofo(@RequestParam String mobile,Integer zpglRcxxId) {

        InterviewApplicationDto dto = new InterviewApplicationDto();
        List<ZpglRcxx> zpglRcxxes = new ArrayList<>();
        if(null != zpglRcxxId){
            zpglRcxxes = ZpglRcxx.builder().build()
                    .selectList(new QueryWrapper<ZpglRcxx>().lambda()
                            .eq(ZpglRcxx::getId, zpglRcxxId));
        }else{
            zpglRcxxes = ZpglRcxx.builder().build()
                    .selectList(new QueryWrapper<ZpglRcxx>().lambda()
                            .eq(ZpglRcxx::getMobile, mobile));
        }
        if(zpglRcxxes.size() == 0){
            return ResultUtil.error("没有简历信息");
        }



        ZpglRcxx zpglRcxx = zpglRcxxes.get(0);
        //复制到dto
        BeanUtils.copyProperties(zpglRcxx,dto);

        //联系人信息
        List<ZpglRcxxLxxxb> zpglRcxxLxxxbs = ZpglRcxxLxxxb.builder().build().selectList(new QueryWrapper<ZpglRcxxLxxxb>()
                .lambda().select(ZpglRcxxLxxxb::getId,ZpglRcxxLxxxb::getLinkName,ZpglRcxxLxxxb::getLinkMobile)
                .eq(ZpglRcxxLxxxb::getZpglRcxxId, zpglRcxx.getId()));
        if(zpglRcxxLxxxbs.size()>0)
            dto.setZpglRcxxLxxxb(zpglRcxxLxxxbs.get(0));



        //工作经验
        List<ZpglRcxxExperience> experiences = ZpglRcxxExperience.builder().build()
                .selectList(new QueryWrapper<ZpglRcxxExperience>()
                .lambda().eq(ZpglRcxxExperience::getZpglRcxxId, zpglRcxx.getId()));
        if (experiences.size()>0)
            dto.setZpglRcxxExperience(experiences);

        //教育经历
        List<ZpglRcxxStudy> study = ZpglRcxxStudy.builder().build()
                .selectList(new QueryWrapper<ZpglRcxxStudy>()
                        .lambda().eq(ZpglRcxxStudy::getZpglRcxxId, zpglRcxx.getId()));
        if (study.size()>0)
            dto.setZpglRcxxStudy(study);

        //家庭资料
        List<ZpglRcxxJtzl> jtzl = ZpglRcxxJtzl.builder().build()
                .selectList(new QueryWrapper<ZpglRcxxJtzl>()
                        .lambda().eq(ZpglRcxxJtzl::getZpglRcxxId, zpglRcxx.getId()));
        if (jtzl.size()>0)
            dto.setZpglRcxxJtzls(jtzl);

        return ResultUtil.data(dto,"查询成功");
    }

    @RequestMapping("/getOrgName")
    @ApiOperation(value = "根据orgCode获取企业名称", httpMethod = "GET", notes = "获取企业名称")
    public Object getOrgName(@RequestParam("orgCode") Integer orgCode){
        QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().build()
                .selectOne(new QueryWrapper<QyzxEntInfoM>().lambda()
                        .select(QyzxEntInfoM::getName).eq(QyzxEntInfoM::getId, orgCode));

        return ResultUtil.data(qyzxEntInfoM);
    }

}