ZpglServiceImpl.java 41.8 KB
Newer Older
1 2
package cn.timer.api.controller.zpgl.sevice;

3
import cn.timer.api.bean.clazz.SysRegion;
4
import cn.timer.api.bean.wechat.MessageTemplate;
5
import cn.timer.api.bean.yggl.YgglMainEmp;
6
import cn.timer.api.bean.zpgl.*;
7
import cn.timer.api.bean.zzgl.ZzglBmgwM;
8 9
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enuminterface.JxglEnumInterface;
10
import cn.timer.api.controller.kqgl.ClockInTool;
11
import cn.timer.api.dto.baidu.*;
12
import cn.timer.api.bean.clazz.NationClass;
13 14
import cn.timer.api.dto.resumesdk.*;
import cn.timer.api.dto.resumesdk.enumresume.ResumeSdk;
15
import cn.timer.api.dto.template.InterviewNotice;
16
import cn.timer.api.dto.zpgl.ImportCandidateDto;
17
import cn.timer.api.dto.zpgl.ZpglRcxxDto;
18
import cn.timer.api.service.OSSService;
19 20
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
21
import cn.timer.api.utils.ZpglMessageTemplate;
22 23
import cn.timer.api.utils.baidu.BaiduTicUtil;
import cn.timer.api.utils.baidu.Base64;
284718418@qq.com committed
24
import cn.timer.api.utils.resumesdk.ResumeSDKUtil;
25
import com.alibaba.fastjson.JSONArray;
26
import com.alibaba.fastjson.JSONObject;
27
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
28
import lombok.extern.slf4j.Slf4j;
29
import org.springframework.beans.factory.annotation.Autowired;
30
import org.springframework.beans.factory.annotation.Value;
31
import org.springframework.http.ResponseEntity;
32
import org.springframework.mail.javamail.JavaMailSender;
33 34
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
35
import org.springframework.web.multipart.MultipartFile;
36 37 38

import javax.transaction.Transactional;
import java.text.SimpleDateFormat;
39
import java.util.Date;
40
import java.util.List;
41 42 43 44 45 46

/**
 * @author wuqingjun
 * @email 284718418@qq.com
 * @date 2022/3/18
 */
47
@Slf4j
48 49 50 51
@Service
@Transactional(rollbackOn = Exception.class)
public class ZpglServiceImpl implements ZpglService {

52 53 54
    @Value("${spring.mail.username}")
    private String username;

55
    @Autowired
56
    private BaiduTicUtil baiduTicUtil;
284718418@qq.com committed
57 58
    @Autowired
    private ResumeSDKUtil resumeSDKUtil;
59 60

    @Autowired
61 62 63
    private JavaMailSender mailSender;

    @Autowired
64 65
    private ZpglMslcLogService zpglMslcLogService;

66 67 68
    @Autowired
    private ZpglWxgzptServiceImpl zpglWxgzptService;

69 70 71
    @Autowired
    private OSSService ossService;

284718418@qq.com committed
72 73 74
    @Value("${config-8timer.Aliyun.RESUMESDK_APPCODE}")
    private String RESUMESDK_APPCODE;

75 76 77 78

    @Override
    public boolean updateZpglRcxx(UserBean userBean, ZpglRcxxDto zpglRcxxDto) {
        boolean count = false;
79
        ZpglRcxx zpglRcxxEntity = ZpglRcxx.builder().id(zpglRcxxDto.getId()).build().selectById();
284718418@qq.com committed
80
        if (StringUtils.isEmpty(zpglRcxxEntity)) {
81 82 83
            return count;
        }
        zpglRcxxDto.setName(zpglRcxxEntity.getName());
84 85 86 87 88
        ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(zpglRcxxDto.getId()).status(zpglRcxxDto.getStatus()).build();
        ZpglMslcLog zpglMslcLog = new ZpglMslcLog();
        zpglMslcLog.setZpglRcxxId(zpglRcxxDto.getId());
        zpglMslcLog.setUserId(userBean.getEmpNum());
        zpglMslcLog.setUserName(userBean.getQyzxEmpLogin().getUsername());
284718418@qq.com committed
89
        if (!StringUtils.isEmpty(zpglRcxxDto.getIfrck()) && zpglRcxxDto.getIfrck().intValue() == 1) {
90 91
            zpglRcxx.setIfrckTime(new Date());
        }
284718418@qq.com committed
92 93 94
        if(!StringUtils.isEmpty(zpglRcxxDto.getCreateTime())){
            zpglRcxx.setCreateTime(zpglRcxxDto.getCreateTime());
        }
95
        String detail = "";
96 97
        // 类型,1状态变更,2面试,3Offer,4讨论,5其他
        int zpglRcxxStatus = 0;
98
        switch (zpglRcxxDto.getStatus()) {
99
            case 1:
100
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.CHANGEING.getType();
101 102 103 104
                //待初筛 填充字段
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.FILTERING, new String[]{
                        userBean.getQyzxEmpLogin().getUsername()});
                break;
105
            case 2:
106
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.CHANGEING.getType();
107 108 109 110 111 112
                //初筛通过 填充字段
                zpglRcxx.setIfrck(zpglRcxxDto.getIfrck());
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.FILTER_PASS, new String[]{
                        userBean.getQyzxEmpLogin().getUsername()});
                break;
            case 3:
113
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.INTERVIEW.getType();
114 115 116 117 118 119 120 121 122 123 124 125 126 127
                //安排面试 填充字段
                zpglRcxx.setInterviewNum(zpglRcxxDto.getInterviewNum());
                zpglRcxx.setInterviewWay(zpglRcxxDto.getInterviewWay());
                zpglRcxx.setInterviewerId(zpglRcxxDto.getInterviewerId());
                zpglRcxx.setInterviewTime(zpglRcxxDto.getInterviewTime());
                zpglRcxx.setNoticeWay(zpglRcxxDto.getNoticeWay());
                YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().select("name").lambda().eq(YgglMainEmp::getEmpNum, zpglRcxxDto.getInterviewerId()));
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.INTERVIEW, new String[]{
                        userBean.getQyzxEmpLogin().getUsername(),
                        zpglRcxxDto.getInterviewNum().toString(),
                        new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(zpglRcxxDto.getInterviewTime()),
                        ygglMainEmp.getName()});
                break;
            case 4:
