ZpglController.java 37.4 KB
Newer Older
1 2
package cn.timer.api.controller.zpgl;

3 4 5 6 7
import cn.hutool.core.util.StrUtil;
import cn.timer.api.bean.kqgl.UserEquiRelation;
import cn.timer.api.bean.kqmk.*;
import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
import cn.timer.api.bean.qyzx.QyzxEmpLogin;
翁国栋 committed
8
import cn.timer.api.bean.qyzx.businessService.QyzxOrderRecord;
284718418@qq.com committed
9
import cn.timer.api.bean.spmk.SpmkCustomApproval;
284718418@qq.com committed
10
import cn.timer.api.bean.wechat.MessageTemplate;
11
import cn.timer.api.bean.yggl.YgglMainEmp;
12
import cn.timer.api.bean.zpgl.*;
13 14 15
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enuminterface.JxglEnumInterface;
16 17
import cn.timer.api.config.enums.CommonEnum;
import cn.timer.api.config.enums.SysRoleType;
18
import cn.timer.api.config.exception.CustomException;
19 20 21
import cn.timer.api.controller.kqgl.ClockInTool;
import cn.timer.api.controller.kqgl.atttimer.RealTimeUpdate;
import cn.timer.api.controller.zpgl.sevice.ZpglService;
284718418@qq.com committed
22
import cn.timer.api.controller.zpgl.sevice.ZpglWxgzptService;
23 24 25 26
import cn.timer.api.dao.kqgl.UserEquiRelationMapper;
import cn.timer.api.dao.kqmk.KqglAssoKqzdkfsMapper;
import cn.timer.api.dao.qyzx.QyzxEmpLoginMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper;
27
import cn.timer.api.dao.zpgl.ZpglRcxxMapper;
284718418@qq.com committed
28
import cn.timer.api.dto.template.InterviewNotice;
29
import cn.timer.api.dto.zpgl.ImportCandidateDto;
30
import cn.timer.api.dto.zpgl.ZpglRcxxDto;
31
import cn.timer.api.dto.zpgl.ZpglRcxxEntryDto;
32
import cn.timer.api.utils.Md5;
33 34
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
284718418@qq.com committed
35
import cn.timer.api.utils.ZpglMessageTemplate;
36
import cn.timer.api.utils.query.BaseQuery;
37
import cn.timer.api.config.enuminterface.YgEnumInterface.jobStatus;
38
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
翁国栋 committed
39
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
40
import com.baomidou.mybatisplus.core.metadata.IPage;
41
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
42 43
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
44
import com.github.yulichang.query.MPJQueryWrapper;
45 46
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
47
import io.swagger.annotations.ApiParam;
48
import lombok.extern.slf4j.Slf4j;
284718418@qq.com committed
49
import org.springframework.beans.BeanUtils;
50
import org.springframework.beans.factory.annotation.Autowired;
51 52 53 54 55 56 57
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
58
import org.springframework.util.StringUtils;
59
import org.springframework.validation.annotation.Validated;
60
import org.springframework.web.bind.annotation.*;
61
import org.springframework.web.client.RestTemplate;
62
import org.springframework.web.multipart.MultipartFile;
63

64
import javax.servlet.http.HttpServletRequest;
65
import javax.transaction.Transactional;
66
import java.text.ParseException;
67
import java.text.SimpleDateFormat;
68
import java.util.Date;
69 70 71
import java.util.HashMap;
import java.util.List;
import java.util.Map;
72

73 74 75 76 77 78 79
/**
 * 招聘管理
 *
 * @author wuqingjun
 * @email 284718418@qq.com
 * @date 2022-03-08 15:14:40
 */
