| | |
| | | package cc.mrbird.febs.server.hr.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.core.constant.ModuleCode; |
| | | import cc.mrbird.febs.common.core.entity.system.DicItem; |
| | | import cc.mrbird.febs.common.core.exception.FebsException; |
| | | import cc.mrbird.febs.server.hr.constant.MyConstant; |
| | | import cc.mrbird.febs.server.hr.entity.EmpBaseInfo; |
| | | import cc.mrbird.febs.server.hr.entity.EmpInsurance; |
| | | import cc.mrbird.febs.server.hr.entity.EmpUnemployment; |
| | | import cc.mrbird.febs.server.hr.feign.IRemoteDeptService; |
| | | import cc.mrbird.febs.server.hr.entity.EmpInsurance; |
| | | import cc.mrbird.febs.server.hr.mapper.EmpInsuranceMapper; |
| | | import cc.mrbird.febs.server.hr.service.IEmpBaseInfoService; |
| | | import cc.mrbird.febs.server.hr.service.IEmpInsuranceService; |
| | | 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 org.springframework.transaction.annotation.Propagation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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 cc.mrbird.febs.common.core.entity.constant.StringConstant; |
| | | 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.*; |
| | | |
| | | /** |
| | | * name:EmpInsurance |
| | | * package:cc.mrbird.febs.server.hr.controller |
| | | * name:EmpInsurance package:cc.mrbird.febs.server.hr.controller |
| | | * description:员工社保申请服务接口实现 |
| | | * |
| | | * @author luoyibo |
| | |
| | | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) |
| | | class EmpInsuranceServiceImpl extends ServiceImpl<EmpInsuranceMapper, EmpInsurance> implements IEmpInsuranceService { |
| | | |
| | | private final RedisService redisService; |
| | | private final EmpInsuranceMapper empInsuranceMapper; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()) |
| | | .map(u -> u.getUserId().toString()) |
| | | private final IEmpBaseInfoService empBaseInfoService; |
| | | private final IRemoteDeptService remoteDeptService; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()).map(u -> u.getUserId().toString()) |
| | | .orElse("1"); |
| | | |
| | | @Override |
| | | public IPage<EmpInsurance> findEmpInsurances(QueryRequest request, EmpInsurance empInsurance) { |
| | | LambdaQueryWrapper<EmpInsurance> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(EmpInsurance::getDelFlag, empInsurance.getDelFlag()); |
| | | QueryWrapper<EmpInsurance> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("a.DelFlag", empInsurance.getDelFlag()); |
| | | if (StringUtils.isNotBlank(empInsurance.getEmpNumb())) { |
| | | queryWrapper.like("a.EmpNumb", empInsurance.getEmpNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empInsurance.getEmpName())) { |
| | | queryWrapper.like("a.EmpName", empInsurance.getEmpName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empInsurance.getCertificateNumb())) { |
| | | queryWrapper.like("a.CertificateNumb", empInsurance.getCertificateNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empInsurance.getDeptName())) { |
| | | queryWrapper.like("a.DeptName", empInsurance.getDeptName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empInsurance.getApplayDateStr())) { |
| | | queryWrapper.between("a.ApplayDate", empInsurance.getApplayDateStr().split(",")[0], |
| | | empInsurance.getApplayDateStr().split(",")[1]); |
| | | } |
| | | if (StringUtils.isNotBlank(empInsurance.getInsuranceGaers())) { |
| | | queryWrapper.eq("a.InsuranceGaers", empInsurance.getInsuranceGaers()); |
| | | } |
| | | if (empInsurance.getReportStatus() != null && empInsurance.getReportStatus() != 0) { |
| | | queryWrapper.eq("a.ReportStatus", empInsurance.getReportStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(empInsurance.getEmpStatus())) { |
| | | queryWrapper.in("a.EmpStatus", empInsurance.getEmpStatus().split(",")); |
| | | } |
| | | queryWrapper.in("c.dept_Id", remoteDeptService.userRightDepts().split(StringConstant.COMMA)); |
| | | Page<EmpInsurance> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return this.page(page, queryWrapper); |
| | | return empInsuranceMapper.selectPageVo(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createEmpInsurance(EmpInsurance empInsurance) { |
| | | public void createEmpInsurance(EmpInsurance empInsurance) throws FebsException { |
| | | LambdaQueryWrapper<EmpInsurance> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(EmpInsurance::getEmpId, empInsurance.getEmpId()); |
| | | lambdaQueryWrapper.eq(EmpInsurance::getApplayDate, empInsurance.getApplayDate()); |
| | | lambdaQueryWrapper.ne(EmpInsurance::getDelFlag, 1); |
| | | if (this.count(lambdaQueryWrapper) > 0) { |
| | | throw new FebsException(MyConstant.MESSAGE); |
| | | } |
| | | empInsurance.setInsuranceId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | empInsurance.setCreator(operatorId); |
| | | empInsurance.setModifier(operatorId); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateEmpInsurance(EmpInsurance empInsurance) { |
| | | public void updateEmpInsurance(EmpInsurance empInsurance) throws FebsException { |
| | | LambdaQueryWrapper<EmpInsurance> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(EmpInsurance::getEmpId, empInsurance.getEmpId()); |
| | | lambdaQueryWrapper.eq(EmpInsurance::getApplayDate, empInsurance.getApplayDate()); |
| | | lambdaQueryWrapper.ne(EmpInsurance::getDelFlag, 1); |
| | | lambdaQueryWrapper.ne(EmpInsurance::getInsuranceId,empInsurance.getInsuranceId()); |
| | | if (this.count(lambdaQueryWrapper) > 0) { |
| | | throw new FebsException(MyConstant.MESSAGE); |
| | | } |
| | | EmpInsurance dbData = this.getById(empInsurance.getInsuranceId()); |
| | | empInsurance.setCreateTime(dbData.getCreateTime()); |
| | | empInsurance.setCreator(dbData.getCreator()); |
| | |
| | | public boolean momentToNormal(String ids) { |
| | | String[] str = ids.split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | return empInsuranceMapper.momentToNormal(list, operatorId)>0; |
| | | return empInsuranceMapper.momentToNormal(list, operatorId) > 0; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importEmpInsurance(List<List<Object>> listObject,List<String> returnList, List<DicItem> dicItems) { |
| | | for (List<Object> list : listObject) { |
| | | if (list.size()==0){ |
| | | continue; |
| | | } |
| | | EmpInsurance empInsurance = new EmpInsurance(); |
| | | empInsurance.setInsuranceId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | empInsurance.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; |
| | | } |
| | | EmpBaseInfo empBaseInfo = empBaseInfoService.getEmpBaseInfoByEmpNumb(list.get(0).toString()); |
| | | if (null == empBaseInfo){ |
| | | returnList.add(StrUtil.format("导入社保申请服务异常: 出现位置第{}行, 原因:{}员工编号不存在",listObject.indexOf(list)+1,list.get(0).toString())); |
| | | continue; |
| | | } |
| | | empInsurance.setDelFlag(2); |
| | | empInsurance.setEmpId(empBaseInfo.getEmpId()); |
| | | empInsurance.setDeptName(list.get(1).toString()); |
| | | empInsurance.setDeptId(dept.getDeptId()); |
| | | empInsurance.setJobName(list.get(2).toString()); |
| | | empInsurance.setEmpName(list.get(3).toString()); |
| | | empInsurance.setCertificateNumb(list.get(4).toString()); |
| | | if (StringUtils.isNotBlank(list.get(5).toString())) { |
| | | empInsurance.setApplayDate(DateUtil.parseDate(list.get(5).toString())); |
| | | } |
| | | empInsurance.setProposer(list.get(6).toString()); |
| | | //婚姻状况 |
| | | DicItem dicItem =dicItems.parallelStream().filter(j->StrUtil.equalsIgnoreCase(j.getDicCode(),"insuranceGaers")&&StrUtil.equals(j.getDicItemName(),list.get(7).toString())).findFirst().orElse(null); |
| | | if (null!=dicItem){ |
| | | empInsurance.setInsuranceGaers(dicItem.getDicItemCode()); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(list.get(8).toString())) { |
| | | empInsurance.setReportStatus("未报告".equals(list.get(8).toString()) ? 0 : 1); |
| | | } |
| | | if (StringUtils.isNotBlank(list.get(8).toString())) { |
| | | empInsurance.setApplayStatus("未申请".equals(list.get(8).toString()) ? 0 : 1); |
| | | } |
| | | empInsurance.setAuditor(list.get(9).toString()); |
| | | empInsurance.setRemark(list.get(10).toString()); |
| | | empInsurance.setEmpStatus(empBaseInfo.getEmpStatus()); |
| | | this.save(empInsurance); |
| | | } |
| | | } |
| | | } |