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

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

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

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

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

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

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

167
    }
168

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

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

翁国栋 committed
211

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

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

            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();
243 244 245
            ZpglRcxxDto zpglRcxxDto = new ZpglRcxxDto();
            zpglRcxxDto.setId(zpglRcxx.getId());
            zpglRcxxDto.setStatus(addygdaDto.getStatus());
246
            zpglRcxxDto.setZpglZwxxId(zpglRcxx.getZpglZwxxId());
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261

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

            }

            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
318 319
            // 人才信息同步至员工档案
            this.copyToYgglMainEmp(zpglRcxx,ygglMainEmp);
320 321 322 323 324 325 326 327 328 329 330 331

            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();
                }
332
            }
333 334 335 336 337 338
            /**
             * 职位信息已入职人数+1
             * 招聘-变更人才信息状态
             * 添加面试流程记录
             * 维护微信公众平台表
             */
284718418@qq.com committed
339
            zpglService.updateZpglOther(userBean, zpglRcxxDto, ygglMainEmp.getId());
340 341 342 343 344 345
            try {
                realtimeupdate.AttendanceTask(userBean.getOrgCode(), ygglMainEmp.getEmpNum(), 2, null);
            } catch (ParseException e) {
                e.printStackTrace();
            }

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

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

353
    }
354

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

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

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

    }
284718418@qq.com committed
412

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

    }
431

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

    }
284718418@qq.com committed
473

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

    /**
493 494 495 496 497 498 499 500 501 502 503 504
     * 招聘-标准简历信息
     *
     * @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();
翁国栋 committed
505
            zpglRcxx.setNationName(NationClass.builder().id(zpglRcxx.getNationClassId()).build().selectById().getName());
506 507 508
            // 工作经验
            List<ZpglRcxxExperience> zpglRcxxExperiences = ZpglRcxxExperience.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxExperience>().lambda().eq(ZpglRcxxExperience::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
509
                            .eq(ZpglRcxxExperience::getIsDelete, 0).orderByDesc(ZpglRcxxExperience::getEndTime)
510 511 512 513
            );
            // 教育经历
            List<ZpglRcxxStudy> zpglRcxxStudys = ZpglRcxxStudy.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxStudy>().lambda().eq(ZpglRcxxStudy::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
514
                            .eq(ZpglRcxxStudy::getIsDelete, 0).orderByDesc(ZpglRcxxStudy::getEndTime)
515 516 517 518
            );
            // 项目经历
            List<ZpglRcxxProject> zpglRcxxProjects = ZpglRcxxProject.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxProject>().lambda().eq(ZpglRcxxProject::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
519
                            .eq(ZpglRcxxProject::getDeleteFlag, 0).orderByDesc(ZpglRcxxProject::getEndTime)
520 521 522 523
            );
            // 培训经验
            List<ZpglRcxxTrain> zpglRcxxTrains = ZpglRcxxTrain.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxTrain>().lambda().eq(ZpglRcxxTrain::getZpglRcxxId, zpglRcxxId)
284718418@qq.com committed
524
                            .eq(ZpglRcxxTrain::getIsDelete, 0).orderByDesc(ZpglRcxxTrain::getEndTime)
525
            );
翁国栋 committed
526 527 528 529 530
            // 家庭资料
            List<ZpglRcxxJtzl> zpglRcxxJtzls = ZpglRcxxJtzl.builder().build().selectList(
                    new QueryWrapper<ZpglRcxxJtzl>().lambda().eq(ZpglRcxxJtzl::getZpglRcxxId, zpglRcxxId)
                            .eq(ZpglRcxxJtzl::getIsDelete, 0).orderByDesc(ZpglRcxxJtzl::getCreateTime)
            );
531 532 533 534

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

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

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

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

    }

    /**
284718418@qq.com committed
557 558 559 560 561 562 563 564 565 566 567
     * 招聘-发起录用审批选择
     *
     * @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
568 569 570
                    new QueryWrapper<SpmkCustomApproval>().select("id", "name")
                            .lambda().eq(SpmkCustomApproval::getOrgCode, userBean.getOrgCode())
                            .eq(SpmkCustomApproval::getAssoType, 10)
284718418@qq.com committed
571 572 573 574 575 576 577 578 579 580
            );
            return ResultUtil.data(spmkCustomApprovals);
        } catch (Exception e) {
            e.printStackTrace();
            throw new CustomException("获取招聘-发起录用审批选择信息失败");
        }

    }

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

    }
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 708 709
    /**
     * 招聘-逻辑删除人才信息
     *
     * @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
710 711

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

284718418@qq.com committed
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 780 781
    /**
     * 人才信息同步至员工档案
     * @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
782 783 784 785 786 787 788 789 790 791 792 793
    @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
794

795
}