| | |
| | | package cc.mrbird.febs.server.hr.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.core.constant.ModuleCode; |
| | | import cc.mrbird.febs.common.core.exception.FebsException; |
| | | import cc.mrbird.febs.server.hr.constant.MyConstant; |
| | | import cc.mrbird.febs.server.hr.entity.EmpLaborTrouble; |
| | | import cc.mrbird.febs.server.hr.entity.EmpResign; |
| | | import cc.mrbird.febs.server.hr.entity.EmpResign; |
| | | import cc.mrbird.febs.server.hr.entity.EmpUnemployment; |
| | | import cc.mrbird.febs.server.hr.mapper.EmpResignMapper; |
| | | import cc.mrbird.febs.server.hr.service.IEmpBaseInfoService; |
| | | import cc.mrbird.febs.server.hr.service.IEmpResignService; |
| | | import cn.hutool.core.date.DateUtil; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cc.mrbird.febs.common.core.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.core.entity.system.Dept; |
| | | import cc.mrbird.febs.common.core.utils.CastUtil; |
| | | import cc.mrbird.febs.common.core.utils.FebsUtil; |
| | | import cc.mrbird.febs.common.core.utils.SequenceUtil; |
| | | import cc.mrbird.febs.common.redis.service.RedisService; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) |
| | | class EmpResignServiceImpl extends ServiceImpl<EmpResignMapper, EmpResign> implements IEmpResignService { |
| | | |
| | | private final RedisService redisService; |
| | | private final EmpResignMapper empResignMapper; |
| | | private final IEmpBaseInfoService empBaseInfoService; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()) |
| | | .map(u -> u.getUserId().toString()) |
| | | .orElse("1"); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createEmpResign(EmpResign empResign) { |
| | | public void createEmpResign(EmpResign empResign) throws FebsException { |
| | | LambdaQueryWrapper<EmpResign> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(EmpResign::getEmpId, empResign.getEmpId()); |
| | | lambdaQueryWrapper.eq(EmpResign::getApplayDate, empResign.getApplayDate()); |
| | | lambdaQueryWrapper.ne(EmpResign::getDelFlag,1); |
| | | if (this.count(lambdaQueryWrapper) > 0) { |
| | | throw new FebsException(MyConstant.MESSAGE); |
| | | } |
| | | empResign.setResignId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | empResign.setCreator(operatorId); |
| | | empResign.setModifier(operatorId); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateEmpResign(EmpResign empResign) { |
| | | public void updateEmpResign(EmpResign empResign) throws FebsException { |
| | | LambdaQueryWrapper<EmpResign> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(EmpResign::getEmpId, empResign.getEmpId()); |
| | | lambdaQueryWrapper.eq(EmpResign::getApplayDate, empResign.getApplayDate()); |
| | | lambdaQueryWrapper.ne(EmpResign::getDelFlag,1); |
| | | lambdaQueryWrapper.ne(EmpResign::getApplayDate,empResign.getApplayDate()); |
| | | if (this.count(lambdaQueryWrapper) > 0) { |
| | | throw new FebsException(MyConstant.MESSAGE); |
| | | } |
| | | EmpResign dbData = this.getById(empResign.getResignId()); |
| | | empResign.setCreateTime(dbData.getCreateTime()); |
| | | empResign.setCreator(dbData.getCreator()); |
| | |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | return empResignMapper.momentToNormal(list, operatorId)>0; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importEmpResign(List<List<Object>> listObject,List<String> returnList) { |
| | | for (List<Object> list : listObject) { |
| | | if (list.size()==0){ |
| | | continue; |
| | | } |
| | | EmpResign resign = new EmpResign(); |
| | | resign.setResignId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | resign.setEmpNumb(list.get(0).toString()); |
| | | List<Dept> depts = CastUtil.castList(redisService.get("depts"), Dept.class); |
| | | Dept dept = depts.stream().filter(d -> d.getDeptName().equals(list.get(1).toString())).findFirst().orElse(null); |
| | | if (null == dept) { |
| | | returnList.add(StrUtil.format("导入员工辞职申请异常: 出现位置第{}行, 原因:{}部门不存在",listObject.indexOf(list)+1,list.get(1).toString())); |
| | | continue; |
| | | } |
| | | Long empId = empBaseInfoService.getEmpIdByEmpNumb(list.get(0).toString()); |
| | | if (null == empId){ |
| | | returnList.add(StrUtil.format("导入员工辞职申请异常: 出现位置第{}行, 原因:{}员工编号不存在",listObject.indexOf(list)+1,list.get(0).toString())); |
| | | continue; |
| | | } |
| | | resign.setDelFlag(2); |
| | | resign.setEmpId(empId); |
| | | resign.setDeptName(list.get(1).toString()); |
| | | resign.setDeptId(dept.getDeptId()); |
| | | resign.setJobName(list.get(2).toString()); |
| | | resign.setEmpName(list.get(3).toString()); |
| | | resign.setCertificateNumb(list.get(4).toString()); |
| | | if (StringUtils.isNotBlank(list.get(5).toString())) { |
| | | resign.setApplayDate(DateUtil.parseDate(list.get(5).toString())); |
| | | } |
| | | resign.setReason(list.get(6).toString()); |
| | | resign.setReporter(list.get(7).toString()); |
| | | resign.setRemark(list.get(8).toString()); |
| | | this.save(resign); |
| | | } |
| | | } |
| | | } |