ZpglController.java 33.9 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;
284718418@qq.com committed
8
import cn.timer.api.bean.spmk.SpmkCustomApproval;
284718418@qq.com committed
9
import cn.timer.api.bean.wechat.MessageTemplate;
10
import cn.timer.api.bean.yggl.YgglMainEmp;
11
import cn.timer.api.bean.zpgl.*;
12 13 14
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enuminterface.JxglEnumInterface;
15 16
import cn.timer.api.config.enums.CommonEnum;
import cn.timer.api.config.enums.SysRoleType;
17
import cn.timer.api.config.exception.CustomException;
18 19 20
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
21
import cn.timer.api.controller.zpgl.sevice.ZpglWxgzptService;
22 23 24 25
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;
26
import cn.timer.api.dao.zpgl.ZpglRcxxMapper;
284718418@qq.com committed
27
import cn.timer.api.dto.template.InterviewNotice;
28
import cn.timer.api.dto.zpgl.ImportCandidateDto;
29
import cn.timer.api.dto.zpgl.ZpglRcxxDto;
30
import cn.timer.api.dto.zpgl.ZpglRcxxEntryDto;
31
import cn.timer.api.utils.Md5;
32 33
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
284718418@qq.com committed
34
import cn.timer.api.utils.ZpglMessageTemplate;
35
import cn.timer.api.utils.query.BaseQuery;
36
import cn.timer.api.config.enuminterface.YgEnumInterface.jobStatus;
37 38
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
39
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
40 41
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
42
import com.github.yulichang.query.MPJQueryWrapper;
43 44
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
45
import io.swagger.annotations.ApiParam;
46
import lombok.extern.slf4j.Slf4j;
47
import org.springframework.beans.factory.annotation.Autowired;
48 49 50 51 52 53 54
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;
55
import org.springframework.util.StringUtils;
56
import org.springframework.validation.annotation.Validated;
57
import org.springframework.web.bind.annotation.*;
58
import org.springframework.web.client.RestTemplate;
59
import org.springframework.web.multipart.MultipartFile;
60

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

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

84 85 86 87 88
    @Value(value = "${config-8timer.init-password}")
    private String pwd;
    // 回调地址
    @Value("${config-8timer.machine8timerUrl}")
    public String mac_command;
89
    @Autowired
90
    private KqglAssoKqzdkfsMapper kqglassokqzdkfsmapper;
91
    @Autowired
92 93 94 95 96 97 98 99 100
    private QyzxEmpLoginMapper qyzxEmpLoginMapper;
    @Autowired
    private RealTimeUpdate realtimeupdate;
    @Autowired
    private UserEquiRelationMapper userequirelationmapper;
    @Autowired
    private YgglMainEmpMapper ygglMainEmpMapper;
    @Autowired
    private ZpglService zpglService;
101 102
    @Autowired
    private ZpglRcxxMapper zpglRcxxMapper;
284718418@qq.com committed
103 104 105 106 107 108 109 110 111 112 113 114
    @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;
115

116 117 118 119 120 121 122 123 124
    /**
     * 招聘-招聘中
     *
     * @param
     * @return
     */
    @GetMapping(value = "/recruit")
    @ApiOperation(value = "1.招聘列表", httpMethod = "GET", notes = "招聘列表")
    @ApiOperationSupport(order = 1)
125
    public Result<Object> recruit(@CurrentUser UserBean userBean, BaseQuery baseQuery,
126 127 128
                                  @ApiParam("搜索关键字") @RequestParam(required = false) String query,
                                  @ApiParam("职位ID") @RequestParam(required = false) Integer zpglZwxxId,
                                  @ApiParam("状态") @RequestParam(required = false) Integer status) {
129 130 131
        try {
            Page<ZpglRcxx> page = new Page<ZpglRcxx>(baseQuery.getPageNum(), baseQuery.getPageSize());
            QueryWrapper<ZpglRcxx> queryWrapper = new QueryWrapper<>();
284718418@qq.com committed
132
            queryWrapper.lambda().eq(ZpglRcxx::getOrgCode, userBean.getOrgCode()).eq(ZpglRcxx::getDeleteFlag, 0);
133 134 135 136 137 138
            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));
            }