80 81 82
@Api(tags = "招聘管理")
@Transactional(rollbackOn = Exception.class)
@RestController
83
@RequestMapping(value = "/zpgl", produces = {"application/json"})
84
@Slf4j
85 86
public class ZpglController {

87 88 89 90 91
    @Value(value = "${config-8timer.init-password}")
    private String pwd;
    // 回调地址
    @Value("${config-8timer.machine8timerUrl}")
    public String mac_command;
92
    @Autowired
93
    private KqglAssoKqzdkfsMapper kqglassokqzdkfsmapper;
94
    @Autowired
95 96 97 98 99 100 101 102 103
    private QyzxEmpLoginMapper qyzxEmpLoginMapper;
    @Autowired
    private RealTimeUpdate realtimeupdate;
    @Autowired
    private UserEquiRelationMapper userequirelationmapper;
    @Autowired
    private YgglMainEmpMapper ygglMainEmpMapper;
    @Autowired
    private ZpglService zpglService;
104 105
    @Autowired
    private ZpglRcxxMapper zpglRcxxMapper;
284718418@qq.com committed
106 107 108 109 110 111 112 113 114 115 116 117
    @Autowired
    private ZpglWxgzptService zpglWxgzptService;
    /**
     * 0应聘登记
     */
    public static final int APPLY_STATUS = 0;
    /**
     * 1测评
     */
    public static final int CP_STATUS = 1;
    @Value("${h5.url}")
    private String h5Url;
118

119 120 121 122 123 124 125 126 127
    /**
     * 招聘-招聘中
     *
     * @param
     * @return
     */
    @GetMapping(value = "/recruit")
    @ApiOperation(value = "1.招聘列表", httpMethod = "GET", notes = "招聘列表")
    @ApiOperationSupport(order = 1)
128
    public Result<Object> recruit(@CurrentUser UserBean userBean, BaseQuery baseQuery,
129 130 131
                                  @ApiParam("搜索关键字") @RequestParam(required = false) String query,
                                  @ApiParam("职位ID") @RequestParam(required = false) Integer zpglZwxxId,
                                  @ApiParam("状态") @RequestParam(required = false) Integer status) {
132 133 134
        try {
            Page<ZpglRcxx> page = new Page<ZpglRcxx>(baseQuery.getPageNum(), baseQuery.getPageSize());
            QueryWrapper<ZpglRcxx> queryWrapper = new QueryWrapper<>();
284718418@qq.com committed
135
            queryWrapper.lambda().eq(ZpglRcxx::getOrgCode, userBean.getOrgCode()).eq(ZpglRcxx::getDeleteFlag, 0);
136 137 138 139 140 141
            if (!StringUtils.isEmpty(zpglZwxxId) && zpglZwxxId > 0) {
                queryWrapper.lambda().eq(ZpglRcxx::getZpglZwxxId, zpglZwxxId);
            }
            if (!StringUtils.isEmpty(query)) {
                queryWrapper.lambda().and(qw -> qw.like(ZpglRcxx::getName, query).or().eq(ZpglRcxx::getMobile, query).or().eq(ZpglRcxx::getMail, query));
            }
142
            queryWrapper.lambda().eq(ZpglRcxx::getStatus, status).orderByDesc(ZpglRcxx::getUpdateTime);
143
            IPage<ZpglRcxx> zpglRcxxPage = ZpglRcxx.builder().build().selectPage(page, queryWrapper);
144
            List<ZpglRcxx> zpglRcxxs = page.getRecords();
145 146 147 148
            zpglRcxxPage.getCurrent();
            zpglRcxxPage.getPages();
            zpglRcxxPage.getTotal();
            zpglRcxxPage.getSize();
149
            Map<String, Object> map = new HashMap<>(9);
150
            map.put("zpglRcxxs", zpglRcxxs);
284718418@qq.com committed
151 152 153 154 155 156 157 158
            map.put("FILTERING", this.getNum(queryWrapper, JxglEnumInterface.ResumeStatus.FILTERING.getType(), userBean.getOrgCode()));
            map.put("FILTER_PASS", this.getNum(queryWrapper, JxglEnumInterface.ResumeStatus.FILTER_PASS.getType(), userBean.getOrgCode()));
            map.put("INTERVIEW", this.getNum(queryWrapper, JxglEnumInterface.ResumeStatus.INTERVIEW.getType(), userBean.getOrgCode()));
            map.put("INTERVIEWED", this.getNum(queryWrapper, JxglEnumInterface.ResumeStatus.INTERVIEWED.getType(), userBean.getOrgCode()));
            map.put("INTERVIEW_PASS", this.getNum(queryWrapper, JxglEnumInterface.ResumeStatus.INTERVIEW_PASS.getType(), userBean.getOrgCode()));
            map.put("EMPLOY", this.getNum(queryWrapper, JxglEnumInterface.ResumeStatus.EMPLOY.getType(), userBean.getOrgCode()));
            map.put("OFFER", this.getNum(queryWrapper, JxglEnumInterface.ResumeStatus.OFFER.getType(), userBean.getOrgCode()));
            map.put("ENTRYING", this.getNum(queryWrapper, JxglEnumInterface.ResumeStatus.ENTRYING.getType(), userBean.getOrgCode()));
159
            return ResultUtil.data(zpglRcxxPage, map, "搜索成功");
160 161 162 163

        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-招聘列表失败");
164
        }
165

166
    }
167

168
    /**
169
     * 招聘-招聘中-职位信息
170 171 172 173
     *
     * @param
     * @return
     */
174
    @GetMapping(value = "/zwxx/{deleteFlag}")
175
    @ApiOperation(value = "2.职位信息", httpMethod = "GET", notes = "职位信息deleteFlag:0")
176
    @ApiOperationSupport(order = 2)
284718418@qq.com committed
177
    public Result<Object> zwxx(@CurrentUser UserBean userBean, @PathVariable Integer deleteFlag) {
178 179
        try {
            QueryWrapper<ZpglZwxx> queryWrapper = new QueryWrapper<>();
180
            queryWrapper.lambda().eq(ZpglZwxx::getOrgCode, userBean.getOrgCode());
284718418@qq.com committed
181
            if (deleteFlag.intValue() == 1) {
284718418@qq.com committed
182
                queryWrapper.lambda().eq(ZpglZwxx::getDeleteFlag, 0).gt(ZpglZwxx::getEndTime,new Date());
183
            }
184 185 186 187 188 189
            List<ZpglZwxx> zpglZwxxs = ZpglZwxx.builder().build().selectList(queryWrapper);
            return ResultUtil.data(zpglZwxxs, "查询成功");
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-职位信息失败");
        }
190
    }
191

192
    /**
193
     * 招聘-变更人才信息状态
194 195 196 197 198
     *
     * @param
     * @return
     */
    @PostMapping(value = "/operation")
199
    @ApiOperation(value = "3.招聘-变更人才信息状态", httpMethod = "POST", notes = "招聘-变更人才信息状态")
200
    @ApiOperationSupport(order = 3)
201
    public Result<Object> operation(@CurrentUser UserBean userBean, @RequestBody ZpglRcxxDto zpglRcxxDto) {
202
        try {
284718418@qq.com committed
203
            return zpglService.updateZpglRcxx(userBean, zpglRcxxDto) ? ResultUtil.success() : ResultUtil.error();
204 205 206 207 208 209
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-变更状态失败");
        }
    }

翁国栋 committed
210

211 212 213 214 215 216 217 218 219 220
    /**
     * 添加员工档案
     *
     * @param userBean
     * @param addygdaDto
     * @return
     */
    @PostMapping(value = "/addygda")
    @ApiOperation(value = "4.招聘-确认入职添加员工档案", httpMethod = "POST", notes = "接口发布说明")
    @ApiOperationSupport(order = 4)
221
    public Result<Object> addygda(@CurrentUser UserBean userBean, @Validated @RequestBody ZpglRcxxEntryDto addygdaDto) {
222
        try {
223
            ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(addygdaDto.getId()).build().selectById();
284718418@qq.com committed
224
            if (StringUtils.isEmpty(zpglRcxx)) {
225 226 227
                return ResultUtil.error("确认入职添加员工档案失败");
            }

228
            Integer orgCode = userBean.getOrgCode();
229 230
            //自定义工号
            String customNum = addygdaDto.getCustomNum();
231
            String name = addygdaDto.getName();
232 233 234 235
            String phone = zpglRcxx.getMobile();
            String zjNum = zpglRcxx.getIdCard();
            //考勤组id
            Integer attgroupid = addygdaDto.getAttgroupid();
236 237 238 239 240 241

            Integer jobType = addygdaDto.getJobType();
            Date rzTime = addygdaDto.getRzTime() == null ? new Date() : addygdaDto.getRzTime();
            Integer syq = addygdaDto.getSyq();
            Integer sex = addygdaDto.getSex();
            Integer bmgwId = addygdaDto.getBmgwId();
242 243 244
            ZpglRcxxDto zpglRcxxDto = new ZpglRcxxDto();
            zpglRcxxDto.setId(zpglRcxx.getId());
            zpglRcxxDto.setStatus(addygdaDto.getStatus());
245
            zpglRcxxDto.setZpglZwxxId(zpglRcxx.getZpglZwxxId());
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260

            QyzxEmpLogin login = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper)
                    .eq(!StrUtil.hasBlank(phone), QyzxEmpLogin::getPhone, phone).one();
            if (login == null) {
                // 初始化密码 pwd
                login = QyzxEmpLogin.builder().phone(phone).pw(Md5.md5(pwd))
                        .sts(CommonEnum.U_STS_ON.getType()).orgId(userBean.getOrgCode()).username(name).build();
                if (!login.insert()) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return ResultUtil.error("添加员工登录表失败,请检查输入信息");
                }
            }