128
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.INTERVIEW.getType();
129
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.INTERVIEWED, new String[]{
130
                        userBean.getQyzxEmpLogin().getUsername(), zpglRcxxEntity.getInterviewNum().toString()});
131 132
                break;
            case 5:
133
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.INTERVIEW.getType();
134 135 136 137
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.INTERVIEW_PASS, new String[]{
                        userBean.getQyzxEmpLogin().getUsername()});
                break;
            case 6:
138
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.INTERVIEW.getType();
139 140 141 142
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.EMPLOY, new String[]{
                        userBean.getQyzxEmpLogin().getUsername()});
                break;
            case 7:
143
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OFFER.getType();
144 145 146 147 148 149 150
                //发送offer 填充字段
                zpglRcxx.setBmgwId(zpglRcxxDto.getBmgwId());
                zpglRcxx.setJobType(zpglRcxxDto.getJobType());
                zpglRcxx.setYjrzTime(zpglRcxxDto.getYjrzTime());
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.OFFER, new String[]{
                        userBean.getQyzxEmpLogin().getUsername()});
                //发送offer
284718418@qq.com committed
151
                ZpglRcxxOffer zpglRcxxOffer = this.insertZpglRcxxOffer(userBean, zpglRcxxDto);
284718418@qq.com committed
152
                zpglRcxxOffer.setReceiverEmail(zpglRcxxEntity.getMail());
284718418@qq.com committed
153
                Thread pthread = new Thread(new ZpglSendMessageThread(mailSender, zpglRcxxOffer));
154
                pthread.start();
155 156
                break;
            case 8:
157
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
158 159 160 161 162 163 164 165 166
                //待入职 填充字段
                zpglRcxx.setBmgwId(zpglRcxxDto.getBmgwId());
                zpglRcxx.setJobType(zpglRcxxDto.getJobType());
                zpglRcxx.setYjrzTime(zpglRcxxDto.getYjrzTime());
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.WAIT, new String[]{
                        userBean.getQyzxEmpLogin().getUsername()});
                break;
            case 9:
                //淘汰 填充字段
167 168 169 170
                if(!StringUtils.isEmpty(zpglRcxxDto.getIfrck())){
                    zpglRcxx.setIfrck(zpglRcxxDto.getIfrck());
                    zpglRcxx.setIfrckTime(new Date());
                }
171 172 173
                zpglRcxx.setZpglFailId(zpglRcxxDto.getZpglFailId());
                zpglRcxx.setRemarks(zpglRcxxDto.getRemarks());
                ZpglFail zpglFail = ZpglFail.builder().id(zpglRcxxDto.getZpglFailId()).build().selectById();
284718418@qq.com committed
174
                String messageTemplate = ZpglMessageTemplate.ENTRYING, titleLabel = "";
175
                if (!StringUtils.isEmpty(zpglFail)) {
176 177
                    if (zpglFail.getZpglRcxxStatus().equals(JxglEnumInterface.ResumeStatus.INTERVIEWED.getType())) {
                        titleLabel = JxglEnumInterface.ResumeStatus.INTERVIEWED.getName();
178
                        zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
179 180
                        messageTemplate = ZpglMessageTemplate.INTERVIEWED_ENTRYING;
                    }
284718418@qq.com committed
181
                    if (zpglFail.getZpglRcxxStatus().equals(JxglEnumInterface.ResumeStatus.INTERVIEW_PASS.getType())) {
182 183 184 185
                        titleLabel = JxglEnumInterface.ResumeStatus.INTERVIEW_PASS.getName();
                        zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
                        messageTemplate = ZpglMessageTemplate.INTERVIEWED_ENTRYING;
                    }
284718418@qq.com committed
186
                    if (zpglFail.getZpglRcxxStatus().equals(JxglEnumInterface.ResumeStatus.INTERVIEW.getType())) {
187 188 189 190 191 192 193 194 195 196
                        titleLabel = JxglEnumInterface.ResumeStatus.INTERVIEW.getName();
                        zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
                        messageTemplate = ZpglMessageTemplate.INTERVIEWED_ENTRYING;
                    }

                    if (zpglFail.getZpglRcxxStatus().equals(JxglEnumInterface.ResumeStatus.EMPLOY.getType())) {
                        titleLabel = JxglEnumInterface.ResumeStatus.EMPLOY.getName();
                        zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
                        messageTemplate = ZpglMessageTemplate.OFFER_ENTRYING;
                    }
197
                    if (zpglFail.getZpglRcxxStatus().equals(JxglEnumInterface.ResumeStatus.OFFER.getType())) {
198 199 200 201 202 203 204 205 206 207 208
                        titleLabel = JxglEnumInterface.ResumeStatus.OFFER.getName();
                        zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
                        messageTemplate = ZpglMessageTemplate.OFFER_ENTRYING;
                    }
                    if (zpglFail.getZpglRcxxStatus().equals(JxglEnumInterface.ResumeStatus.ENTRYING.getType())) {
                        titleLabel = JxglEnumInterface.ResumeStatus.ENTRYING.getName();
                        zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
                        messageTemplate = ZpglMessageTemplate.OFFER_ENTRYING;
                    }
                    if (zpglFail.getZpglRcxxStatus().equals(JxglEnumInterface.ResumeStatus.ENTRY.getType())) {
                        titleLabel = JxglEnumInterface.ResumeStatus.ENTRY.getName();
209
                        zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
210 211 212
                        messageTemplate = ZpglMessageTemplate.OFFER_ENTRYING;
                    }
                    detail = ZpglMessageTemplate.print(messageTemplate, new String[]{
284718418@qq.com committed
213
                            userBean.getUserInfo().getName(), zpglFail.getFailCause(), StringUtils.isEmpty(zpglRcxxDto.getRemarks())?"":zpglRcxxDto.getRemarks(), titleLabel});
214 215 216
                }
                break;
            case 10:
217
                zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
218 219 220 221 222 223 224
                //确认入职
                detail = ZpglMessageTemplate.print(ZpglMessageTemplate.ENTRY, new String[]{
                        userBean.getQyzxEmpLogin().getUsername()});
                break;
            default:
                break;
        }
