| | |
| | | package cc.mrbird.febs.server.hr.service.impl; |
| | | |
| | | import cc.mrbird.febs.server.hr.entity.EmpContractInfo; |
| | | import cc.mrbird.febs.server.hr.mapper.EmpContractInfoMapper; |
| | | import cc.mrbird.febs.server.hr.service.IEmpContractInfoService; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | import cc.mrbird.febs.common.core.constant.DicCode; |
| | | import cc.mrbird.febs.common.core.entity.system.Dept; |
| | | import cc.mrbird.febs.common.core.entity.system.DicItem; |
| | | import cc.mrbird.febs.common.core.utils.CastUtil; |
| | | import cc.mrbird.febs.common.redis.service.RedisService; |
| | | import cc.mrbird.febs.server.hr.entity.EmpPhysicalExam; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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 java.util.List; |
| | | import cc.mrbird.febs.common.core.constant.ModuleCode; |
| | | import cc.mrbird.febs.common.core.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.core.utils.FebsUtil; |
| | | import cc.mrbird.febs.common.core.utils.SequenceUtil; |
| | | import cc.mrbird.febs.server.hr.entity.EmpBaseInfo; |
| | | import cc.mrbird.febs.server.hr.entity.EmpContractInfo; |
| | | import cc.mrbird.febs.server.hr.mapper.EmpContractInfoMapper; |
| | | import cc.mrbird.febs.server.hr.service.IEmpContractInfoService; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | |
| | | /** |
| | | * |
| | | * name:EmpContractinfo |
| | | * package:cc.mrbird.febs.server.hr.controller |
| | | * description:员工合同信息服务接口实现 |
| | | * |
| | | * @author luoyibo |
| | | * @date 2021-01-24 20:35:42 |
| | | * @since JDK1.8 |
| | | */ |
| | | * name:EmpContractinfo |
| | | * package:cc.mrbird.febs.server.hr.controller |
| | | * description:员工合同信息服务接口实现 |
| | | * |
| | | * @author luoyibo |
| | | * @date 2021-01-31 11:28:23 |
| | | * @since JDK1.8 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) |
| | | public class EmpContractInfoServiceImpl extends ServiceImpl |
| | | <EmpContractInfoMapper, EmpContractInfo> implements IEmpContractInfoService { |
| | | class EmpContractInfoServiceImpl extends ServiceImpl<EmpContractInfoMapper, EmpContractInfo> implements IEmpContractInfoService { |
| | | |
| | | private final EmpContractInfoMapper empContractinfoMapper; |
| | | private final RedisService redisService; |
| | | private final EmpContractInfoMapper empContractinfoMapper; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()) |
| | | .map(u -> u.getUserId().toString()) |
| | | .orElse("1"); |
| | | |
| | | @Override |
| | | public IPage<EmpContractInfo> findEmpContractinfos(QueryRequest request, EmpContractInfo empContractinfo) { |
| | | LambdaQueryWrapper<EmpContractInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | // TODO 设置查询条件 |
| | | Page<EmpContractInfo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return this.page(page, queryWrapper); |
| | | } |
| | | @Override |
| | | public IPage<EmpContractInfo> findEmpContractinfos(QueryRequest request, EmpContractInfo empContractinfo) { |
| | | LambdaQueryWrapper<EmpContractInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(EmpContractInfo::getDelFlag, empContractinfo.getDelFlag()); |
| | | if (StringUtils.isNotBlank(empContractinfo.getEmpNumb())) { |
| | | queryWrapper.like(EmpContractInfo::getEmpNumb, empContractinfo.getEmpNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empContractinfo.getEmpName())) { |
| | | queryWrapper.like(EmpContractInfo::getEmpName, empContractinfo.getEmpName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empContractinfo.getCertificateNumb())) { |
| | | queryWrapper.like(EmpContractInfo::getCertificateNumb, empContractinfo.getCertificateNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empContractinfo.getDeptName())) { |
| | | queryWrapper.like(EmpContractInfo::getDeptName, empContractinfo.getDeptName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empContractinfo.getSigningDateStr())) { |
| | | queryWrapper.between(EmpContractInfo::getSigningDate, empContractinfo.getSigningDateStr().split(",")[0], empContractinfo.getSigningDateStr().split(",")[1]); |
| | | } |
| | | if (StringUtils.isNotBlank(empContractinfo.getEndDateStr())) { |
| | | queryWrapper.between(EmpContractInfo::getEndDate, empContractinfo.getEndDateStr().split(",")[0], empContractinfo.getEndDateStr().split(",")[1]); |
| | | } |
| | | if (StringUtils.isNotBlank(empContractinfo.getDeptName())) { |
| | | queryWrapper.like(EmpContractInfo::getEmpStatus, empContractinfo.getEmpStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(empContractinfo.getContractStatus())) { |
| | | queryWrapper.eq(EmpContractInfo::getContractStatus, empContractinfo.getContractStatus()); |
| | | } |
| | | Page<EmpContractInfo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | IPage<EmpContractInfo> iPage = this.page(page, queryWrapper); |
| | | List<EmpContractInfo> list = iPage.getRecords(); |
| | | //设置字典数据 |
| | | List<DicItem> dicItems = CastUtil.castList(redisService.get("dicItems"), DicItem.class); |
| | | list.forEach(p -> { |
| | | p.setContractStatusName(dicItems.stream() |
| | | .filter(k -> DicCode.CONTRACTSTATUS.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getContractStatus())) |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("新签")); |
| | | }); |
| | | iPage.setRecords(list); |
| | | return iPage; |
| | | } |
| | | |
| | | @Override |
| | | public List<EmpContractInfo> findEmpContractinfos(EmpContractInfo empContractinfo) { |
| | | LambdaQueryWrapper<EmpContractInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | // TODO 设置查询条件 |
| | | return this.baseMapper.selectList(queryWrapper); |
| | | } |
| | | @Override |
| | | public List<EmpContractInfo> findEmpContractinfos(EmpContractInfo empContractinfo) { |
| | | LambdaQueryWrapper<EmpContractInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(EmpContractInfo::getDelFlag, empContractinfo.getDelFlag()); |
| | | return this.baseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createEmpContractinfo(EmpContractInfo empContractinfo) { |
| | | this.save(empContractinfo); |
| | | } |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createEmpContractinfo(EmpContractInfo empContractinfo) { |
| | | empContractinfo.setContractId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | if (empContractinfo.getBeginDate() == null) { |
| | | empContractinfo.setBeginDate(empContractinfo.getSigningDate()); |
| | | } |
| | | empContractinfo.setCreator(operatorId); |
| | | empContractinfo.setModifier(operatorId); |
| | | this.save(empContractinfo); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateEmpContractinfo(EmpContractInfo empContractinfo) { |
| | | this.saveOrUpdate(empContractinfo); |
| | | } |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateEmpContractinfo(EmpContractInfo empContractinfo) { |
| | | EmpContractInfo dbData = this.getById(empContractinfo.getContractId()); |
| | | empContractinfo.setCreateTime(dbData.getCreateTime()); |
| | | empContractinfo.setCreator(dbData.getCreator()); |
| | | empContractinfo.setDelFlag(dbData.getDelFlag()); |
| | | empContractinfo.setModifyTime(new Date()); |
| | | empContractinfo.setModifier(operatorId); |
| | | this.saveOrUpdate(empContractinfo); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteEmpContractinfo(EmpContractInfo empContractinfo) { |
| | | LambdaQueryWrapper<EmpContractInfo> wapper = new LambdaQueryWrapper<>(); |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteEmpContractinfo(EmpContractInfo empContractinfo) { |
| | | LambdaQueryWrapper<EmpContractInfo> wrapper = new LambdaQueryWrapper<>(); |
| | | // TODO 设置删除条件 |
| | | this.remove(wapper); |
| | | } |
| | | } |
| | | this.remove(wrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据Id批量逻辑删除记录 |
| | | * <p> |
| | | * date 2021-01-28 10:48 |
| | | * |
| | | * @param ids 待删除Id |
| | | * @return void |
| | | * @author: luoyibo |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void logicDelEmpContractinfo(String ids) { |
| | | String[] str = ids.split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | empContractinfoMapper.logicDeleteByIds(list, operatorId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean momentToNormal(String ids) { |
| | | String[] str = ids.split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | return empContractinfoMapper.momentToNormal(list, operatorId) > 0; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importEmpContractInfo(List<List<Object>> listObject) { |
| | | for (List<Object> list : listObject) { |
| | | EmpContractInfo contractInfo = new EmpContractInfo(); |
| | | contractInfo.setContractId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | contractInfo.setEmpNumb(list.get(0).toString()); |
| | | List<Dept> depts = CastUtil.castList(redisService.get("depts"), Dept.class); |
| | | Long deptId = depts.stream().filter(d -> d.getDeptName().equals(list.get(1).toString())).findFirst().get() |
| | | .getDeptId(); |
| | | contractInfo.setDeptName(list.get(1).toString()); |
| | | contractInfo.setDeptId(deptId); |
| | | contractInfo.setJobName(list.get(2).toString()); |
| | | contractInfo.setEmpName(list.get(3).toString()); |
| | | contractInfo.setCertificateNumb(list.get(4).toString()); |
| | | if (StringUtils.isNotBlank(list.get(5).toString())) { |
| | | contractInfo.setSigningDate(DateUtil.parseDate(list.get(5).toString())); |
| | | } |
| | | if (StringUtils.isNotBlank(list.get(6).toString())) { |
| | | contractInfo.setEndDate(DateUtil.parseDate(list.get(6).toString())); |
| | | } |
| | | if (StringUtils.isNotBlank(list.get(7).toString())) { |
| | | contractInfo.setContractPeriod(Integer.valueOf(list.get(7).toString())); |
| | | } |
| | | contractInfo.setContractStatus(list.get(8).toString()); |
| | | contractInfo.setTransactor(list.get(9).toString()); |
| | | contractInfo.setRemark(list.get(10).toString()); |
| | | this.save(contractInfo); |
| | | } |
| | | } |
| | | } |