            YgglMainEmp ygglMainEmp = ygglMainEmpMapper.selectOne(new QueryWrapper<YgglMainEmp>().lambda()
                    .eq(YgglMainEmp::getPhone, phone).eq(YgglMainEmp::getOrgCode, orgCode));
284718418@qq.com committed
261
            if (!StringUtils.isEmpty(ygglMainEmp)) {
262 263 264 265
                return ResultUtil.error("该手机号已被使用,请输入正确手机号");
            }
            QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(orgCode).userType(SysRoleType.U_TYPE_EMP.getType())
                    .status(CommonEnum.U_STS_ON.getType()).build().insert();
266
            ygglMainEmp = YgglMainEmp.builder().name(name).phone(phone).zjType(addygdaDto.getZjType()).zjNum(zjNum).jobType(jobType)
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
                    .jobStatus(jobStatus.SHIYONG.getType()).rzTime(rzTime).syq(syq).sex(sex)
                    .empNum(login.getId()).orgCode(orgCode).bmgwId(bmgwId).customNum(customNum).build();

            if (addygdaDto.getAttgroupid() != null) {
                KqglAssoYhkqz.builder().kqzid(attgroupid).userid(login.getId()).qyid(userBean.getOrgCode()).build().insert();

                List<KqglAssoKqzdkfs> kqjs = kqglassokqzdkfsmapper.selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, addygdaDto.getAttgroupid()).eq(KqglAssoKqzdkfs::getType, 1));

                for (KqglAssoKqzdkfs abp : kqjs) {
                    KqglAssoKqj kqj = KqglAssoKqj.builder().id(abp.getDkfsid()).build().selectById();
                    KqglAssoYhsb kqjry = KqglAssoYhsb.builder().build().selectOne(new QueryWrapper<KqglAssoYhsb>().lambda().eq(KqglAssoYhsb::getUserId, login.getId()).eq(KqglAssoYhsb::getKqjid, kqj.getId()));
                    if (kqjry == null) {
                        String url = mac_command + "/addUserName";
                        HttpHeaders headers = new HttpHeaders();
                        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
                        params.add("devId", kqj.getCode());
                        params.add("userId", login.getId());
                        params.add("userName", ygglMainEmp.getName());
                        RestTemplate restTemplate = new RestTemplate();
                        HttpEntity httpEntity = new HttpEntity(params, headers);
                        ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);

                        KqglAssoYhsb.builder().build().delete(new QueryWrapper<KqglAssoYhsb>().lambda().eq(KqglAssoYhsb::getUserId, login.getId()).eq(KqglAssoYhsb::getKqjid, kqj.getId()));

                        KqglAssoYhsb uskqj = KqglAssoYhsb.builder().userId(login.getId()).kqjid(kqj.getId()).type(1).build();

                        UserEquiRelation isgly = userequirelationmapper.selectByuserId(login.getId());
                        if (isgly != null) {
                            uskqj.setIsGly(isgly.getIsGly());
                        } else {
                            uskqj.setIsGly(0);
298
                        }
284718418@qq.com committed
299
                        if (!uskqj.insert()) {
300
                            return ResultUtil.error("操作失败--新增用户与设备关系");
301 302
                        }
                    }