225
        zpglMslcLog.setZpglRcxxStatus(zpglRcxxStatus);
226 227 228
        zpglMslcLog.setDetail(detail);
        count = zpglRcxx.updateById();
        zpglMslcLogService.addZpglMslcLog(zpglMslcLog);
229
        // 发送面试通知
284718418@qq.com committed
230
        if (count && JxglEnumInterface.ResumeStatus.INTERVIEW.getType().equals(zpglRcxxDto.getStatus()) && JxglEnumInterface.NoticeWay.WECHAT_PUBLIC.getType().equals(zpglRcxxDto.getNoticeWay())) {
231
            InterviewNotice interviewNotice = new InterviewNotice();
284718418@qq.com committed
232 233 234 235
            ZpglZwxx zpglZwxx = ZpglZwxx.builder().id(zpglRcxxEntity.getZpglZwxxId()).build().selectById();
            if (!StringUtils.isEmpty(zpglZwxx)) {
                interviewNotice.setZpglZwxxName(zpglZwxx.getName());
            }
236
            interviewNotice.setName(zpglRcxxEntity.getName());
284718418@qq.com committed
237 238 239 240
            interviewNotice.setType(zpglRcxxDto.getNoticeWay());
            interviewNotice.setEmail(zpglRcxxEntity.getMail());
            //公众号类型 1:8小时企业管理 2:优领人才网
            interviewNotice.setWxgzhType(1);
284718418@qq.com committed
241 242
            //0 即时发送,1 定时发送
            interviewNotice.setTiming(0);
243 244
            interviewNotice.setInterviewTime(zpglRcxxDto.getInterviewTime());
            // 通知面试官
284718418@qq.com committed
245
            YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().select("phone").lambda()
284718418@qq.com committed
246 247
                    .eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()).eq(YgglMainEmp::getEmpNum, zpglRcxxDto.getInterviewerId()));
            if (!StringUtils.isEmpty(ygglMainEmp)) {
284718418@qq.com committed
248 249 250
                interviewNotice.setMobile(ygglMainEmp.getPhone());
                interviewNotice.setYgglMainEmpId(ygglMainEmp.getId());
            }
251
            interviewNotice.setTemplateId(MessageTemplate.TEMPLATE_ID_TO_INTERVIEWER);
252
            interviewNotice.setContentStr(ZpglMessageTemplate.print(ZpglMessageTemplate.TO_INTERVIEWER, new String[]{interviewNotice.getName()}));
284718418@qq.com committed
253
            log.info("TO_INTERVIEWER addInterviewMessageQueue info:{}", zpglWxgzptService.addInterviewMessageQueue(interviewNotice));
254
            // 通知面试者
284718418@qq.com committed
255
            interviewNotice.setZpglRcxxId(zpglRcxxEntity.getId());
256
            interviewNotice.setMobile(zpglRcxxEntity.getMobile());
257
            interviewNotice.setRemark("请您提前做好准备,妥善安排接面试的时间~如有疑问,请联系 HR");
284718418@qq.com committed
258 259
            interviewNotice.setContentStr(ZpglMessageTemplate.print(ZpglMessageTemplate.TO_INTERVIEWEE, new String[]{interviewNotice.getName(), interviewNotice.getZpglZwxxName()}));
            log.info("TO_INTERVIEWEE addInterviewMessageQueue info:{}", zpglWxgzptService.addInterviewMessageQueue(interviewNotice));
260
        }
261 262
        return count;
    }
263 264 265 266 267 268 269 270

    @Override
    public SysRegion getSysRegion(Integer keyId) {
        return SysRegion.builder().build()
                .selectOne(new QueryWrapper<SysRegion>().lambda().eq(SysRegion::getKeyId, keyId).select(
                        SysRegion::getRegionName, SysRegion::getKeyId, SysRegion::getZipCode,
                        SysRegion::getRegionCode));
    }
271 272

    @Override
273
    public Result<Object> addResumeImportCandidate(UserBean userBean, MultipartFile file, ImportCandidateDto importCandidateDto) {
274 275 276 277 278
        BaiduTicResumeDto baiduTicResumeDto = BaiduTicResumeDto.builder().filename(file.getOriginalFilename()).filetype(importCandidateDto.getSuffix()).filedata(Base64.getStrFromPath(file)).build();
        ResponseEntity<String> resumeString = baiduTicUtil.getResumeByCvParser(baiduTicResumeDto);
        JSONObject json = (JSONObject) JSONObject.parse(resumeString.getBody());
        log.info("招聘-导入候选人简历{}", resumeString.getBody());
        ResumeExtract resumeExtract = null;
284718418@qq.com committed
279 280
        if ("success".equals(json.get("error_msg"))) {
            if (StringUtils.isEmpty(json.get("results"))) {
281
                log.info("招聘-导入候选人简历:results is null");
282
                return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
283
            }
284718418@qq.com committed
284 285
            JSONArray array = (JSONArray) json.get("results");
            if (StringUtils.isEmpty(array.get(0))) {
286
                log.info("招聘-导入候选人简历:results is null");
287
                return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
288 289
            }
            JSONObject resultsJsonObject = (JSONObject) array.get(0);
284718418@qq.com committed
290 291
            resumeExtract = JSONObject.toJavaObject((JSONObject) resultsJsonObject.get("extract"), ResumeExtract.class);
        } else {
292
            return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
293
        }
284718418@qq.com committed
294
        if (StringUtils.isEmpty(resumeExtract) || StringUtils.isEmpty(resumeExtract.getBasic_infos())) {
295
            return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
296
        }
297 298 299 300 301
        Result<String> data = ossService.upload(userBean.getOrgCode(), "zpgl", file);
        if(!StringUtils.isEmpty(data) && !StringUtils.isEmpty(data.getData())){
            importCandidateDto.setFilePath(data.getData());
            importCandidateDto.setFileName(file.getOriginalFilename());
        }
302
        return this.addZpglRcxx(userBean, resumeExtract, importCandidateDto);
303 304
    }

