|
@@ -1,6 +1,8 @@
|
|
package com.jeeplus.human.enrollment.enrollmentRegistration.service;
|
|
package com.jeeplus.human.enrollment.enrollmentRegistration.service;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -18,7 +20,6 @@ import com.jeeplus.common.SecurityUtils;
|
|
import com.jeeplus.common.TokenProvider;
|
|
import com.jeeplus.common.TokenProvider;
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
import com.jeeplus.flowable.feign.IFlowableApi;
|
|
import com.jeeplus.flowable.feign.IFlowableApi;
|
|
-import com.jeeplus.human.depart.handover.domain.HandoverSocialSecurity;
|
|
|
|
import com.jeeplus.human.enrollment.enrollmentRegistration.domain.*;
|
|
import com.jeeplus.human.enrollment.enrollmentRegistration.domain.*;
|
|
import com.jeeplus.human.enrollment.enrollmentRegistration.mapper.EnrollmentRegistrationMapper;
|
|
import com.jeeplus.human.enrollment.enrollmentRegistration.mapper.EnrollmentRegistrationMapper;
|
|
import com.jeeplus.human.enrollment.enrollmentRegistration.mapper.EnrollmentSocialSecurityCardMapper;
|
|
import com.jeeplus.human.enrollment.enrollmentRegistration.mapper.EnrollmentSocialSecurityCardMapper;
|
|
@@ -37,9 +38,17 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.*;
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
+import java.nio.file.Path;
|
|
|
|
+import java.nio.file.Paths;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
+import java.util.zip.ZipEntry;
|
|
|
|
+import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author 王强
|
|
* @author 王强
|
|
@@ -679,39 +688,39 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
|
|
|
|
|
|
String userId = info.getUserId();
|
|
String userId = info.getUserId();
|
|
//查询教育经历数据
|
|
//查询教育经历数据
|
|
- List<EnrollmentEduInfo> eduInfoList = eduInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentEduInfo> eduInfoList = eduInfoService.findByUserId(userId, "5");
|
|
info.setEduInfoList(eduInfoList);
|
|
info.setEduInfoList(eduInfoList);
|
|
|
|
|
|
//查询工作经历数据
|
|
//查询工作经历数据
|
|
- List<EnrollmentWorkInfo> workInfos = workInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentWorkInfo> workInfos = workInfoService.findByUserId(userId, "5");
|
|
info.setWorkInfoList(workInfos);
|
|
info.setWorkInfoList(workInfos);
|
|
|
|
|
|
//查询培训经历数据
|
|
//查询培训经历数据
|
|
- List<EnrollmentTrainingInfo> trainingInfos = trainingInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentTrainingInfo> trainingInfos = trainingInfoService.findByUserId(userId, "5");
|
|
info.setTrainingInfoList(trainingInfos);
|
|
info.setTrainingInfoList(trainingInfos);
|
|
|
|
|
|
//查询资质证书数据
|
|
//查询资质证书数据
|
|
- List<EnrollmentCertificateInfo> certificateInfoList = certificateInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentCertificateInfo> certificateInfoList = certificateInfoService.findByUserId(userId, "5");
|
|
info.setCertificateInfoList(certificateInfoList);
|
|
info.setCertificateInfoList(certificateInfoList);
|
|
|
|
|
|
//查询专业技能数据
|
|
//查询专业技能数据
|
|
- List<EnrollmentSkillInfo> skillInfoList = skillInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentSkillInfo> skillInfoList = skillInfoService.findByUserId(userId, "5");
|
|
info.setSkillInfoList(skillInfoList);
|
|
info.setSkillInfoList(skillInfoList);
|
|
|
|
|
|
//查询语言能力数据
|
|
//查询语言能力数据
|
|
- List<EnrollmentLanguageInfo> languageInfoList = languageInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentLanguageInfo> languageInfoList = languageInfoService.findByUserId(userId, "5");
|
|
info.setLanguageInfoList(languageInfoList);
|
|
info.setLanguageInfoList(languageInfoList);
|
|
|
|
|
|
//查询家庭成员数据
|
|
//查询家庭成员数据
|
|
- List<EnrollmentFamilyInfo> familyInfoList = familyInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentFamilyInfo> familyInfoList = familyInfoService.findByUserId(userId, "5");
|
|
info.setFamilyInfoList(familyInfoList);
|
|
info.setFamilyInfoList(familyInfoList);
|
|
|
|
|
|
//查询奖项信息
|
|
//查询奖项信息
|
|
- List<EnrollmentRewardInfo> rewardInfoList = rewardInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentRewardInfo> rewardInfoList = rewardInfoService.findByUserId(userId, "5");
|
|
info.setRewardInfoList(rewardInfoList);
|
|
info.setRewardInfoList(rewardInfoList);
|
|
|
|
|
|
//查询劳动合同
|
|
//查询劳动合同
|
|
- List<EnrollmentLaborContractInfo> laborContractInfoList = laborContractInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentLaborContractInfo> laborContractInfoList = laborContractInfoService.findByUserId(userId, "5");
|
|
info.setLaborContractInfoList(laborContractInfoList);
|
|
info.setLaborContractInfoList(laborContractInfoList);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -765,7 +774,7 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
|
|
info.setRewardInfoList(rewardInfoList);
|
|
info.setRewardInfoList(rewardInfoList);
|
|
|
|
|
|
//查询劳动合同
|
|
//查询劳动合同
|
|
- List<EnrollmentLaborContractInfo> laborContractInfoList = laborContractInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentLaborContractInfo> laborContractInfoList = laborContractInfoService.findByUserId(userId, "5");
|
|
info.setLaborContractInfoList(laborContractInfoList);
|
|
info.setLaborContractInfoList(laborContractInfoList);
|
|
}
|
|
}
|
|
return info;
|
|
return info;
|
|
@@ -847,7 +856,7 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
|
|
info.setRewardInfoList(rewardInfoList);
|
|
info.setRewardInfoList(rewardInfoList);
|
|
|
|
|
|
//查询劳动合同
|
|
//查询劳动合同
|
|
- List<EnrollmentLaborContractInfo> laborContractInfoList = laborContractInfoService.findByUserId(userId,"5");
|
|
|
|
|
|
+ List<EnrollmentLaborContractInfo> laborContractInfoList = laborContractInfoService.findByUserId(userId, "5");
|
|
info.setLaborContractInfoList(laborContractInfoList);
|
|
info.setLaborContractInfoList(laborContractInfoList);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -965,10 +974,10 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
|
|
String id = UUID.randomUUID().toString().replace("-", "");
|
|
String id = UUID.randomUUID().toString().replace("-", "");
|
|
BeanUtils.copyProperties(registrationData, enrollmentUserInfoAudit);
|
|
BeanUtils.copyProperties(registrationData, enrollmentUserInfoAudit);
|
|
enrollmentUserInfoAudit.setStatus("2");
|
|
enrollmentUserInfoAudit.setStatus("2");
|
|
- if(!"4".equals(registrationData.getStatus())){
|
|
|
|
|
|
+ if (!"4".equals(registrationData.getStatus())) {
|
|
enrollmentUserInfoAudit.setId(id);
|
|
enrollmentUserInfoAudit.setId(id);
|
|
enrollmentUserInfoAudit.setRegistrationId(registrationData.getId());
|
|
enrollmentUserInfoAudit.setRegistrationId(registrationData.getId());
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
enrollmentUserInfoAudit.setId(registrationData.getId());
|
|
enrollmentUserInfoAudit.setId(registrationData.getId());
|
|
enrollmentUserInfoAudit.setRegistrationId(registrationData.getRegistrationId());
|
|
enrollmentUserInfoAudit.setRegistrationId(registrationData.getRegistrationId());
|
|
}
|
|
}
|
|
@@ -990,13 +999,13 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
|
|
allMap.put("员工信息审批", newMap);
|
|
allMap.put("员工信息审批", newMap);
|
|
SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
|
|
SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
|
|
|
|
|
|
- if(!"4".equals(registrationData.getStatus())){
|
|
|
|
|
|
+ if (!"4".equals(registrationData.getStatus())) {
|
|
IWorkAttachmentApi workAttachmentApi = SpringUtil.getBean(IWorkAttachmentApi.class);
|
|
IWorkAttachmentApi workAttachmentApi = SpringUtil.getBean(IWorkAttachmentApi.class);
|
|
SpringUtil.getBean(IWorkAttachmentApi.class).deleteByAttachmentId(enrollmentUserInfoAudit.getId());
|
|
SpringUtil.getBean(IWorkAttachmentApi.class).deleteByAttachmentId(enrollmentUserInfoAudit.getId());
|
|
saveAttachments(enrollmentUserInfoAudit.getIdCardFront(), "idCardFront", enrollmentUserInfoAudit.getId(), userDTO, workAttachmentApi);
|
|
saveAttachments(enrollmentUserInfoAudit.getIdCardFront(), "idCardFront", enrollmentUserInfoAudit.getId(), userDTO, workAttachmentApi);
|
|
saveAttachments(enrollmentUserInfoAudit.getIdCardBack(), "idCardBack", enrollmentUserInfoAudit.getId(), userDTO, workAttachmentApi);
|
|
saveAttachments(enrollmentUserInfoAudit.getIdCardBack(), "idCardBack", enrollmentUserInfoAudit.getId(), userDTO, workAttachmentApi);
|
|
saveEnrollmentDetailInfo(registrationData);
|
|
saveEnrollmentDetailInfo(registrationData);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
updateEnrollmentDetailInfo(registrationData);
|
|
updateEnrollmentDetailInfo(registrationData);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -1615,4 +1624,337 @@ public class EnrollmentRegistrationService extends ServiceImpl<EnrollmentRegistr
|
|
mapper.updateDdIdById(registration);
|
|
mapper.updateDdIdById(registration);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ public List<EnrollmentRegistration> getUserInfoByIds(List<String> ids, String type) {
|
|
|
|
+ List<EnrollmentRegistration> enrollmentRegistrations = new ArrayList<>();
|
|
|
|
+ for (String id : ids) {
|
|
|
|
+ EnrollmentRegistration info = mapper.getById(id);
|
|
|
|
+ if (ObjectUtil.isNotEmpty(info)) {
|
|
|
|
+ String userId = info.getUserId();
|
|
|
|
+ switch (type) {
|
|
|
|
+ case "1"://身份证
|
|
|
|
+ List<WorkAttachmentInfoDTO> idCardFront = mapper.findDtos(info.getIdCard(), "idCardFront");
|
|
|
|
+ List<WorkAttachmentInfoDTO> idCardBack = mapper.findDtos(info.getIdCard(), "idCardBack");
|
|
|
|
+ if (CollectionUtils.isNotEmpty(idCardFront)) {
|
|
|
|
+ info.setIdCardFront(idCardFront);
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isNotEmpty(idCardBack)) {
|
|
|
|
+ info.setIdCardBack(idCardBack);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "2"://学历
|
|
|
|
+ case "3"://学位
|
|
|
|
+ List<EnrollmentEduInfo> eduInfoList = eduInfoService.findByUserId(userId, "5");
|
|
|
|
+ info.setEduInfoList(eduInfoList);
|
|
|
|
+ break;
|
|
|
|
+ case "4"://培训
|
|
|
|
+ List<EnrollmentTrainingInfo> trainingInfos = trainingInfoService.findByUserId(userId, "5");
|
|
|
|
+ info.setTrainingInfoList(trainingInfos);
|
|
|
|
+ break;
|
|
|
|
+ case "5"://资质
|
|
|
|
+ List<EnrollmentCertificateInfo> certificateInfoList = certificateInfoService.findByUserId(userId, "5");
|
|
|
|
+ info.setCertificateInfoList(certificateInfoList);
|
|
|
|
+ break;
|
|
|
|
+ case "6"://技能
|
|
|
|
+ List<EnrollmentSkillInfo> skillInfoList = skillInfoService.findByUserId(userId, "5");
|
|
|
|
+ info.setSkillInfoList(skillInfoList);
|
|
|
|
+ break;
|
|
|
|
+ case "7"://语言
|
|
|
|
+ List<EnrollmentLanguageInfo> languageInfoList = languageInfoService.findByUserId(userId, "5");
|
|
|
|
+ info.setLanguageInfoList(languageInfoList);
|
|
|
|
+ break;
|
|
|
|
+ case "8"://表彰
|
|
|
|
+ List<EnrollmentRewardInfo> rewardInfoList = rewardInfoService.findByUserId(userId, "5");
|
|
|
|
+ info.setRewardInfoList(rewardInfoList);
|
|
|
|
+ break;
|
|
|
|
+ case "9"://劳动合同
|
|
|
|
+ List<EnrollmentLaborContractInfo> laborContractInfoList = laborContractInfoService.findByUserId(userId, "5");
|
|
|
|
+ info.setLaborContractInfoList(laborContractInfoList);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ enrollmentRegistrations.add(info);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return enrollmentRegistrations;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量下载附件压缩包
|
|
|
|
+ *
|
|
|
|
+ * @param ids
|
|
|
|
+ * @param attachmentType
|
|
|
|
+ * @param response
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public void downloadAttachmentByUserIds(List<String> ids, String attachmentType, HttpServletResponse response) throws Exception {
|
|
|
|
+ //根据id获取用户信息
|
|
|
|
+ List<EnrollmentRegistration> enrollmentRegistrations = getUserInfoByIds(ids, attachmentType);
|
|
|
|
+ if (enrollmentRegistrations.isEmpty()) {
|
|
|
|
+ response.reset();
|
|
|
|
+ response.setContentType("application/json;charset=UTF-8");
|
|
|
|
+ response.setStatus(HttpServletResponse.SC_OK); // 可选
|
|
|
|
+ response.getWriter().write("{\"code\":400,\"msg\":\"所选用户未查询到附件信息,无法下载\"}");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 临时路径
|
|
|
|
+ String baseDir = "";
|
|
|
|
+ if (System.getProperty("os.name").toLowerCase().contains("win")) {
|
|
|
|
+ baseDir = "D:\\attachment-file";
|
|
|
|
+ } else {
|
|
|
|
+ baseDir = "/attachment-file/";
|
|
|
|
+ }
|
|
|
|
+ String tempDir = baseDir + File.separator + UUID.randomUUID();
|
|
|
|
+ String zipPath = baseDir + File.separator + UUID.randomUUID() + ".zip";
|
|
|
|
+ // 创建文件结构
|
|
|
|
+ generateUserEducationFiles(enrollmentRegistrations, tempDir, attachmentType);
|
|
|
|
+ // 压缩
|
|
|
|
+ zipFolder(tempDir, zipPath);
|
|
|
|
+ File zipFile = new File(zipPath);
|
|
|
|
+ // 检查是否为空
|
|
|
|
+ if (!zipFile.exists() || zipFile.length() == 0 || zipFile.length() == 22) {
|
|
|
|
+ // 清理目录和空文件
|
|
|
|
+ FileUtil.del(tempDir);
|
|
|
|
+ zipFile.delete();
|
|
|
|
+ response.reset();
|
|
|
|
+ response.setContentType("application/json;charset=UTF-8");
|
|
|
|
+ response.setStatus(HttpServletResponse.SC_OK);
|
|
|
|
+ response.getWriter().write("{\"code\":400,\"msg\":\"所选用户未查询到附件信息,无法下载\"}");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 设置响应头并输出流
|
|
|
|
+ response.setContentType("application/zip");
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=file.zip");
|
|
|
|
+ response.setContentLength((int) zipFile.length());
|
|
|
|
+
|
|
|
|
+ // 写入输出流
|
|
|
|
+ try (FileInputStream fis = new FileInputStream(zipFile);
|
|
|
|
+ BufferedInputStream bis = new BufferedInputStream(fis);
|
|
|
|
+ ServletOutputStream sos = response.getOutputStream()) {
|
|
|
|
+
|
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
|
+ int bytesRead;
|
|
|
|
+ while ((bytesRead = bis.read(buffer, 0, 1024)) != -1) {
|
|
|
|
+ sos.write(buffer, 0, bytesRead);
|
|
|
|
+ }
|
|
|
|
+ sos.flush();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 删除临时目录和 zip 文件
|
|
|
|
+ FileUtil.del(tempDir);
|
|
|
|
+ zipFile.delete();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 数据处理逻辑
|
|
|
|
+ *
|
|
|
|
+ * @param userList
|
|
|
|
+ * @param rootPath
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public void generateUserEducationFiles(List<EnrollmentRegistration> userList, String rootPath, String type) throws IOException {
|
|
|
|
+ for (EnrollmentRegistration user : userList) {
|
|
|
|
+ String userDir = rootPath + File.separator + user.getName();
|
|
|
|
+ Files.createDirectories(Paths.get(userDir));
|
|
|
|
+ switch (type) {
|
|
|
|
+ case "1"://身份证
|
|
|
|
+ if (CollUtil.isNotEmpty(user.getIdCardFront())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO idFront : user.getIdCardFront()) {
|
|
|
|
+ String fileName = "身份证正面." + FileUtil.extName(idFront.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(idFront);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isNotEmpty(user.getIdCardBack())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO idBack : user.getIdCardBack()) {
|
|
|
|
+ String fileName = "身份证反面." + FileUtil.extName(idBack.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(idBack);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "2"://学历
|
|
|
|
+ for (EnrollmentEduInfo info : user.getEduInfoList()) {
|
|
|
|
+ if (CollUtil.isNotEmpty(info.getEducationFile())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO file : info.getEducationFile()) {
|
|
|
|
+ String fileName = info.getGraduatedFrom() + "." + FileUtil.extName(file.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(file);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "3"://学位
|
|
|
|
+ for (EnrollmentEduInfo info : user.getEduInfoList()) {
|
|
|
|
+ if (CollUtil.isNotEmpty(info.getDegreeFile())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO file : info.getDegreeFile()) {
|
|
|
|
+ String fileName = info.getGraduatedFrom() + "." + FileUtil.extName(file.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(file);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "4"://培训
|
|
|
|
+ for (EnrollmentTrainingInfo info : user.getTrainingInfoList()) {
|
|
|
|
+ if (CollUtil.isNotEmpty(info.getFiles())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO file : info.getFiles()) {
|
|
|
|
+ String fileName = info.getName() + "." + FileUtil.extName(file.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(file);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "5"://资质
|
|
|
|
+ for (EnrollmentCertificateInfo info : user.getCertificateInfoList()) {
|
|
|
|
+ if (CollUtil.isNotEmpty(info.getCertificateAttachment())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO file : info.getCertificateAttachment()) {
|
|
|
|
+ String sysCertType = SpringUtil.getBean(IDictApi.class).getDictLabel(info.getType(), "sys_cert_type", "文件");
|
|
|
|
+ String fileName = sysCertType + "." + FileUtil.extName(file.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(file);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "6"://技能
|
|
|
|
+ for (EnrollmentSkillInfo info : user.getSkillInfoList()) {
|
|
|
|
+ if (CollUtil.isNotEmpty(info.getFiles())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO file : info.getFiles()) {
|
|
|
|
+ String fileName = info.getName() + "." + FileUtil.extName(file.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(file);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "7"://语言
|
|
|
|
+ for (EnrollmentLanguageInfo info : user.getLanguageInfoList()) {
|
|
|
|
+ if (CollUtil.isNotEmpty(info.getFiles())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO file : info.getFiles()) {
|
|
|
|
+ String fileName = info.getLanguage() + "." + FileUtil.extName(file.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(file);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "8"://表彰
|
|
|
|
+ for (EnrollmentRewardInfo info : user.getRewardInfoList()) {
|
|
|
|
+ if (CollUtil.isNotEmpty(info.getFiles())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO file : info.getFiles()) {
|
|
|
|
+ String fileName = info.getName() + "." + FileUtil.extName(file.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(file);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "9"://劳动合同
|
|
|
|
+ for (EnrollmentLaborContractInfo info : user.getLaborContractInfoList()) {
|
|
|
|
+ if (CollUtil.isNotEmpty(info.getFiles())) {
|
|
|
|
+ for (WorkAttachmentInfoDTO file : info.getFiles()) {
|
|
|
|
+ String typeName = SpringUtil.getBean(IDictApi.class).getDictLabel(info.getType(), "labor_contract_type", "文件");
|
|
|
|
+ String fileName = typeName + "." + FileUtil.extName(file.getName());
|
|
|
|
+ byte[] fileContent = downloadFile(file);
|
|
|
|
+ if (fileContent != null) {
|
|
|
|
+ Path filePath = Paths.get(userDir, fileName);
|
|
|
|
+ Files.write(filePath, fileContent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 下载到本地
|
|
|
|
+ *
|
|
|
|
+ * @param workattachment
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public byte[] downloadFile(WorkAttachmentInfoDTO workattachment) throws IOException {
|
|
|
|
+ String aliyunUrl = "http://cdn.gangwaninfo.com";
|
|
|
|
+ String aliDownloadUrl = "http://oss.gangwaninfo.com";
|
|
|
|
+ String file = aliyunUrl + workattachment.getUrl();
|
|
|
|
+ file = file.replace("amp;", "");
|
|
|
|
+ String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
|
|
|
|
+ String cons = "";
|
|
|
|
+ if (file.contains(aliyunUrl)) {
|
|
|
|
+ cons = aliyunUrl;
|
|
|
|
+ } else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
|
|
|
|
+ cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
|
+ } else {
|
|
|
|
+ cons = aliDownloadUrl;
|
|
|
|
+ }
|
|
|
|
+ String ossKey = file.split(cons + "/")[1];
|
|
|
|
+ return SpringUtil.getBean(IWorkAttachmentApi.class).downBytesByStream(ossKey, fileName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 压缩方法
|
|
|
|
+ *
|
|
|
|
+ * @param sourceDirPath
|
|
|
|
+ * @param zipPath
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public static void zipFolder(String sourceDirPath, String zipPath) throws IOException {
|
|
|
|
+ Path zipFilePath = Paths.get(zipPath);
|
|
|
|
+ Path sourcePath = Paths.get(sourceDirPath);
|
|
|
|
+
|
|
|
|
+ try (ZipOutputStream zs = new ZipOutputStream(Files.newOutputStream(zipFilePath))) {
|
|
|
|
+ Files.walk(sourcePath)
|
|
|
|
+ .filter(path -> !Files.isDirectory(path))
|
|
|
|
+ .forEach(path -> {
|
|
|
|
+ ZipEntry zipEntry = new ZipEntry(sourcePath.relativize(path).toString());
|
|
|
|
+ try {
|
|
|
|
+ zs.putNextEntry(zipEntry);
|
|
|
|
+ Files.copy(path, zs);
|
|
|
|
+ zs.closeEntry();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|