303 304 305 306 307 308 309 310 311 312 313 314 315 316
                }

            }

            if (syq == 0) {
                ygglMainEmp.setZzTime(rzTime);
            } else {

                String sdf = new SimpleDateFormat("yyyy-MM-dd").format(rzTime);

                String zztime = ClockInTool.requires_extra_times(sdf, syq, 4, 1);

                ygglMainEmp.setZzTime(ClockInTool.strToDateLong(zztime));
            }
284718418@qq.com committed
317 318
            // 人才信息同步至员工档案
            this.copyToYgglMainEmp(zpglRcxx,ygglMainEmp);
319 320 321 322 323 324 325 326 327 328 329 330

            ygglMainEmp.insert();

            //假期规则初始化
            String current_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
            List<KqglAssoLeaveRules> rul = KqglAssoLeaveRules.builder().build().selectList(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, orgCode));
            for (KqglAssoLeaveRules r : rul) {
                if (r.getLeaveBalance() == 0) {
                    KqglAssoLeaveEmployeeBalance.builder().leaveRulesId(r.getId()).userid(ygglMainEmp.getEmpNum()).balanceDays(-1).modifyUserid(userBean.getEmpNum()).modifyTimer(current_time).orgCode(userBean.getOrgCode()).build().insert();
                } else {
                    KqglAssoLeaveEmployeeBalance.builder().leaveRulesId(r.getId()).userid(ygglMainEmp.getEmpNum()).balanceDays(0.0).modifyUserid(userBean.getEmpNum()).modifyTimer(current_time).orgCode(userBean.getOrgCode()).build().insert();
                }
331
            }
332 333 334 335 336 337
            /**
             * 职位信息已入职人数+1
             * 招聘-变更人才信息状态
             * 添加面试流程记录
             * 维护微信公众平台表
             */
284718418@qq.com committed
338
            zpglService.updateZpglOther(userBean, zpglRcxxDto, ygglMainEmp.getId());
339 340 341 342 343 344
            try {
                realtimeupdate.AttendanceTask(userBean.getOrgCode(), ygglMainEmp.getEmpNum(), 2, null);
            } catch (ParseException e) {
                e.printStackTrace();
            }

345
            return ResultUtil.success("确认入职成功!");
346

347 348
        } catch (Exception e) {
            e.printStackTrace();
349
            throw new CustomException("招聘-确认入职失败");
350
        }
351

352
    }
353

354
    /**
355
     * 招聘-已淘汰
356 357 358 359 360
     *
     * @param
     * @return
     */
    @GetMapping(value = "/recruit/fail")
361
    @ApiOperation(value = "5.招聘-已淘汰列表", httpMethod = "GET", notes = "招聘-已淘汰列表")
362 363
    @ApiOperationSupport(order = 5)
    public Result<Object> recruitFail(@CurrentUser UserBean userBean, BaseQuery baseQuery,
284718418@qq.com committed
364 365 366 367
                                      @ApiParam("搜索关键字") @RequestParam(required = false) String query,
                                      @ApiParam("职位ID") @RequestParam(required = false) Integer zpglZwxxId,
                                      @ApiParam("状态") @RequestParam(required = false) Integer status,
                                      @ApiParam("排序") @RequestParam(required = false) Integer orderBy) {
368 369 370 371
        try {
            Page<ZpglRcxx> page = new Page<ZpglRcxx>(baseQuery.getPageNum(), baseQuery.getPageSize());
            MPJQueryWrapper<ZpglRcxx> queryWrapper = new MPJQueryWrapper<>();
            queryWrapper.selectAll(ZpglRcxx.class).select("zf.fail_cause")
284718418@qq.com committed
372 373
                    .leftJoin("zpgl_fail zf on t.zpgl_fail_id = zf.id");
            queryWrapper.eq("t.org_code", userBean.getOrgCode()).eq("t.delete_flag", 0).eq("zf.org_code", userBean.getOrgCode());
374 375 376 377 378 379
            if (!StringUtils.isEmpty(zpglZwxxId) && zpglZwxxId > 0) {
                queryWrapper.eq("t.zpgl_zwxx_id", zpglZwxxId);
            }
            if (!StringUtils.isEmpty(query)) {
                queryWrapper.and(qw -> qw.like("t.name", query).or().eq("t.mobile", query).or().eq("t.mail", query));
            }
284718418@qq.com committed
380
            if (!StringUtils.isEmpty(status)) {
381 382
                queryWrapper.eq("t.status", 9);
                queryWrapper.eq("zf.zpgl_rcxx_status", status);
284718418@qq.com committed
383
            } else {
384 385
                queryWrapper.eq("t.ifrck", 1);
            }
284718418@qq.com committed
386
            if (!StringUtils.isEmpty(orderBy)) {
387
                // 排序 1最近跟进时间 2最近入库时间 3最早入库时间
284718418@qq.com committed
388
                if (orderBy.intValue() == 1) {
389
                    queryWrapper.orderByDesc("t.update_time");
284718418@qq.com committed
390
                } else if (orderBy.intValue() == 2) {
391
                    queryWrapper.orderByDesc("t.ifrck_time");
284718418@qq.com committed
392
                } else if (orderBy.intValue() == 3) {
393 394 395
                    queryWrapper.orderByAsc("t.ifrck_time");
                }
            }
396

284718418@qq.com committed
397
            IPage<ZpglRcxx> zpglRcxxPage = zpglRcxxMapper.selectJoinPage(page, ZpglRcxx.class, queryWrapper);
398 399 400 401 402 403 404 405 406
            List<ZpglRcxx> zpglRcxxs = page.getRecords();
            zpglRcxxPage.getCurrent();
            zpglRcxxPage.getPages();
            zpglRcxxPage.getTotal();
            zpglRcxxPage.getSize();
            return ResultUtil.data(zpglRcxxPage, zpglRcxxs, "搜索成功");

        } catch (Exception e) {
            e.printStackTrace();
407
            throw new CustomException("招聘-已淘汰,人才库列表失败");
408 409 410
        }

    }