305
    @Override
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
    public Result<Object> addCandidateByResumeSDK(UserBean userBean, MultipartFile file, ImportCandidateDto importCandidateDto) {
        ResumeSdkDto resumeSdkDto = ResumeSdkDto.builder().ocr_type(1).need_avatar(0).file_name(file.getOriginalFilename()).file_cont(Base64.getStrFromPath(file)).build();
        String resumeString = "";
        try {
            resumeString = resumeSDKUtil.getResumeByCvParser(resumeSdkDto, RESUMESDK_APPCODE);
        }catch (Exception e){
            e.printStackTrace();
        }
        JSONObject json = (JSONObject) JSONObject.parse(resumeString);
        log.info("招聘-导入候选人简历{}", resumeString);
        if(StringUtils.isEmpty(json)){
            log.error("招聘-导入候选人简历: resumeSDKUtil.getResumeByCvParser return null. ");
            return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
        }
        Status statusEntity = JSONObject.toJavaObject((JSONObject) json.get("status"), Status.class);
        if(StringUtils.isEmpty(statusEntity) || !ResumeSdk.StatusCodeEnum.SUCCESSS.getType().equals(statusEntity.getCode())){
            log.error("招聘-导入候选人简历:{}",ResumeSdk.StatusCodeEnum.getName(statusEntity.getCode()));
            return ResultUtil.error("导入简历失败,请联系管理员~("+ResumeSdk.StatusCodeEnum.getName(statusEntity.getCode())+")");
        }
        Result<String> data = ossService.upload(userBean.getOrgCode(), "zpgl", file);
        if(!StringUtils.isEmpty(data) && !StringUtils.isEmpty(data.getData())){
            importCandidateDto.setFilePath(data.getData());
            importCandidateDto.setFileName(file.getOriginalFilename());
        }
        return this.addZpglRcxx(userBean, json, importCandidateDto);
    }
    @Override
333 334 335 336 337 338 339
    public boolean updateZpglRcxxZwxx(UserBean userBean, ZpglRcxxDto zpglRcxxDto) {
        ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(zpglRcxxDto.getId()).zpglZwxxId(zpglRcxxDto.getZpglZwxxId()).build();
        ZpglMslcLog zpglMslcLog = new ZpglMslcLog();
        zpglMslcLog.setZpglRcxxId(zpglRcxxDto.getId());
        zpglMslcLog.setUserId(userBean.getEmpNum());
        zpglMslcLog.setUserName(userBean.getQyzxEmpLogin().getUsername());
        zpglMslcLog.setZpglRcxxStatus(JxglEnumInterface.MslcLogStatus.OTHER.getType());
284718418@qq.com committed
340
        zpglMslcLog.setDetail(userBean.getQyzxEmpLogin().getUsername() + " 更改候选人应聘职位.");
341 342 343 344
        zpglRcxx.updateById();
        return zpglMslcLogService.addZpglMslcLog(zpglMslcLog);
    }

345
    @Override
284718418@qq.com committed
346
    public boolean updateZpglOther(UserBean userBean, ZpglRcxxDto zpglRcxxDto,Integer ygglMainEmpId) {
347 348 349 350 351 352 353 354 355 356 357 358 359 360
        // 招聘-变更人才信息状态
        // 添加面试流程记录
        this.updateZpglRcxx(userBean,zpglRcxxDto);
        // 职位信息已入职人数+1
        ZpglZwxx zpglZwxx = ZpglZwxx.builder().id(zpglRcxxDto.getZpglZwxxId()).build().selectById();
        if(!StringUtils.isEmpty(zpglZwxx)){
            zpglZwxx.setEntryNum(zpglZwxx.getEntryNum()+1);
            zpglZwxx.updateById();
        }
        // 维护微信公众平台表
        ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(zpglRcxxDto.getId()).build().selectById();
        if(!StringUtils.isEmpty(zpglRcxx) && !StringUtils.isEmpty(zpglRcxx.getMobile())){
            ZpglWxgzptEmpRcxx zpglWxgzptEmpRcxx = ZpglWxgzptEmpRcxx.builder().build().selectOne(
                    new QueryWrapper<ZpglWxgzptEmpRcxx>().select("id","zpgl_rcxx_id").lambda().eq(ZpglWxgzptEmpRcxx::getMobile,zpglRcxx.getMobile())
284718418@qq.com committed
361
                    .eq(ZpglWxgzptEmpRcxx::getDeleteFlag,0)
362 363
            );
            if(!StringUtils.isEmpty(zpglWxgzptEmpRcxx) && (StringUtils.isEmpty(zpglWxgzptEmpRcxx.getZpglRcxxId()) || zpglWxgzptEmpRcxx.getZpglRcxxId() <= 0)){
364 365
                zpglWxgzptEmpRcxx.setOrgCode(userBean.getOrgCode());
                zpglWxgzptEmpRcxx.setZpglRcxxId(zpglRcxx.getId());
284718418@qq.com committed
366
                zpglWxgzptEmpRcxx.setYgglMainEmpId(ygglMainEmpId);
367 368 369
                zpglWxgzptEmpRcxx.updateById();
            }
            if(StringUtils.isEmpty(zpglWxgzptEmpRcxx)){
370 371 372
                zpglWxgzptEmpRcxx = new ZpglWxgzptEmpRcxx();
                zpglWxgzptEmpRcxx.setOrgCode(userBean.getOrgCode());
                zpglWxgzptEmpRcxx.setZpglRcxxId(zpglRcxx.getId());
284718418@qq.com committed
373
                zpglWxgzptEmpRcxx.setYgglMainEmpId(ygglMainEmpId);
374 375 376 377 378 379 380
                zpglWxgzptEmpRcxx.setMobile(zpglRcxx.getMobile());
                zpglWxgzptEmpRcxx.insert();
            }
        }
        return true;
    }

381 382 383
    /**
     * 导入简历
     * 同步人才信息 教育资讯 基本信息 其他信息 项目信息 工作信息
284718418@qq.com committed
384
     *
385 386 387
     * @param resumeExtract
     * @param importCandidateDto
     */
