|
|
@@ -10,7 +10,10 @@ import com.jeeplus.common.config.Global;
|
|
|
import com.jeeplus.common.oss.OSSClientUtil;
|
|
|
import com.jeeplus.common.persistence.Page;
|
|
|
import com.jeeplus.common.service.CrudService;
|
|
|
-import com.jeeplus.common.utils.*;
|
|
|
+import com.jeeplus.common.utils.Collections3;
|
|
|
+import com.jeeplus.common.utils.DateUtils;
|
|
|
+import com.jeeplus.common.utils.IdGen;
|
|
|
+import com.jeeplus.common.utils.MenuStatusEnum;
|
|
|
import com.jeeplus.modules.act.entity.Act;
|
|
|
import com.jeeplus.modules.act.service.ActTaskService;
|
|
|
import com.jeeplus.modules.act.utils.ProcessDefCache;
|
|
|
@@ -24,7 +27,6 @@ import com.jeeplus.modules.projectFilingBatch.entity.ProjectFilingBatchImportInf
|
|
|
import com.jeeplus.modules.projectcontentinfo.dao.ProjectReportDataDao;
|
|
|
import com.jeeplus.modules.projectcontentinfo.dao.ProjectReportDataTwoDao;
|
|
|
import com.jeeplus.modules.projectcontentinfo.dao.ProjectcontentinfoDao;
|
|
|
-import com.jeeplus.modules.projectcontentinfo.entity.ProjectMaterialDefectRecord;
|
|
|
import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
|
|
|
import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportDataTwo;
|
|
|
import com.jeeplus.modules.projectcontentinfo.entity.Projectcontentinfo;
|
|
|
@@ -99,7 +101,6 @@ import java.net.URLEncoder;
|
|
|
import java.nio.charset.Charset;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.*;
|
|
|
import java.util.*;
|
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipFile;
|
|
|
@@ -2686,13 +2687,11 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
|
|
|
File resultFile = null;
|
|
|
File file = null;
|
|
|
try {
|
|
|
- //遍历项目id并查询对应数据信息
|
|
|
- for (String projectId: idList) {
|
|
|
- //获取项目信息
|
|
|
- RuralProjectRecords records = this.getQueryProjectUsers(projectId);
|
|
|
- //根据项目id查询项目报告信息
|
|
|
- //ProjectReportData projectReportData = projectReportDataService.getReportDataByProjectId(records.getId());
|
|
|
- //projectReportData = projectReportDataService.get(projectReportData.getId());
|
|
|
+ //一次性将被选择到的所有项目信息都查出来,然后进行批量处理,降低处理时间
|
|
|
+ List<RuralProjectRecords> projectList = ruralProjectRecordsDao.getInfoByProjectIdList(idList);
|
|
|
+
|
|
|
+ for (RuralProjectRecords records : projectList) {
|
|
|
+
|
|
|
ProjectAccessoryRelationInfo relateInfo = new ProjectAccessoryRelationInfo();
|
|
|
|
|
|
//添加项目类型
|
|
|
@@ -2728,29 +2727,37 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
|
|
|
relateInfo.setId(records.getId());
|
|
|
//查询报告文件、依据性文件、其他文件必填列表以及数据
|
|
|
List<MainDictDetail> mainDictDetails = this.attachmentTemplateList();
|
|
|
+
|
|
|
List<ProjectTemplateInfo> projectTemplateList = null;
|
|
|
- String downloadPath = path + "/" + records.getProjectName();
|
|
|
+ // 原始拼接逻辑
|
|
|
+ String downloadPath = path + "/"+ records.getProjectReportNumber() + "-" + records.getProjectName();
|
|
|
+ // 最大长度限制
|
|
|
+ int maxLength = 100;
|
|
|
+ // 省略号
|
|
|
+ String ellipsis = "...";
|
|
|
+ // 处理超长字符串
|
|
|
+ if (downloadPath.length() > maxLength) {
|
|
|
+ // 截取前 97 个字符 + 省略号(总长度刚好100)
|
|
|
+ downloadPath = downloadPath.substring(0, maxLength - ellipsis.length()) + ellipsis;
|
|
|
+ }
|
|
|
for (MainDictDetail mainDict : mainDictDetails) {
|
|
|
relateInfo.setAttachType(mainDict.getValue());
|
|
|
File dirFile = null;
|
|
|
switch (mainDict.getValue()) {
|
|
|
case "11":
|
|
|
dirFile=new File(downloadPath+"/成果文件");
|
|
|
- projectTemplateList = Lists.newArrayList();
|
|
|
- projectTemplateList = this.getProjectTemplateList(relateInfo);
|
|
|
- this.disposeFileList(projectTemplateList,dirFile.getPath());
|
|
|
+ List<WorkClientAttachment> exportProjectTemplateList = this.getExportProjectTemplateList(relateInfo);
|
|
|
+ this.disposeExportFileList(exportProjectTemplateList,dirFile.getPath());
|
|
|
break;
|
|
|
case "12":
|
|
|
dirFile=new File(downloadPath+"/依据性资料");
|
|
|
- projectTemplateList = Lists.newArrayList();
|
|
|
- projectTemplateList = this.getProjectTemplateList(relateInfo);
|
|
|
- this.disposeFileList(projectTemplateList,dirFile.getPath());
|
|
|
+ exportProjectTemplateList = this.getExportProjectTemplateList(relateInfo);
|
|
|
+ this.disposeExportFileList(exportProjectTemplateList,dirFile.getPath());
|
|
|
break;
|
|
|
case "13":
|
|
|
dirFile=new File(downloadPath+"/其他文件");
|
|
|
- projectTemplateList = Lists.newArrayList();
|
|
|
- projectTemplateList = this.getProjectTemplateList(relateInfo);
|
|
|
- this.disposeFileList(projectTemplateList,dirFile.getPath());
|
|
|
+ exportProjectTemplateList = this.getExportProjectTemplateList(relateInfo);
|
|
|
+ this.disposeExportFileList(exportProjectTemplateList,dirFile.getPath());
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
@@ -2775,6 +2782,128 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
|
|
|
return file.getPath();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目相应文件批量下载并压缩
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ public String exportProjectRecordsFiles(String id) throws Exception {
|
|
|
+ File file = null;
|
|
|
+ if(StringUtils.isNotBlank(id)){
|
|
|
+ RuralProjectRecords records = ruralProjectRecordsDao.get(id);
|
|
|
+
|
|
|
+ File resultFile = null;
|
|
|
+ String path = null;
|
|
|
+ try {
|
|
|
+ if (null != records) {
|
|
|
+ //设置下载的压缩包名(固定字符+时间戳)
|
|
|
+ long timeMillis = System.currentTimeMillis();
|
|
|
+
|
|
|
+ // 最大长度限制
|
|
|
+ int maxLength = 100;
|
|
|
+ // 省略号
|
|
|
+ String ellipsis = "...";
|
|
|
+
|
|
|
+ String projectName = records.getProjectName();
|
|
|
+ // 处理超长字符串
|
|
|
+ if (records.getProjectName().length() > maxLength) {
|
|
|
+ // 截取前 97 个字符 + 省略号(总长度刚好100)
|
|
|
+ projectName = records.getProjectName().substring(0, maxLength - ellipsis.length()) + ellipsis;
|
|
|
+ }
|
|
|
+
|
|
|
+ String fileLocality = records.getProjectReportNumber() + "-" + projectName + "-项目附件_" + timeMillis;
|
|
|
+
|
|
|
+ //判定当前系统
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ProjectAccessoryRelationInfo relateInfo = new ProjectAccessoryRelationInfo();
|
|
|
+
|
|
|
+ //添加项目类型
|
|
|
+ relateInfo.setAttachmentProjectType(records.getProjectType());
|
|
|
+ relateInfo.setAttachmentProjectSort(records.getAttachmentProjectSort());
|
|
|
+
|
|
|
+ String money=records.getSubmitMoney();
|
|
|
+ Integer approvalMoney=null;
|
|
|
+ if(com.jeeplus.common.utils.StringUtils.isBlank(money)){
|
|
|
+ approvalMoney=1;
|
|
|
+ }else{
|
|
|
+ approvalMoney=Integer.parseInt(money);
|
|
|
+ }
|
|
|
+ switch (approvalMoney){
|
|
|
+ case 0:
|
|
|
+ //金额为0
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney(null);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ //500w以下金额状态
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney("1");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //500w以上金额状态
|
|
|
+ relateInfo.setAttachmentProjectApprovalMoney("2");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //添加报告类型
|
|
|
+ relateInfo.setRequiredStage(1);
|
|
|
+ relateInfo.setId(records.getId());
|
|
|
+ //查询报告文件、依据性文件、其他文件必填列表以及数据
|
|
|
+ List<MainDictDetail> mainDictDetails = this.attachmentTemplateList();
|
|
|
+ for (MainDictDetail mainDict : mainDictDetails) {
|
|
|
+ relateInfo.setAttachType(mainDict.getValue());
|
|
|
+ File dirFile = null;
|
|
|
+ switch (mainDict.getValue()) {
|
|
|
+ case "11":
|
|
|
+ dirFile=new File(path+"/成果文件");
|
|
|
+ List<WorkClientAttachment> exportProjectTemplateList = this.getExportProjectTemplateList(relateInfo);
|
|
|
+ this.disposeExportFileList(exportProjectTemplateList,dirFile.getPath());
|
|
|
+ break;
|
|
|
+ case "12":
|
|
|
+ dirFile=new File(path+"/依据性资料");
|
|
|
+ exportProjectTemplateList = this.getExportProjectTemplateList(relateInfo);
|
|
|
+ this.disposeExportFileList(exportProjectTemplateList,dirFile.getPath());
|
|
|
+ break;
|
|
|
+ case "13":
|
|
|
+ dirFile=new File(path+"/其他文件");
|
|
|
+ exportProjectTemplateList = this.getExportProjectTemplateList(relateInfo);
|
|
|
+ this.disposeExportFileList(exportProjectTemplateList,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
|
|
|
@@ -2873,6 +3002,65 @@ public class RuralProjectRecordsService extends CrudService<RuralProjectRecordsD
|
|
|
return projectTemplateList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目相关文件信息批量导出
|
|
|
+ * @param projectTemplateInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<WorkClientAttachment> getExportProjectTemplateList(ProjectAccessoryRelationInfo projectTemplateInfo){
|
|
|
+ //查询所有被选择为必填项展示列,并查询附件信息
|
|
|
+ List<ProjectTemplateInfo> projectTemplateList = projectTemplateDao.getProjectTemplateList(projectTemplateInfo);
|
|
|
+ //查询没有被选择必填项的数据并查询是否已经上传附件,若有则添加到展示列中
|
|
|
+ List<ProjectTemplateInfo> otherProjectTemplateList = projectTemplateDao.projectAccessoryListByParentId(projectTemplateInfo);
|
|
|
+ WorkClientAttachment attchment = new WorkClientAttachment();
|
|
|
+ attchment.setProjectId(projectTemplateInfo.getId());
|
|
|
+ List<String> attachmentIdList = Lists.newArrayList();
|
|
|
+ for (ProjectTemplateInfo info: projectTemplateList) {
|
|
|
+ attachmentIdList.add(info.getId());
|
|
|
+ }
|
|
|
+ for (ProjectTemplateInfo info: otherProjectTemplateList) {
|
|
|
+ attachmentIdList.add(info.getId());
|
|
|
+ }
|
|
|
+ attchment.setAttachmentIdList(attachmentIdList);
|
|
|
+ List<WorkClientAttachment> attachments = workClientAttachmentDao.getInfoList(attchment);
|
|
|
+
|
|
|
+ return attachments;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理文件信息
|
|
|
+ * @param workAttachments
|
|
|
+ * @param downloadPath
|
|
|
+ */
|
|
|
+ public void disposeExportFileList(List<WorkClientAttachment> workAttachments,String downloadPath) throws Exception {
|
|
|
+ if(null != workAttachments && !workAttachments.isEmpty()){
|
|
|
+ SftpClientUtil sftpClientUtil = new SftpClientUtil();
|
|
|
+ try {
|
|
|
+ // 批量连接一次
|
|
|
+ sftpClientUtil.connectBatch();
|
|
|
+
|
|
|
+ for (WorkClientAttachment attachment : workAttachments) {
|
|
|
+ String url = attachment.getUrl();
|
|
|
+ int lastSlash = url.lastIndexOf("/");
|
|
|
+ String dir = url.substring(0, lastSlash);
|
|
|
+ String fileName = url.substring(lastSlash + 1);
|
|
|
+
|
|
|
+ // 调用【批量下载方法】
|
|
|
+ sftpClientUtil.downloadRuralProjectBatch(
|
|
|
+ dir,
|
|
|
+ fileName,
|
|
|
+ downloadPath,
|
|
|
+ attachment.getAttachmentName()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ // 统一关闭
|
|
|
+ sftpClientUtil.closeBatch();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 项目列表新增文件信息获取
|
|
|
* @param projectRecords 项目信息
|