284718418@qq.com committed
411

412
    /**
413
     * 招聘-移入/出人才库
414 415 416 417
     *
     * @param
     * @return
     */
418 419
    @PostMapping(value = "/remove/{id}/{ifrck}")
    @ApiOperation(value = "6.招聘-移入/出人才库", httpMethod = "GET", notes = "招聘-移入/出人才库")
420
    @ApiOperationSupport(order = 6)
421
    public Result<Object> remove(@CurrentUser UserBean userBean, @PathVariable Integer id, @PathVariable Integer ifrck) {
422
        try {
423
            return ZpglRcxx.builder().id(id).ifrck(ifrck).ifrckTime(new Date()).userId(userBean.getEmpNum()).build().updateById() ? ResultUtil.success("操作成功") : ResultUtil.error("操作失败");
424 425 426 427 428 429
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-删除人才信息失败");
        }

    }
430

284718418@qq.com committed
431
    /**
432
     * 招聘-导入候选人简历
284718418@qq.com committed
433
     *
434 435 436 437 438 439 440
     * @param userBean
     * @param file
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/resume_import_candidate")
441 442
    @ApiOperation(value = "7.招聘-导入候选人简历", httpMethod = "POST", notes = "招聘-导入候选人简历")
    @ApiOperationSupport(order = 7)
443
    public Result<Object> resumeImportCandidate(@CurrentUser UserBean userBean, @RequestParam(required = true) MultipartFile file,
444 445
                                                @ApiParam("招聘渠道ID") @RequestParam(required = false) Integer zpglZpqdId,
                                                @ApiParam("职位信息Id") @RequestParam(required = true) Integer zpglZwxxId,
284718418@qq.com committed
446
                                                @ApiParam("状态") @RequestParam(required = true) Integer status, HttpServletRequest request) {
447
        try {
448 449 450 451
            ImportCandidateDto importCandidateDto = new ImportCandidateDto();
            importCandidateDto.setStatus(status);
            importCandidateDto.setZpglZpqdId(zpglZpqdId);
            importCandidateDto.setZpglZwxxId(zpglZwxxId);
452
            // 获取文件 文档类型,目前支持pdf,doc,docx,wps,txt,jpg,jpeg,png,bmp,tif格式
284718418@qq.com committed
453 454
            String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
            if (StringUtils.isEmpty(suffix)) {
455 456
                return ResultUtil.error("导入简历失败,请检查是否为简历文件~");
            }
284718418@qq.com committed
457
            if ("pdf,doc,docx,wps,txt,jpg,jpeg,png,bmp,tif".indexOf(suffix) == -1) {
458 459
                return ResultUtil.error("导入简历失败,目前支持pdf,doc,docx,wps,txt,jpg,jpeg,png,bmp,tif格式~");
            }
460
            importCandidateDto.setSuffix(suffix);
461 462
//             return zpglService.addResumeImportCandidate(userBean, file, importCandidateDto);
            return zpglService.addCandidateByResumeSDK(userBean, file, importCandidateDto);
463 464 465
        } catch (CustomException e) {
            e.printStackTrace();
            throw e;
466 467 468 469 470 471
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-导入候选人简历失败");
        }

    }
284718418@qq.com committed
472

473 474 475 476 477 478 479 480 481 482 483
    /**
     * 招聘-更改招聘职位
     *
     * @param
     * @return
     */
    @PostMapping(value = "/edit/zwxx")
    @ApiOperation(value = "8.招聘-更改招聘职位", httpMethod = "POST", notes = "招聘-更改招聘职位")
    @ApiOperationSupport(order = 8)
    public Result<Object> deitZwxx(@CurrentUser UserBean userBean, @RequestBody ZpglRcxxDto zpglRcxxDto) {
        try {
284718418@qq.com committed
484
            return zpglService.updateZpglRcxxZwxx(userBean, zpglRcxxDto) ? ResultUtil.success("更改招聘职位成功") : ResultUtil.error("更改招聘职位失败");
485 486 487 488 489
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-更改招聘职位失败");
        }
    }