284718418@qq.com committed
388
    private Result<Object> addZpglRcxx(UserBean userBean, ResumeExtract resumeExtract, ImportCandidateDto importCandidateDto) {
389 390 391 392 393
        ZpglRcxx zpglRcxx = ZpglRcxx.builder().build();
        zpglRcxx.setZpglZwxxId(importCandidateDto.getZpglZwxxId());
        zpglRcxx.setStatus(importCandidateDto.getStatus());
        zpglRcxx.setZpglZpqdId(importCandidateDto.getZpglZpqdId());
        zpglRcxx.setOrgCode(userBean.getOrgCode().toString());
394 395
        zpglRcxx.setFileName(importCandidateDto.getFileName());
        zpglRcxx.setFilePath(importCandidateDto.getFilePath());
396 397
        Integer highesteducation = null;
        // 添加人才信息
284718418@qq.com committed
398
        if (!StringUtils.isEmpty(resumeExtract.getBasic_infos())) {
399
            zpglRcxx.setName(resumeExtract.getBasic_infos().getName());
400
            String phone = resumeExtract.getBasic_infos().getPhone_numbers();
284718418@qq.com committed
401
            if (StringUtils.isEmpty(phone)) {
402 403 404
                return ResultUtil.error("导入简历失败,手机号码不存在~");
            }
            // 查询简历是否重复导入
284718418@qq.com committed
405 406
            ZpglRcxx zpglRcxxEntiyt = ZpglRcxx.builder().build().selectOne(new QueryWrapper<ZpglRcxx>().lambda().eq(ZpglRcxx::getMobile, phone).eq(ZpglRcxx::getDeleteFlag, 0));
            if (!StringUtils.isEmpty(zpglRcxxEntiyt)) {
407 408 409
                return ResultUtil.error("简历已入库,请勿重复导入");
            }
            zpglRcxx.setMobile(phone);
410 411 412
            zpglRcxx.setMail(resumeExtract.getBasic_infos().getEmail_address());
            zpglRcxx.setWeixin(resumeExtract.getBasic_infos().getWechat());
            zpglRcxx.setIdCard(resumeExtract.getBasic_infos().getId_number());
284718418@qq.com committed
413 414
            if (!StringUtils.isEmpty(resumeExtract.getBasic_infos().getGender())) {
                zpglRcxx.setSex(resumeExtract.getBasic_infos().getGender().indexOf("男") != -1 ? 0 : 1);
415 416
            }
            //出生日期,格式化为 年-月,如2000-01,若只有年,则只显示年,如2000
284718418@qq.com committed
417
            if (!StringUtils.isEmpty(resumeExtract.getBasic_infos().getBirth_date()) && resumeExtract.getBasic_infos().getBirth_date().length() > 0) {
418
                zpglRcxx.setDatebirth(this.getDate(resumeExtract.getBasic_infos().getBirth_date()));
419
            }
284718418@qq.com committed
420 421 422
            if (!StringUtils.isEmpty(resumeExtract.getBasic_infos().getNation())) {
                NationClass nationClass = NationClass.builder().build().selectOne(new QueryWrapper<NationClass>().lambda().like(NationClass::getName, resumeExtract.getBasic_infos().getNation()));
                if (!StringUtils.isEmpty(nationClass)) {
423 424 425 426 427
                    zpglRcxx.setNationClassId(nationClass.getId());
                }
            }
            zpglRcxx.setAddress(resumeExtract.getBasic_infos().getHome_location());
            zpglRcxx.setUniversitie(resumeExtract.getBasic_infos().getSchool());
284718418@qq.com committed
428
            if (!StringUtils.isEmpty(resumeExtract.getBasic_infos().getCur_duration())) {
429 430 431 432 433
                zpglRcxx.setWorkyears(Integer.parseInt(resumeExtract.getBasic_infos().getCur_duration()));
            }
            zpglRcxx.setCompany(resumeExtract.getBasic_infos().getCur_company());
            zpglRcxx.insert();
        }
284718418@qq.com committed
434
        if (!StringUtils.isEmpty(zpglRcxx.getId())) {
435
            // 添加教育经历
284718418@qq.com committed
436
            if (!StringUtils.isEmpty(resumeExtract.getEducation_infos())) {
437 438
                ZpglRcxxStudy zpglRcxxStudy = ZpglRcxxStudy.builder().zpglRcxxId(zpglRcxx.getId()).build();
                List<EducationInfo> list = resumeExtract.getEducation_infos();
284718418@qq.com committed
439 440
                for (EducationInfo entity : list) {
                    if (!StringUtils.isEmpty(entity.getStart_time()) && entity.getStart_time().length() > 0) {
441 442
                        zpglRcxxStudy.setStartTime(this.getDate(entity.getStart_time()));
                    }
284718418@qq.com committed
443
                    if (!StringUtils.isEmpty(entity.getEnd_time()) && entity.getEnd_time().length() > 0) {
444 445 446
                        zpglRcxxStudy.setEndTime(this.getDate(entity.getEnd_time()));
                    }
                    zpglRcxxStudy.setSubject(entity.getMajor());
284718418@qq.com committed
447
                    zpglRcxxStudy.setSchoolName(StringUtils.isEmpty(entity.getSchool()) ? entity.getCollege() : entity.getSchool());
448 449 450 451 452 453
                    zpglRcxxStudy.setEducation(this.getEducation(entity.getSchooling_record()));
                    highesteducation = zpglRcxxStudy.getEducation();
                    zpglRcxxStudy.insert();
                }
            }
            // 添加工作经验
284718418@qq.com committed
454
            if (!StringUtils.isEmpty(resumeExtract.getWork_infos())) {
455 456
                ZpglRcxxExperience zpglRcxxExperience = ZpglRcxxExperience.builder().zpglRcxxId(zpglRcxx.getId()).build();
                List<WorkInfo> list = resumeExtract.getWork_infos();
284718418@qq.com committed
457
                for (WorkInfo entity : list) {
458 459 460 461
                    zpglRcxxExperience.setCompany(entity.getCompany());
                    zpglRcxxExperience.setJobName(entity.getJob());
                    zpglRcxxExperience.setDepartment(entity.getDepartment());
                    zpglRcxxExperience.setWorkContent(entity.getDescribe());
284718418@qq.com committed
462
                    if (!StringUtils.isEmpty(entity.getEnd_time()) && entity.getEnd_time().length() > 0) {
463 464
                        zpglRcxxExperience.setEndTime(this.getDate(entity.getEnd_time()));
                    }
284718418@qq.com committed
465
                    if (!StringUtils.isEmpty(entity.getStart_time()) && entity.getStart_time().length() > 0) {
466 467 468 469 470 471
                        zpglRcxxExperience.setStartTime(this.getDate(entity.getStart_time()));
                    }
                    zpglRcxxExperience.insert();
                }
            }
            // 添加项目信息
284718418@qq.com committed
472
            if (!StringUtils.isEmpty(resumeExtract.getProject_infos())) {
473 474
                ZpglRcxxProject zpglRcxxProject = ZpglRcxxProject.builder().zpglRcxxId(zpglRcxx.getId()).build();
                List<ProjectInfo> list = resumeExtract.getProject_infos();
284718418@qq.com committed
475
                for (ProjectInfo entity : list) {
476 477 478 479 480 481
                    zpglRcxxProject.setProjectDescribe(entity.getDescribe());
                    zpglRcxxProject.setDuty(entity.getDuty());
                    zpglRcxxProject.setJob(entity.getJob());
                    zpglRcxxProject.setLocation(entity.getLocation());
                    zpglRcxxProject.setProjectName(entity.getProject_name());

284718418@qq.com committed
482
                    if (!StringUtils.isEmpty(entity.getStart_time()) && entity.getStart_time().length() > 0) {
483 484
                        zpglRcxxProject.setStartTime(this.getDate(entity.getStart_time()));
                    }
284718418@qq.com committed
485
                    if (!StringUtils.isEmpty(entity.getEnd_time()) && entity.getEnd_time().length() > 0) {
486 487 488 489 490
                        zpglRcxxProject.setEndTime(this.getDate(entity.getEnd_time()));
                    }
                    zpglRcxxProject.insert();
                }
            }
284718418@qq.com committed
491
            if (!StringUtils.isEmpty(highesteducation)) {
492 493 494 495 496 497 498 499
                ZpglRcxx.builder().id(zpglRcxx.getId()).highesteducation(highesteducation.toString()).build().updateById();
            }

        }
        return ResultUtil.success();
    }

    /**
500 501 502 503 504 505 506 507 508 509 510 511
     * 导入简历
     * 同步人才信息 教育资讯 基本信息 其他信息 项目信息 工作信息
     * @sdkdocs http://www.resumesdk.com/docs/rs-parser.html
     * @param json
     * @param importCandidateDto
     */
    private Result<Object> addZpglRcxx(UserBean userBean, JSONObject json, ImportCandidateDto importCandidateDto) {
        ReumeSdkResult reumeSdkResult = JSONObject.toJavaObject((JSONObject) json.get("result"), ReumeSdkResult.class);
        if(StringUtils.isEmpty(reumeSdkResult)){
            log.info("招聘-导入候选人简历:results is null");
            return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
        }
284718418@qq.com committed
512
        /** 基础信息开始 */
513 514 515 516 517 518 519 520 521 522 523 524 525 526
        ZpglRcxx zpglRcxx = ZpglRcxx.builder().build();
        zpglRcxx.setZpglZwxxId(importCandidateDto.getZpglZwxxId());
        zpglRcxx.setStatus(importCandidateDto.getStatus());
        zpglRcxx.setZpglZpqdId(importCandidateDto.getZpglZpqdId());
        zpglRcxx.setOrgCode(userBean.getOrgCode().toString());
        zpglRcxx.setFileName(importCandidateDto.getFileName());
        zpglRcxx.setFilePath(importCandidateDto.getFilePath());
        // 添加人才信息
        zpglRcxx.setName(reumeSdkResult.getName());
        String phone = reumeSdkResult.getPhone();
        if (StringUtils.isEmpty(phone)) {
            return ResultUtil.error("导入简历失败,手机号码不存在~");
        }
        // 查询简历是否重复导入
284718418@qq.com committed
527
        ZpglRcxx zpglRcxxEntiyt = ZpglRcxx.builder().build().selectOne(new QueryWrapper<ZpglRcxx>().lambda().eq(ZpglRcxx::getOrgCode, userBean.getOrgCode()).eq(ZpglRcxx::getMobile, phone).eq(ZpglRcxx::getDeleteFlag, 0));
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
        if (!StringUtils.isEmpty(zpglRcxxEntiyt)) {
            return ResultUtil.error("简历已入库,请勿重复导入");
        }
        zpglRcxx.setMobile(phone);
        zpglRcxx.setMail(reumeSdkResult.getEmail());
        zpglRcxx.setWeixin(reumeSdkResult.getWeixin());
        zpglRcxx.setIdCard(reumeSdkResult.getId_card());
        if (!StringUtils.isEmpty(reumeSdkResult.getGender())) {
            zpglRcxx.setSex(reumeSdkResult.getGender().indexOf("男") != -1 ? 0 : 1);
        }
        //出生日期,格式化为 年.月,如2000.01,若只有年,则只显示年,如2000
        if (!StringUtils.isEmpty(reumeSdkResult.getBirthday()) && reumeSdkResult.getBirthday().length() > 0) {
            zpglRcxx.setDatebirth(this.getDate(reumeSdkResult.getBirthday()));
        }
        if (!StringUtils.isEmpty(reumeSdkResult.getRace())) {
            NationClass nationClass = NationClass.builder().build().selectOne(new QueryWrapper<NationClass>().lambda().like(NationClass::getName, reumeSdkResult.getRace()));
            if (!StringUtils.isEmpty(nationClass)) {
                zpglRcxx.setNationClassId(nationClass.getId());
            }
        }
        // 身高
        if(!StringUtils.isEmpty(reumeSdkResult.getHeight())){
            String[] height = reumeSdkResult.getHeight().split("cm");
            if(height.length > 0){
                zpglRcxx.setHeight(Integer.parseInt(height[0]));
            }
        }
        // 体重
        if(!StringUtils.isEmpty(reumeSdkResult.getWeight())){
            String[] height = reumeSdkResult.getWeight().split("kg");
            if(height.length > 0){
                zpglRcxx.setWeight(Integer.parseInt(height[0]));
            }
        }
        zpglRcxx.setNativePlace(reumeSdkResult.getNationality());
        zpglRcxx.setAddress(reumeSdkResult.getLiving_address());
        zpglRcxx.setUniversitie(reumeSdkResult.getCollege());
284718418@qq.com committed
565
        zpglRcxx.setSubject(reumeSdkResult.getMajor());
566 567 568 569 570
        if(!StringUtils.isEmpty(reumeSdkResult.getDegree())){
            zpglRcxx.setHighesteducation(this.getEducation(reumeSdkResult.getDegree())+"");
        }
        if (!StringUtils.isEmpty(reumeSdkResult.getWork_year_norm())) {
            if(reumeSdkResult.getWork_year_norm().indexOf(".") != -1){
571
                zpglRcxx.setWorkyears(Integer.parseInt(reumeSdkResult.getWork_year_norm().substring(0,reumeSdkResult.getWork_year_norm().lastIndexOf(".")))+1);
572 573 574 575 576 577 578 579 580 581
            }else {
                zpglRcxx.setWorkyears(Integer.parseInt(reumeSdkResult.getWork_year_norm()));
            }
        }
        if(!StringUtils.isEmpty(reumeSdkResult.getExpect_salary_max())){
            zpglRcxx.setSalary(Integer.parseInt(reumeSdkResult.getExpect_salary_max()));
        }
        zpglRcxx.setCompany(reumeSdkResult.getWork_company());

        zpglRcxx.setZjzw(reumeSdkResult.getWork_position());
284718418@qq.com committed
582 583
        zpglRcxx.setContMyDesc(reumeSdkResult.getCont_my_desc());
        zpglRcxx.setHobby(reumeSdkResult.getCont_hobby());
584
        zpglRcxx.insert();
284718418@qq.com committed
585
        /** 基础信息结束 */
586
        if (!StringUtils.isEmpty(zpglRcxx.getId())) {
284718418@qq.com committed
587 588 589 590 591 592 593 594
            // 初始化流程记录
            ZpglMslcLog zpglMslcLog = new ZpglMslcLog();
            zpglMslcLog.setZpglRcxxId(zpglRcxx.getId());
            zpglMslcLog.setUserId(userBean.getEmpNum());
            zpglMslcLog.setUserName(userBean.getQyzxEmpLogin().getUsername());
            zpglMslcLog.setZpglRcxxStatus(JxglEnumInterface.MslcLogStatus.OTHER.getType());
            zpglMslcLog.setDetail(ZpglMessageTemplate.SYS_ADD);
            zpglMslcLogService.addZpglMslcLog(zpglMslcLog);
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
            // 添加教育经历
            if (!StringUtils.isEmpty(reumeSdkResult.getEducation_objs())) {
                ZpglRcxxStudy zpglRcxxStudy = ZpglRcxxStudy.builder().zpglRcxxId(zpglRcxx.getId()).build();
                List<Education_objs> list = reumeSdkResult.getEducation_objs();
                for (Education_objs entity : list) {
                    if (!StringUtils.isEmpty(entity.getStart_date()) && entity.getStart_date().length() > 0) {
                        zpglRcxxStudy.setStartTime(this.getDate(entity.getStart_date()));
                    }
                    if (!StringUtils.isEmpty(entity.getEnd_date()) && entity.getEnd_date().length() > 0) {
                        zpglRcxxStudy.setEndTime(this.getDate(entity.getEnd_date()));
                    }
                    zpglRcxxStudy.setSubject(entity.getEdu_major());
                    zpglRcxxStudy.setSchoolName(entity.getEdu_college());
                    zpglRcxxStudy.setEducation(this.getEducation(entity.getEdu_degree_norm()));
                    zpglRcxxStudy.insert();
                }
            }
            // 添加工作经验
            if (!StringUtils.isEmpty(reumeSdkResult.getJob_exp_objs())) {
                ZpglRcxxExperience zpglRcxxExperience = ZpglRcxxExperience.builder().zpglRcxxId(zpglRcxx.getId()).build();
                List<Job_exp_objs> list = reumeSdkResult.getJob_exp_objs();
                for (Job_exp_objs entity : list) {
                    zpglRcxxExperience.setCompany(entity.getJob_cpy());
                    zpglRcxxExperience.setJobName(entity.getJob_position());
                    zpglRcxxExperience.setDepartment(entity.getJob_dept());
                    zpglRcxxExperience.setWorkContent(entity.getJob_content());
                    zpglRcxxExperience.setReason(entity.getJob_why_leave());
                    if (!StringUtils.isEmpty(entity.getEnd_date()) && entity.getEnd_date().length() > 0) {
                        zpglRcxxExperience.setEndTime(this.getDate(entity.getEnd_date()));
                    }
                    if (!StringUtils.isEmpty(entity.getStart_date()) && entity.getStart_date().length() > 0) {
                        zpglRcxxExperience.setStartTime(this.getDate(entity.getStart_date()));
                    }

                    zpglRcxxExperience.insert();
                }
            }
            // 添加项目信息
            if (!StringUtils.isEmpty(reumeSdkResult.getProj_exp_objs())) {
                ZpglRcxxProject zpglRcxxProject = ZpglRcxxProject.builder().zpglRcxxId(zpglRcxx.getId()).build();
                List<Proj_exp_objs> list = reumeSdkResult.getProj_exp_objs();
                for (Proj_exp_objs entity : list) {
                    zpglRcxxProject.setProjectDescribe(entity.getProj_content());
                    zpglRcxxProject.setDuty(entity.getProj_resp());
                    zpglRcxxProject.setJob(entity.getProj_position());
                    zpglRcxxProject.setProjectName(entity.getProj_name());
                    if (!StringUtils.isEmpty(entity.getStart_date()) && entity.getStart_date().length() > 0) {
                        zpglRcxxProject.setStartTime(this.getDate(entity.getStart_date()));
                    }
                    if (!StringUtils.isEmpty(entity.getEnd_date()) && entity.getEnd_date().length() > 0) {
                        zpglRcxxProject.setEndTime(this.getDate(entity.getEnd_date()));
                    }
                    zpglRcxxProject.insert();
                }
            }
            // 添加培训经历
            if (!StringUtils.isEmpty(reumeSdkResult.getTraining_objs())) {
                ZpglRcxxTrain zpglRcxxTrain = ZpglRcxxTrain.builder().zpglRcxxId(zpglRcxx.getId()).build();
                List<Training_objs> list = reumeSdkResult.getTraining_objs();
                for (Training_objs entity : list) {
                    zpglRcxxTrain.setTrainCompany(entity.getTrain_org());
                    zpglRcxxTrain.setTrainContent(entity.getTrain_cont());
                    if (!StringUtils.isEmpty(entity.getStart_date()) && entity.getStart_date().length() > 0) {
                        zpglRcxxTrain.setStartTime(this.getDate(entity.getStart_date()));
                    }
                    if (!StringUtils.isEmpty(entity.getEnd_date()) && entity.getEnd_date().length() > 0) {
                        zpglRcxxTrain.setEndTime(this.getDate(entity.getEnd_date()));
                    }
                    zpglRcxxTrain.insert();
                }
            }
        }
        return ResultUtil.success();
    }

    /**
671
     * 根据string时间获取date(2019-10或2019)
284718418@qq.com committed
672
     *
673 674 675
     * @param date
     * @return
     */
