|
@@ -3,6 +3,9 @@
|
|
|
*/
|
|
|
package com.jeeplus.modules.workstaff.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
|
|
|
import com.dingtalk.api.response.OapiV2UserCreateResponse;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -15,6 +18,9 @@ import com.jeeplus.common.service.CrudService;
|
|
|
import com.jeeplus.common.utils.MenuStatusEnum;
|
|
|
import com.jeeplus.common.utils.MyBeanUtils;
|
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
|
+import com.jeeplus.modules.projectAccessory.entity.ProjectAccessoryRelationInfo;
|
|
|
+import com.jeeplus.modules.projectAccessory.entity.ProjectTemplateInfo;
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
|
|
|
import com.jeeplus.modules.sys.dao.AreaDao;
|
|
|
import com.jeeplus.modules.sys.entity.Area;
|
|
|
import com.jeeplus.modules.sys.entity.MainDictDetail;
|
|
@@ -25,6 +31,8 @@ import com.jeeplus.modules.sys.utils.DictUtils;
|
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
import com.jeeplus.modules.sysuseroffice.entity.Useroffice;
|
|
|
import com.jeeplus.modules.sysuseroffice.service.UserofficeService;
|
|
|
+import com.jeeplus.modules.utils.SftpClientUtil;
|
|
|
+import com.jeeplus.modules.utils.ZipCompressUtil;
|
|
|
import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
|
|
|
import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
|
|
|
import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
|
|
@@ -33,10 +41,7 @@ import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
|
|
|
import com.jeeplus.modules.workrelationship.dao.WorkRelationshipDao;
|
|
|
import com.jeeplus.modules.workrelationship.entity.WorkRelationship;
|
|
|
import com.jeeplus.modules.workstaff.dao.*;
|
|
|
-import com.jeeplus.modules.workstaff.entity.DingTalkUser;
|
|
|
-import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
|
|
|
-import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfoExcel;
|
|
|
-import com.jeeplus.modules.workstaff.entity.WorkStaffCertificate;
|
|
|
+import com.jeeplus.modules.workstaff.entity.*;
|
|
|
import com.jeeplus.modules.workstaff.utils.DingTalkUtils;
|
|
|
import com.jeeplus.modules.workstaffachiveslog.dao.WorkStaffAchivesLogDao;
|
|
|
import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
|
|
@@ -48,12 +53,19 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -1531,6 +1543,217 @@ public class WorkStaffBasicInfoService extends CrudService<WorkStaffBasicInfoDao
|
|
|
//钉钉逻辑
|
|
|
}
|
|
|
|
|
|
+ public String exportAll(List<String> idList,String type) throws Exception {
|
|
|
+ //设置下载的压缩包名(固定字符+时间戳)
|
|
|
+ long timeMillis = System.currentTimeMillis();
|
|
|
+ String fileLocality = "";
|
|
|
+ switch (type) {
|
|
|
+ case "1"://身份证
|
|
|
+ fileLocality = "身份证附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ case "2"://学历证书
|
|
|
+ fileLocality = "学历证书附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ case "3"://学位证书
|
|
|
+ fileLocality = "学位证书附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ case "4"://培训证书
|
|
|
+ fileLocality = "培训证书附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ case "5"://执业资格证
|
|
|
+ fileLocality = "执业资格证附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ case "6"://职称证书
|
|
|
+ fileLocality = "职称证书附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ case "7"://外语语种证书
|
|
|
+ fileLocality = "外语语种证书附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ case "8"://表彰
|
|
|
+ fileLocality = "表彰证书附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ case "9"://劳动合同
|
|
|
+ fileLocality = "劳动合同附件_"+ timeMillis;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //判定当前系统
|
|
|
+ String path = null;
|
|
|
+ if(System.getProperty("os.name").toLowerCase().contains("win")){
|
|
|
+ path = Global.getConfig("remoteServer.winDirectory");
|
|
|
+ }else{
|
|
|
+ path = Global.getConfig("remoteServer.directory");
|
|
|
+ }
|
|
|
+ path = path + "/" + fileLocality;
|
|
|
+ //检查该路径对应的目录是否存在. 如果不存在则创建目录
|
|
|
+ File dir=new File(path);
|
|
|
+ if (!dir.exists()) {
|
|
|
+ dir.mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ File resultFile = null;
|
|
|
+ File file = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ //遍历项目id并查询对应数据信息
|
|
|
+ for (String userId: idList) {
|
|
|
+ WorkStaffBasicInfo workStaffBasicInfo = this.get(userId);
|
|
|
+ String downloadPath = path + "/" + workStaffBasicInfo.getName();
|
|
|
+ File dirFile = null;
|
|
|
+
|
|
|
+ //按照achieveId查询
|
|
|
+ String id = workStaffBasicInfo.getId();
|
|
|
+ if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(workStaffBasicInfo.getAchiveId())) {
|
|
|
+ workStaffBasicInfo.setId(workStaffBasicInfo.getAchiveId());
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case "1"://身份证
|
|
|
+ dirFile=new File(downloadPath + "_身份证附件");
|
|
|
+ if(StringUtils.isNotBlank(workStaffBasicInfo.getIdCardPortraitPath())){
|
|
|
+ this.disposeFileList( workStaffBasicInfo.getIdCardPortraitPath(), workStaffBasicInfo.getName() + "身份证人像面", dirFile.getPath());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(workStaffBasicInfo.getIdCardNationalEmblemPath())){
|
|
|
+ this.disposeFileList( workStaffBasicInfo.getIdCardNationalEmblemPath(), workStaffBasicInfo.getName() + "身份证国徽面", dirFile.getPath());
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "2"://学历证书
|
|
|
+ dirFile=new File(downloadPath + "_学历证书附件");
|
|
|
+ educationService.query(workStaffBasicInfo);
|
|
|
+ for (WorkStaffEducation workStaffEducation : workStaffBasicInfo.getEducationList()) {
|
|
|
+ if(StringUtils.isNotBlank(workStaffEducation.getEduPhoto())){
|
|
|
+ this.disposeFileList(workStaffEducation.getEduPhoto(),workStaffBasicInfo.getName() + workStaffEducation.getSchool() + "学历证书", dirFile.getPath());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "3"://学位证书
|
|
|
+ dirFile=new File(downloadPath + "_学位证书附件");
|
|
|
+ educationService.query(workStaffBasicInfo);
|
|
|
+ for (WorkStaffEducation workStaffEducation : workStaffBasicInfo.getEducationList()) {
|
|
|
+ this.disposeFileList(workStaffEducation.getDegreePhoto(),workStaffBasicInfo.getName() + workStaffEducation.getSchool() + "学位证书", dirFile.getPath());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "4"://培训证书
|
|
|
+ dirFile=new File(downloadPath + "_培训证书附件");
|
|
|
+ trainingService.query(workStaffBasicInfo);
|
|
|
+ for (WorkStaffTraining workStaffTraining : workStaffBasicInfo.getTrainingList()) {
|
|
|
+ this.disposeFileList(workStaffTraining.getFilePath(),workStaffBasicInfo.getName() + workStaffTraining.getAgency() + "培训证书", dirFile.getPath());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "5"://执业资格证
|
|
|
+ dirFile=new File(downloadPath + "_执业资格证附件");
|
|
|
+ certificateService.query(workStaffBasicInfo);
|
|
|
+ for (WorkStaffCertificate workStaffCertificate : workStaffBasicInfo.getCertificateList()) {
|
|
|
+ this.disposeFileList(workStaffCertificate.getFilePath(),workStaffBasicInfo.getName() + workStaffCertificate.getName() + "执业资格证书", dirFile.getPath());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "6"://职称证书
|
|
|
+ dirFile=new File(downloadPath + "_职称证书附件");
|
|
|
+ titleService.query(workStaffBasicInfo);
|
|
|
+ for (WorkStaffTitle workStaffTitle : workStaffBasicInfo.getTitleList()) {
|
|
|
+ this.disposeFileList(workStaffTitle.getFilePath(),workStaffBasicInfo.getName() + workStaffTitle.getName() + "职称证书", dirFile.getPath());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "7"://外语语种证书
|
|
|
+ dirFile=new File(downloadPath + "_外语语种证书附件");
|
|
|
+ languagesService.query(workStaffBasicInfo);
|
|
|
+ for (WorkStaffLanguages workStaffLanguages : workStaffBasicInfo.getLanguageList()) {
|
|
|
+ this.disposeFileList(workStaffLanguages.getFilePath(),workStaffBasicInfo.getName() + workStaffLanguages.getLanguage() + "语种证书", dirFile.getPath());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "8"://表彰
|
|
|
+ dirFile=new File(downloadPath + "_表彰证书附件");
|
|
|
+ rewardsService.query(workStaffBasicInfo);
|
|
|
+ for (WorkStaffRewards workStaffRewards : workStaffBasicInfo.getRewardsList()) {
|
|
|
+ this.disposeFileList(workStaffRewards.getFilePath(),workStaffBasicInfo.getName() + workStaffRewards.getName() + "表彰证书", dirFile.getPath());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "9"://劳动合同
|
|
|
+ dirFile=new File(downloadPath + "_劳动合同附件");
|
|
|
+ labourContractService.query(workStaffBasicInfo);
|
|
|
+ for (WorkStaffLaborContract workStaffLaborContract : workStaffBasicInfo.getLaborContractList()) {
|
|
|
+ this.disposeFileList(workStaffLaborContract.getFilePath(),workStaffBasicInfo.getName() + workStaffLaborContract.getFileName() + "劳动合同", dirFile.getPath());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //处理完之后进行打包压缩并删除之前的文件
|
|
|
+ ZipCompressUtil zipUtil = new ZipCompressUtil();
|
|
|
+ resultFile = new File(path);
|
|
|
+ file = zipUtil.zipCompress(resultFile, true);
|
|
|
+
|
|
|
+ }catch (IOException e) {
|
|
|
+ logger.error("Exception e:"+e);
|
|
|
+ }
|
|
|
+ finally {
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
+ if(resultFile.isFile()&&resultFile.exists()){
|
|
|
+ resultFile.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return file.getPath();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理文件信息
|
|
|
+ * @param filePath
|
|
|
+ * @param fileName
|
|
|
+ * @param downloadPath
|
|
|
+ */
|
|
|
+ public void disposeFileList(String filePath,String fileName,String downloadPath) throws IOException {
|
|
|
+ SftpClientUtil sftpClientUtil = new SftpClientUtil();
|
|
|
+ String prefix = Global.getAliyunUrl();
|
|
|
+ String alyunPrefix = Global.getAliDownloadUrl();
|
|
|
+
|
|
|
+ if (filePath.startsWith(prefix)) {
|
|
|
+ filePath = filePath.substring(prefix.length());
|
|
|
+ }
|
|
|
+ if (filePath.startsWith(alyunPrefix)) {
|
|
|
+ filePath = filePath.substring(alyunPrefix.length());
|
|
|
+ }
|
|
|
+ String substring = filePath.substring(0, filePath.lastIndexOf("/"));
|
|
|
+ String extension = filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length());
|
|
|
+ sftpClientUtil.downloadFileOnPathAndName(filePath.substring(0,filePath.lastIndexOf("/")),filePath.substring(filePath.lastIndexOf("/") + 1, filePath.length()),downloadPath,fileName + "." + extension);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载压缩文件
|
|
|
+ * @param filePath
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ public void downloadZipFile(String filePath, HttpServletResponse response){
|
|
|
+ File file = new File(filePath);
|
|
|
+ // 取得文件名。
|
|
|
+ String fileName = file.getName();
|
|
|
+ InputStream in = null;
|
|
|
+ try {
|
|
|
+ fileName = URLEncoder.encode(fileName,"UTF8");
|
|
|
+ in = new FileInputStream(file);
|
|
|
+ response.reset();//重置 响应头
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ response.setContentType("application/x-download");
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
|
|
+
|
|
|
+ byte[] b = new byte[1024];
|
|
|
+ int len;
|
|
|
+ while ((len = in.read(b)) > 0){
|
|
|
+ response.getOutputStream().write(b, 0, len);
|
|
|
+ }
|
|
|
+ in.close();
|
|
|
+ response.getOutputStream().close();
|
|
|
+ }catch (IOException e) {
|
|
|
+ logger.error("Exception e:"+e);
|
|
|
+ }
|
|
|
+ finally {
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
+ if(file.isFile()&&file.exists()){
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|