139
            queryWrapper.lambda().eq(ZpglRcxx::getStatus, status).orderByDesc(ZpglRcxx::getUpdateTime);
140
            IPage<ZpglRcxx> zpglRcxxPage = ZpglRcxx.builder().build().selectPage(page, queryWrapper);
141
            List<ZpglRcxx> zpglRcxxs = page.getRecords();
142 143 144 145
            zpglRcxxPage.getCurrent();
            zpglRcxxPage.getPages();
            zpglRcxxPage.getTotal();
            zpglRcxxPage.getSize();
146
            Map<String, Object> map = new HashMap<>(9);
147
            map.put("zpglRcxxs", zpglRcxxs);
284718418@qq.com committed
148 149 150 151 152 153 154 155
            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()));
156
            return ResultUtil.data(zpglRcxxPage, map, "搜索成功");
157 158 159 160

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

163
    }
164

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

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

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

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

            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();
238 239 240
            ZpglRcxxDto zpglRcxxDto = new ZpglRcxxDto();
            zpglRcxxDto.setId(zpglRcxx.getId());
            zpglRcxxDto.setStatus(addygdaDto.getStatus());
241
            zpglRcxxDto.setZpglZwxxId(zpglRcxx.getZpglZwxxId());
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256

            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
257
            if (!StringUtils.isEmpty(ygglMainEmp)) {
258 259 260 261
                return ResultUtil.error("该手机号已被使用,请输入正确手机号");
            }
            QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(orgCode).userType(SysRoleType.U_TYPE_EMP.getType())
                    .status(CommonEnum.U_STS_ON.getType()).build().insert();
262
            ygglMainEmp = YgglMainEmp.builder().name(name).phone(phone).zjType(addygdaDto.getZjType()).zjNum(zjNum).jobType(jobType)
263 264 265 266 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
                    .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);
294
                        }
284718418@qq.com committed
295
                        if (!uskqj.insert()) {
296
                            return ResultUtil.error("操作失败--新增用户与设备关系");
297 298
                        }
                    }
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
                }

            }

            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));
            }

            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();
                }
325
            }
326 327 328 329 330 331 332
            /**
             * 职位信息已入职人数+1
             * 招聘-变更人才信息状态
             * 添加面试流程记录
             * 维护微信公众平台表
             */
            zpglService.updateZpglOther(userBean, zpglRcxxDto, ygglMainEmp.getEmpNum());
333 334 335 336 337 338
            try {
                realtimeupdate.AttendanceTask(userBean.getOrgCode(), ygglMainEmp.getEmpNum(), 2, null);
            } catch (ParseException e) {
                e.printStackTrace();
            }

339
            return ResultUtil.success("确认入职成功!");
340

341 342
        } catch (Exception e) {
            e.printStackTrace();
343
            throw new CustomException("招聘-确认入职失败");
344
        }
345

346
    }
347

348
    /**
349
     * 招聘-已淘汰
350 351 352 353 354
     *
     * @param
     * @return
     */
    @GetMapping(value = "/recruit/fail")
355
    @ApiOperation(value = "5.招聘-已淘汰列表", httpMethod = "GET", notes = "招聘-已淘汰列表")
356 357
    @ApiOperationSupport(order = 5)
    public Result<Object> recruitFail(@CurrentUser UserBean userBean, BaseQuery baseQuery,
284718418@qq.com committed
358 359 360 361
                                      @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) {
362 363 364 365
        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
366 367
                    .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());
368 369 370 371 372 373
            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
374
            if (!StringUtils.isEmpty(status)) {
375 376
                queryWrapper.eq("t.status", 9);
                queryWrapper.eq("zf.zpgl_rcxx_status", status);
284718418@qq.com committed
377
            } else {
378 379
                queryWrapper.eq("t.ifrck", 1);
            }