284718418@qq.com committed
676
    private Date getDate(String date) {
677
        String datebirth = "";
284718418@qq.com committed
678
        date = date.replace(".","-");
679
        String[] num = date.split("-");
284718418@qq.com committed
680 681 682 683
        if (num.length == 1) {
            datebirth = num[0] + "-1-1";
        } else if (num.length == 2) {
            datebirth = num[0] + "-" + num[1] + "-1";
684
        }
284718418@qq.com committed
685
        return datebirth.length() > 0 ? ClockInTool.strToDateLong(datebirth) : null;
686 687 688 689
    }

    /**
     * 获取学历类型
284718418@qq.com committed
690
     *
691 692 693
     * @param str
     * @return
     */
284718418@qq.com committed
694
    private Integer getEducation(String str) {
695
        Integer education = 0;
284718418@qq.com committed
696
        if (StringUtils.isEmpty(str)) {
697 698 699
            return education;
        }
        // 博士研究生/硕士研究生/本科/专科/高中/中专/初中
700
        // 小学、初中、高中、中专、大专、本科、硕士研究生、博士研究生、博士后、mba
284718418@qq.com committed
701
        if (str.indexOf("初中") != -1) {
702
            education = 2;
703 704 705
        } else if (str.indexOf("小学") != -1) {
            education = 1;
        }else if (str.indexOf("中专") != -1) {
706
            education = 4;
284718418@qq.com committed
707
        } else if (str.indexOf("高中") != -1) {
708
            education = 3;
709
        } else if (str.indexOf("专科") != -1 || str.indexOf("大专") != -1) {
710
            education = 5;
284718418@qq.com committed
711
        } else if (str.indexOf("本科") != -1) {
712
            education = 6;
713
        } else if (str.indexOf("硕士研究生") != -1 || str.indexOf("硕士") != -1) {
714
            education = 7;
715
        } else if (str.indexOf("博士研究生") != -1 || str.indexOf("博士") != -1) {
716 717 718
            education = 8;
        }
        return education;
719
    }