490 491

    /**
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
     * 招聘-标准简历信息
     *
     * @param
     * @return
     */
    @GetMapping(value = "/standard/recruit")
    @ApiOperation(value = "9.招聘-标准简历信息", httpMethod = "GET", notes = "招聘-标准简历信息")
    @ApiOperationSupport(order = 9)
    public Result<Object> standardRecruit(@CurrentUser UserBean userBean,
                                          @ApiParam("人才信息ID") @RequestParam(required = false) Integer zpglRcxxId) {
        try {
            ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(zpglRcxxId).build().selectById();
            // 工作经验
            List<ZpglRcxxExperience> zpglRcxxExperiences = ZpglRcxxExperience.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxExperience>().lambda().eq(ZpglRcxxExperience::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
507
                            .eq(ZpglRcxxExperience::getIsDelete, 0).orderByDesc(ZpglRcxxExperience::getEndTime)
508 509 510 511
            );
            // 教育经历
            List<ZpglRcxxStudy> zpglRcxxStudys = ZpglRcxxStudy.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxStudy>().lambda().eq(ZpglRcxxStudy::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
512
                            .eq(ZpglRcxxStudy::getIsDelete, 0).orderByDesc(ZpglRcxxStudy::getEndTime)
513 514 515 516
            );
            // 项目经历
            List<ZpglRcxxProject> zpglRcxxProjects = ZpglRcxxProject.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxProject>().lambda().eq(ZpglRcxxProject::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
517
                            .eq(ZpglRcxxProject::getDeleteFlag, 0).orderByDesc(ZpglRcxxProject::getEndTime)
518 519 520 521
            );
            // 培训经验
            List<ZpglRcxxTrain> zpglRcxxTrains = ZpglRcxxTrain.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxTrain>().lambda().eq(ZpglRcxxTrain::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
522
                            .eq(ZpglRcxxTrain::getIsDelete, 0).orderByDesc(ZpglRcxxTrain::getEndTime)
523
            );
翁国栋 committed
524 525 526 527 528
            // 家庭资料
            List<ZpglRcxxJtzl> zpglRcxxJtzls = ZpglRcxxJtzl.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxJtzl>().lambda().eq(ZpglRcxxJtzl::getZpglRcxxId, zpglRcxxId)
                            .eq(ZpglRcxxJtzl::getIsDelete, 0).orderByDesc(ZpglRcxxJtzl::getCreateTime)
            );
529 530 531 532

            // FPA性格测评数据
            ZpglDtk zpglDtk = ZpglDtk.builder().build().selectOne(new QueryWrapper<ZpglDtk>().lambda().eq(ZpglDtk::getZpglRcxxId, zpglRcxxId));

533
            // offer
534
            ZpglRcxxOffer zpglRcxxOffer = ZpglRcxxOffer.builder().build().selectOne(new QueryWrapper<ZpglRcxxOffer>().lambda().eq(ZpglRcxxOffer::getZpglRcxxId, zpglRcxxId).eq(ZpglRcxxOffer::getDeleteFlag, 0).orderByDesc(ZpglRcxxOffer::getCreateTime));
535 536

            Map<String, Object> map = new HashMap<>(7);
537 538 539 540 541 542
            map.put("zpglRcxx", zpglRcxx);
            map.put("zpglRcxxExperiences", zpglRcxxExperiences);
            map.put("zpglRcxxStudys", zpglRcxxStudys);
            map.put("zpglRcxxProjects", zpglRcxxProjects);
            map.put("zpglRcxxTrains", zpglRcxxTrains);
            map.put("zpglDtk", zpglDtk);
543
            map.put("zpglRcxxOffer", zpglRcxxOffer);
翁国栋 committed
544
            map.put("zpglRcxxJtzls",zpglRcxxJtzls);
284718418@qq.com committed
545
            return ResultUtil.data(map, "搜索成功");
546 547 548 549 550 551 552 553 554

        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("获取招聘-标准简历信息失败");
        }

    }

    /**
284718418@qq.com committed
555 556 557 558 559 560 561 562 563 564 565
     * 招聘-发起录用审批选择
     *
     * @param
     * @return
     */
    @GetMapping(value = "/custom_approval")
    @ApiOperation(value = "10.招聘-发起录用审批选择", httpMethod = "GET", notes = "招聘-发起录用审批选择")
    @ApiOperationSupport(order = 10)
    public Result<Object> customApproval(@CurrentUser UserBean userBean) {
        try {
            List<SpmkCustomApproval> spmkCustomApprovals = SpmkCustomApproval.builder().build().selectList(
284718418@qq.com committed
566 567 568
                    new QueryWrapper<SpmkCustomApproval>().select("id", "name")
                            .lambda().eq(SpmkCustomApproval::getOrgCode, userBean.getOrgCode())
                            .eq(SpmkCustomApproval::getAssoType, 10)
284718418@qq.com committed
569 570 571 572 573 574 575 576 577 578
            );
            return ResultUtil.data(spmkCustomApprovals);
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("获取招聘-发起录用审批选择信息失败");
        }

    }

    /**
284718418@qq.com committed
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
     * 招聘-发起应聘登记或者测评 status:0应聘登记,1测评
     *
     * @param
     * @return
     */
    @GetMapping(value = "/send_apply_cp/{id}/{status}")
    @ApiOperation(value = "11.招聘-发起应聘登记或者测评", httpMethod = "GET", notes = "status:0应聘登记,1测评")
    @ApiOperationSupport(order = 11)
    public Result<Object> sendApplyOrCp(@CurrentUser UserBean userBean, @PathVariable Integer id, @PathVariable Integer status) {
        try {
            ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(id).build().selectById();
            if (StringUtils.isEmpty(zpglRcxx)) {
                log.error("招聘-发起应聘登记或测评:id={} 空数据", id);
                return ResultUtil.error("操作失败~");
            }
            InterviewNotice interviewNotice = new InterviewNotice();
595 596 597 598
            ZpglZwxx zpglZwxx = ZpglZwxx.builder().id(zpglRcxx.getZpglZwxxId()).build().selectById();
            if (!StringUtils.isEmpty(zpglZwxx)) {
                interviewNotice.setZpglZwxxName(zpglZwxx.getName());
            }
284718418@qq.com committed
599 600 601 602 603 604 605 606 607 608 609
            interviewNotice.setName(zpglRcxx.getName());
            interviewNotice.setEmail(zpglRcxx.getMail());
            //公众号类型 1:8小时企业管理 2:优领人才网
            interviewNotice.setWxgzhType(1);
            //0 即时发送,1 定时发送
            interviewNotice.setTiming(0);
            interviewNotice.setType(JxglEnumInterface.NoticeWay.WECHAT_PUBLIC.getType());
            interviewNotice.setInterviewTime(new Date());
            // 通知面试者
            interviewNotice.setZpglRcxxId(zpglRcxx.getId());
            interviewNotice.setMobile(zpglRcxx.getMobile());
610 611 612
            interviewNotice.setNoticeName(userBean.getQyzxEmpLogin().getUsername());
            interviewNotice.setRemark("请点击详情填写");
            interviewNotice.setTemplateId(MessageTemplate.TEMPLATE_ID_TO_INTERVIEWE);
284718418@qq.com committed
613 614
            // 发送应聘登记表消息
            if (APPLY_STATUS == status.intValue()) {
615 616
                interviewNotice.setContentNotice(ZpglMessageTemplate.TO_APPLY);
                interviewNotice.setContentStr(ZpglMessageTemplate.print(ZpglMessageTemplate.THANKS, new String[]{zpglRcxx.getName(),interviewNotice.getZpglZwxxName()}));
284718418@qq.com committed
617
                interviewNotice.setUrl(h5Url + "?zpglRcxxId="+zpglRcxx.getId()+"&mobile=" + zpglRcxx.getMobile() + "&orgId=" + userBean.getOrgCode() + "#/basicInfo");
284718418@qq.com committed
618 619
            // 发送FPA测评消息
            } else {
620 621
                interviewNotice.setContentNotice(ZpglMessageTemplate.TO_CEPIN);
                interviewNotice.setContentStr(ZpglMessageTemplate.print(ZpglMessageTemplate.THANKS, new String[]{zpglRcxx.getName(),interviewNotice.getZpglZwxxName()}));
284718418@qq.com committed
622
                interviewNotice.setUrl(h5Url + "/?zpglRcxxId=" + zpglRcxx.getId()+ "&orgId=" + userBean.getOrgCode() + "#/cpxt");
284718418@qq.com committed
623 624 625 626 627 628 629 630 631
            }
            log.info("TO_INTERVIEWEE sendApplyOrCePin MessageQueue info:{}", zpglWxgzptService.sendApplyOrCePin(interviewNotice));
            return ResultUtil.success();
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("操作失败");
        }

    }
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 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
    /**
     * 招聘-逻辑删除人才信息
     *
     * @param
     * @return
     */
    @PostMapping(value = "/edit/{id}")
    @ApiOperation(value = "12.招聘-删除人才信息", httpMethod = "GET", notes = "删除人才信息")
    @ApiOperationSupport(order = 12)
    public Result<Object> edit(@CurrentUser UserBean userBean, @PathVariable Integer id) {
        try {
            return ZpglRcxx.builder().id(id).deleteFlag(1).userId(userBean.getEmpNum()).build().updateById() ? ResultUtil.success("操作成功") : ResultUtil.error("操作失败");
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-删除人才信息失败");
        }

    }
    /**
     * 招聘-人才库
     *
     * @param
     * @return
     */
    @GetMapping(value = "/recruit/envelope")
    @ApiOperation(value = "13.招聘-人才库列表", httpMethod = "GET", notes = "招聘-人才库列表")
    @ApiOperationSupport(order = 13)
    public Result<Object> envelope(@CurrentUser UserBean userBean, BaseQuery baseQuery,
                                   @ApiParam("搜索关键字") @RequestParam(required = false) String query,
                                   @ApiParam("职位ID") @RequestParam(required = false) Integer zpglZwxxId,
                                   @ApiParam("状态") @RequestParam(required = false) Integer status,
                                   @ApiParam("排序") @RequestParam(required = false) Integer orderBy) {
        try {
            Page<ZpglRcxx> page = new Page<ZpglRcxx>(baseQuery.getPageNum(), baseQuery.getPageSize());
            QueryWrapper<ZpglRcxx> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("org_code", userBean.getOrgCode()).eq("delete_flag", 0);
            if (!StringUtils.isEmpty(zpglZwxxId) && zpglZwxxId > 0) {
                queryWrapper.eq("zpgl_zwxx_id", zpglZwxxId);
            }
            if (!StringUtils.isEmpty(query)) {
                queryWrapper.and(qw -> qw.like("name", query).or().eq("mobile", query).or().eq("mail", query));
            }
            queryWrapper.eq("ifrck", 1);
            if (!StringUtils.isEmpty(orderBy)) {
                // 排序 1最近跟进时间 2最近入库时间 3最早入库时间
                if (orderBy.intValue() == 1) {
                    queryWrapper.orderByDesc("update_time");
                } else if (orderBy.intValue() == 2) {
                    queryWrapper.orderByDesc("ifrck_time");
                } else if (orderBy.intValue() == 3) {
                    queryWrapper.orderByAsc("ifrck_time");
                }
            }else {
                queryWrapper.orderByDesc("update_time");
            }

            IPage<ZpglRcxx> zpglRcxxPage = ZpglRcxx.builder().build().selectPage(page, queryWrapper);
            List<ZpglRcxx> zpglRcxxs = page.getRecords();
            for (ZpglRcxx entity : zpglRcxxs) {
                if(!StringUtils.isEmpty(entity.getZpglFailId()) && entity.getZpglFailId()>0){
                    ZpglFail fail = ZpglFail.builder().id(entity.getZpglFailId()).build().selectById();
                    entity.setFailCause(fail.getFailCause());
                }
            }
            zpglRcxxPage.getCurrent();
            zpglRcxxPage.getPages();
            zpglRcxxPage.getTotal();
            zpglRcxxPage.getSize();
            return ResultUtil.data(zpglRcxxPage, zpglRcxxs, "搜索成功");

        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-已淘汰,人才库列表失败");
        }

    }