284718418@qq.com committed
380
            if (!StringUtils.isEmpty(orderBy)) {
381
                // 排序 1最近跟进时间 2最近入库时间 3最早入库时间
284718418@qq.com committed
382
                if (orderBy.intValue() == 1) {
383
                    queryWrapper.orderByDesc("t.update_time");
284718418@qq.com committed
384
                } else if (orderBy.intValue() == 2) {
385
                    queryWrapper.orderByDesc("t.ifrck_time");
284718418@qq.com committed
386
                } else if (orderBy.intValue() == 3) {
387 388 389
                    queryWrapper.orderByAsc("t.ifrck_time");
                }
            }
390

284718418@qq.com committed
391
            IPage<ZpglRcxx> zpglRcxxPage = zpglRcxxMapper.selectJoinPage(page, ZpglRcxx.class, queryWrapper);
392 393 394 395 396 397 398 399 400
            List<ZpglRcxx> zpglRcxxs = page.getRecords();
            zpglRcxxPage.getCurrent();
            zpglRcxxPage.getPages();
            zpglRcxxPage.getTotal();
            zpglRcxxPage.getSize();
            return ResultUtil.data(zpglRcxxPage, zpglRcxxs, "搜索成功");

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

    }
284718418@qq.com committed
405

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

    }
424

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

    }
284718418@qq.com committed
466