720 721 722

    /**
     * 添加offer记录
284718418@qq.com committed
723
     *
724 725 726 727
     * @param userBean
     * @param zpglRcxxDto
     * @return
     */
284718418@qq.com committed
728
    private ZpglRcxxOffer insertZpglRcxxOffer(UserBean userBean, ZpglRcxxDto zpglRcxxDto) {
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746
        Integer orgCode = userBean.getOrgCode();
        ZpglRcxxOffer zpglRcxxOffer = ZpglRcxxOffer.builder().build();
        zpglRcxxOffer.setOrgCode(orgCode);
        zpglRcxxOffer.setRcxxName(zpglRcxxDto.getName());
        zpglRcxxOffer.setZpglRcxxId(zpglRcxxDto.getId());
        zpglRcxxOffer.setRzTime(zpglRcxxDto.getYjrzTime());
        // 所在部门
        ZzglBmgwM zzglBmgwM = ZzglBmgwM.builder().build().selectOne(
                new QueryWrapper<ZzglBmgwM>().lambda().eq(ZzglBmgwM::getOrgCode, orgCode).eq(ZzglBmgwM::getId, zpglRcxxDto.getBmgwId()));
        Integer bmid = null;
        if (!StringUtils.isEmpty(zzglBmgwM)) {
            zpglRcxxOffer.setGangwei(zzglBmgwM.getName());
            bmid = zzglBmgwM.getUpId();
        }
        // 所在职位
        ZzglBmgwM z = ZzglBmgwM.builder().build().selectOne(
                new QueryWrapper<ZzglBmgwM>().lambda().eq(ZzglBmgwM::getOrgCode, orgCode).eq(ZzglBmgwM::getId, bmid));
        if (!StringUtils.isEmpty(z)) {
284718418@qq.com committed
747
            zpglRcxxOffer.setBumen(z.getName());
748 749 750 751
        }
        // 所在公司
        ZzglBmgwM company = ZzglBmgwM.builder().build().selectOne(
                new QueryWrapper<ZzglBmgwM>().select("name").lambda().eq(ZzglBmgwM::getOrgCode, orgCode).eq(ZzglBmgwM::getUpId, 0));
284718418@qq.com committed
752 753
        if (!StringUtils.isEmpty(company)) {
            zpglRcxxOffer.setTitle(company.getName() + "录用函");
754 755
            zpglRcxxOffer.setCompanyName(company.getName());
        }
284718418@qq.com committed
756
        YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().select("phone", "name", "work_email").lambda()
757
                .eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, zpglRcxxDto.getLinkId()));
284718418@qq.com committed
758
        if (!StringUtils.isEmpty(ygglMainEmp)) {
759 760 761 762 763 764 765
            zpglRcxxOffer.setLinkName(ygglMainEmp.getName());
            zpglRcxxOffer.setLinkPhone(ygglMainEmp.getPhone());
            zpglRcxxOffer.setLinkEmail(ygglMainEmp.getWorkEmail());
        }
        zpglRcxxOffer.insert();
        return zpglRcxxOffer;
    }
766
}