284718418@qq.com committed
708 709

    /**
284718418@qq.com committed
710
     * 获取统计数据
284718418@qq.com committed
711
     *
284718418@qq.com committed
712 713 714 715 716
     * @param queryWrapper
     * @param status
     * @param orgCode
     * @return
     */
284718418@qq.com committed
717
    private Integer getNum(QueryWrapper<ZpglRcxx> queryWrapper, Integer status, Integer orgCode) {
284718418@qq.com committed
718
        queryWrapper.clear();
284718418@qq.com committed
719
        queryWrapper.lambda().eq(ZpglRcxx::getOrgCode, orgCode).eq(ZpglRcxx::getDeleteFlag, 0);
284718418@qq.com committed
720 721 722
        return ZpglRcxx.builder().build().selectCount(queryWrapper.lambda().eq(ZpglRcxx::getStatus, status));
    }

284718418@qq.com committed
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
    /**
     * 人才信息同步至员工档案
     * @param source
     * @param target
     */
    private void copyToYgglMainEmp(ZpglRcxx source,YgglMainEmp target){
        if(!StringUtils.isEmpty(source.getMail())){
            target.setWorkEmail(source.getMail());
        }
        if(!StringUtils.isEmpty(source.getDatebirth())){
            target.setBirthday(source.getDatebirth());
        }
        if(!StringUtils.isEmpty(source.getBmgwId())){
            target.setBmgwId(source.getBmgwId());
        }
        if(!StringUtils.isEmpty(source.getProvinceId())){
            target.setProvinceId(source.getProvinceId());
        }
        if(!StringUtils.isEmpty(source.getProvince())){
            target.setProvince(source.getProvince());
        }
        if(!StringUtils.isEmpty(source.getDistrictId())){
            target.setDistrictId(source.getDistrictId());
        }
        if(!StringUtils.isEmpty(source.getDistrict())){
            target.setDistrict(source.getDistrict());
        }

        if(!StringUtils.isEmpty(source.getCityId())){
            target.setCityId(source.getCityId());
        }
        if(!StringUtils.isEmpty(source.getCity())){
            target.setCityId(source.getCity());
        }
        if(!StringUtils.isEmpty(source.getAddress())){

        }
        if(!StringUtils.isEmpty(source.getHighesteducation())){
            target.setEdu(Integer.parseInt(source.getHighesteducation()));
        }
        if(!StringUtils.isEmpty(source.getSex())){
            target.setSex(source.getSex());
        }
        if(!StringUtils.isEmpty(source.getZpglCompanyId())){
            target.setZpglCompanyId(source.getZpglCompanyId());
        }
        if(!StringUtils.isEmpty(source.getZpglZjId())){
            target.setZpglZjId(source.getZpglZjId());
        }
        if(!StringUtils.isEmpty(source.getZpglGzddId())){
            target.setZpglGzddId(source.getZpglGzddId());
        }
        if(!StringUtils.isEmpty(source.getWeixin())){
            target.setWechat(source.getWeixin());
        }

    }
翁国栋 committed
780 781 782 783 784 785 786 787 788 789 790 791
    @PostMapping(value = "/editInfo")
    @ApiOperation(value = "14.招聘-变更基础信息", httpMethod = "POST", notes = "招聘-变更人才信息状态")
    @ApiOperationSupport(order = 3)
    public Result<Object> editInfo(@CurrentUser UserBean userBean, @RequestBody ZpglRcxxDto zpglRcxxDto) {
        try {
           boolean re = ZpglRcxx.builder().name(zpglRcxxDto.getName()).mobile(zpglRcxxDto.getMobile()).mail(zpglRcxxDto.getMail()).build().update(new LambdaUpdateWrapper<ZpglRcxx>().eq(ZpglRcxx::getId, zpglRcxxDto.getId()));
            return re?ResultUtil.success("修改成功"):ResultUtil.error("修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-修改成功");
        }
    }
284718418@qq.com committed
792

793
}