| | |
| | | package cc.mrbird.febs.server.hr.service.impl; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.util.*; |
| | | import java.util.function.Consumer; |
| | | |
| | | import cc.mrbird.febs.common.core.entity.system.SysConfig; |
| | | import cc.mrbird.febs.common.core.utils.MyUtil; |
| | | import cc.mrbird.febs.server.hr.entity.EmpDimissionLog; |
| | | import cc.mrbird.febs.server.hr.entity.EmpJobChange; |
| | | import cc.mrbird.febs.server.hr.properties.FebsServerHrProperties; |
| | | import cc.mrbird.febs.server.hr.service.IEmpDimissionLogService; |
| | | import cc.mrbird.febs.server.hr.service.IEmpJobChangeService; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cc.mrbird.febs.server.hr.entity.*; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | |
| | | import cc.mrbird.febs.server.hr.mapper.EmpBaseInfoMapper; |
| | | import cc.mrbird.febs.server.hr.service.IEmpBaseInfoService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.util.FileSystemUtils; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * name:EmpBaseinfo |
| | |
| | | private final EmpBaseInfoMapper empBaseInfoMapper; |
| | | private final IEmpDimissionLogService dimissionLogService; |
| | | private final IEmpJobChangeService jobChangeService; |
| | | |
| | | private final FebsServerHrProperties properties; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()) |
| | | .map(u -> u.getUserId().toString()) |
| | | .orElse("1"); |
| | |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getPolitics())) { |
| | | queryWrapper.like(EmpBaseInfo::getPolitics, empBaseInfo.getPolitics()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpStatus())) { |
| | | queryWrapper.in(EmpBaseInfo::getEmpStatus, empBaseInfo.getEmpStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getAgeStr())) { |
| | | queryWrapper.between(EmpBaseInfo::getAge, empBaseInfo.getAgeStr().split(",")[0], empBaseInfo.getAgeStr().split(",")[1]); |
| | |
| | | iPage.setRecords(list); |
| | | return iPage; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IPage<EmpBaseInfo> findZsEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) { |
| | | LambdaQueryWrapper<EmpBaseInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | if (StringUtils.isNotBlank(empBaseInfo.getPolitics())) { |
| | | queryWrapper.in(EmpBaseInfo::getPolitics, empBaseInfo.getPolitics().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getAgeStr())) { |
| | | String[] ages=empBaseInfo.getAgeStr().split(","); |
| | | for (int i = 0; i < ages.length; i++) { |
| | | String ageBtn=ages[i]; |
| | | queryWrapper.between(EmpBaseInfo::getAge, ageBtn.split("-")[0], ageBtn.split("-")[1]); |
| | | } |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getAgeStr())) { |
| | | String[] ages = empBaseInfo.getAgeStr().split(","); |
| | | Consumer<LambdaQueryWrapper<EmpBaseInfo>> consumer = new Consumer<LambdaQueryWrapper<EmpBaseInfo>>() { |
| | | @Override |
| | | public void accept(LambdaQueryWrapper<EmpBaseInfo> wrapper) { |
| | | for (int i = 0; i < ages.length; i++) { |
| | | String ageBtn = ages[i]; |
| | | wrapper.or().between(EmpBaseInfo::getAge, ageBtn.split("-")[0], ageBtn.split("-")[1]); |
| | | } |
| | | } |
| | | }; |
| | | queryWrapper.and(consumer); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getArchivesStatus())) { |
| | | queryWrapper.in(EmpBaseInfo::getArchivesStatus, empBaseInfo.getArchivesStatus().split(",")); |
| | | } |
| | |
| | | List<DicItem> dicItems = CastUtil.castList(redisService.get("dicItems"), DicItem.class); |
| | | list.forEach(p -> { |
| | | p.setSexName("1".equals(p.getSex()) ? "男" : "女"); |
| | | p.setEmpTypeName("1".equals(p.getEmpType()) ? "正式工" : "临时工"); |
| | | p.setInsuranceTypeName("1".equals(p.getInsuranceType()) ? "(深户)五险一档" : "(非深户)五险一档"); |
| | | p.setArchivesStatusName("0".equals(p.getArchivesStatus()) ? "未移交" : "已移交"); |
| | | //保险类型 |
| | | p.setInsuranceTypeName(dicItems.stream() |
| | | .filter(k -> DicCode.INSURANCETYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getInsuranceType())) |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("汉族")); |
| | | //员工类别 |
| | | p.setEmpTypeName(dicItems.stream() |
| | | .filter(k -> DicCode.EMPTYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getEmpType())) |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("汉族")); |
| | | // 设置民族 |
| | | p.setNationName(dicItems.stream() |
| | | .filter(k -> DicCode.NATION.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getNation())) |
| | |
| | | } else{ |
| | | empBaseInfo.setEmpId(dbInfo.getEmpId()); |
| | | } |
| | | if (StrUtil.isNotBlank(empBaseInfo.getImagePath())){ |
| | | String path = properties.getEmpBaseInfoPath()+empBaseInfo.getEmpId()+".png"; |
| | | if ( MyUtil.generateImage(empBaseInfo.getImagePath(),path)) { |
| | | empBaseInfo.setImagePath(empBaseInfo.getEmpId()+".png"); |
| | | }; |
| | | } |
| | | empBaseInfo.setCreator(operatorId); |
| | | empBaseInfo.setModifier(operatorId); |
| | | this.saveOrUpdate(empBaseInfo); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateEmpBaseInfo(EmpBaseInfo empBaseInfo) { |
| | | if (StrUtil.isNotBlank(empBaseInfo.getImagePath())){ |
| | | String path = properties.getEmpBaseInfoPath()+empBaseInfo.getEmpId()+".png"; |
| | | if ( MyUtil.generateImage(empBaseInfo.getImagePath(),path)) { |
| | | empBaseInfo.setImagePath(empBaseInfo.getEmpId()+".png"); |
| | | } |
| | | |
| | | } |
| | | EmpBaseInfo dbData = this.getById(empBaseInfo.getEmpId()); |
| | | empBaseInfo.setCreateTime(dbData.getCreateTime()); |
| | | empBaseInfo.setCreator(dbData.getCreator()); |
| | |
| | | if (tempEmpBaseInfo == null) { |
| | | return false; |
| | | } |
| | | return !empBaseInfo.getEmpId().equals(tempEmpBaseInfo.getEmpId()); |
| | | return !empBaseInfo.getEmpNumb().equals(tempEmpBaseInfo.getEmpNumb()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | this.save(empBaseInfo); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void getImage(String empId, HttpServletResponse response) throws Exception { |
| | | EmpBaseInfo empBaseInfo = this.getById(empId); |
| | | if (StrUtil.isBlank(empBaseInfo.getImagePath())){ |
| | | return; |
| | | } |
| | | String path = properties.getEmpBaseInfoPath()+empBaseInfo.getEmpId()+".png"; |
| | | try (InputStream inputStream = new FileInputStream(path); OutputStream out = response.getOutputStream()) { |
| | | |
| | | //byte数组用于存放图片字节数据 |
| | | byte[] buff = new byte[inputStream.available()]; |
| | | |
| | | inputStream.read(buff); |
| | | inputStream.close(); |
| | | |
| | | //设置发送到客户端的响应内容类型 |
| | | response.setContentType("image/png"); |
| | | |
| | | out.write(buff); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | return stringObjectMap; |
| | | } |
| | | } |
| | | } |