467 468 469 470 471 472 473 474 475 476 477
    /**
     * 招聘-更改招聘职位
     *
     * @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
478
            return zpglService.updateZpglRcxxZwxx(userBean, zpglRcxxDto) ? ResultUtil.success("更改招聘职位成功") : ResultUtil.error("更改招聘职位失败");
479 480 481 482 483
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("招聘-更改招聘职位失败");
        }
    }
484 485

    /**
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
     * 招聘-标准简历信息
     *
     * @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
501
                            .eq(ZpglRcxxExperience::getIsDelete, 0).orderByDesc(ZpglRcxxExperience::getEndTime)
502 503 504 505
            );
            // 教育经历
            List<ZpglRcxxStudy> zpglRcxxStudys = ZpglRcxxStudy.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxStudy>().lambda().eq(ZpglRcxxStudy::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
506
                            .eq(ZpglRcxxStudy::getIsDelete, 0).orderByDesc(ZpglRcxxStudy::getEndTime)
507 508 509 510
            );
            // 项目经历
            List<ZpglRcxxProject> zpglRcxxProjects = ZpglRcxxProject.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxProject>().lambda().eq(ZpglRcxxProject::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
511
                            .eq(ZpglRcxxProject::getDeleteFlag, 0).orderByDesc(ZpglRcxxProject::getEndTime)
512 513 514 515
            );
            // 培训经验
            List<ZpglRcxxTrain> zpglRcxxTrains = ZpglRcxxTrain.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxTrain>().lambda().eq(ZpglRcxxTrain::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
516
                            .eq(ZpglRcxxTrain::getIsDelete, 0).orderByDesc(ZpglRcxxTrain::getEndTime)
517 518 519 520 521
            );

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

522
            // offer
523
            ZpglRcxxOffer zpglRcxxOffer = ZpglRcxxOffer.builder().build().selectOne(new QueryWrapper<ZpglRcxxOffer>().lambda().eq(ZpglRcxxOffer::getZpglRcxxId, zpglRcxxId).eq(ZpglRcxxOffer::getDeleteFlag, 0).orderByDesc(ZpglRcxxOffer::getCreateTime));
524 525

            Map<String, Object> map = new HashMap<>(7);
526 527 528 529 530 531
            map.put("zpglRcxx", zpglRcxx);
            map.put("zpglRcxxExperiences", zpglRcxxExperiences);
            map.put("zpglRcxxStudys", zpglRcxxStudys);
            map.put("zpglRcxxProjects", zpglRcxxProjects);
            map.put("zpglRcxxTrains", zpglRcxxTrains);
            map.put("zpglDtk", zpglDtk);
532
            map.put("zpglRcxxOffer", zpglRcxxOffer);
284718418@qq.com committed
533
            return ResultUtil.data(map, "搜索成功");
534 535 536 537 538 539 540 541 542

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

    }

    /**
284718418@qq.com committed
543 544 545 546 547 548 549 550 551 552 553
     * 招聘-发起录用审批选择
     *
     * @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
554 555 556
                    new QueryWrapper<SpmkCustomApproval>().select("id", "name")
                            .lambda().eq(SpmkCustomApproval::getOrgCode, userBean.getOrgCode())
                            .eq(SpmkCustomApproval::getAssoType, 10)
284718418@qq.com committed
557 558 559 560 561 562 563 564 565 566
            );
            return ResultUtil.data(spmkCustomApprovals);
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("获取招聘-发起录用审批选择信息失败");
        }

    }

    /**
284718418@qq.com committed
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582
     * 招聘-发起应聘登记或者测评 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();
583 584 585 586
            ZpglZwxx zpglZwxx = ZpglZwxx.builder().id(zpglRcxx.getZpglZwxxId()).build().selectById();
            if (!StringUtils.isEmpty(zpglZwxx)) {
                interviewNotice.setZpglZwxxName(zpglZwxx.getName());
            }
284718418@qq.com committed
587 588 589 590 591 592 593 594 595 596 597
            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());
598 599 600
            interviewNotice.setNoticeName(userBean.getQyzxEmpLogin().getUsername());
            interviewNotice.setRemark("请点击详情填写");
            interviewNotice.setTemplateId(MessageTemplate.TEMPLATE_ID_TO_INTERVIEWE);
284718418@qq.com committed
601 602
            // 发送应聘登记表消息
            if (APPLY_STATUS == status.intValue()) {
603 604
                interviewNotice.setContentNotice(ZpglMessageTemplate.TO_APPLY);
                interviewNotice.setContentStr(ZpglMessageTemplate.print(ZpglMessageTemplate.THANKS, new String[]{zpglRcxx.getName(),interviewNotice.getZpglZwxxName()}));
284718418@qq.com committed
605 606 607
                interviewNotice.setUrl(h5Url + "?mobile=" + zpglRcxx.getMobile() + "&orgId=" + userBean.getOrgCode() + "#/basicInfo");
            // 发送FPA测评消息
            } else {
608 609
                interviewNotice.setContentNotice(ZpglMessageTemplate.TO_CEPIN);
                interviewNotice.setContentStr(ZpglMessageTemplate.print(ZpglMessageTemplate.THANKS, new String[]{zpglRcxx.getName(),interviewNotice.getZpglZwxxName()}));
284718418@qq.com committed
610 611 612 613 614 615 616 617 618 619
                interviewNotice.setUrl(h5Url + "/?zpglRcxxId=" + zpglRcxx.getId() + "#/cpxt");
            }
            log.info("TO_INTERVIEWEE sendApplyOrCePin MessageQueue info:{}", zpglWxgzptService.sendApplyOrCePin(interviewNotice));
            return ResultUtil.success();
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("操作失败");
        }

    }
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 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
    /**
     * 招聘-逻辑删除人才信息
     *
     * @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
696 697

    /**
284718418@qq.com committed
698
     * 获取统计数据
284718418@qq.com committed
699
     *
284718418@qq.com committed
700 701 702 703 704
     * @param queryWrapper
     * @param status
     * @param orgCode
     * @return
     */
284718418@qq.com committed
705
    private Integer getNum(QueryWrapper<ZpglRcxx> queryWrapper, Integer status, Integer orgCode) {
284718418@qq.com committed
706
        queryWrapper.clear();
284718418@qq.com committed
707
        queryWrapper.lambda().eq(ZpglRcxx::getOrgCode, orgCode).eq(ZpglRcxx::getDeleteFlag, 0);
284718418@qq.com committed
708 709 710
        return ZpglRcxx.builder().build().selectCount(queryWrapper.lambda().eq(ZpglRcxx::getStatus, status));
    }

711
}