| | |
| | | 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 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"); |
| | |
| | | iPage.setRecords(list); |
| | | return iPage; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IPage<EmpBaseInfo> findZsEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) { |
| | | LambdaQueryWrapper<EmpBaseInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | } 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; |
| | | } |
| | | } |
| | | } |