Browse Source

0000000000000

zhouli 8 months ago
parent
commit
51d554881a

+ 47 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/DownloadTask.java

@@ -0,0 +1,47 @@
+
+package org.sky.scientific.pojo.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.sky.core.tenant.mp.TenantEntity;
+import org.sky.core.tool.utils.DateUtil;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serial;
+import java.util.Date;
+
+/**
+ * 下载任务表 实体类
+ *
+ * @author Kd
+ * @since 2025-06-29
+ */
+@Data
+@TableName("kd_download_task")
+@Schema(description = "Asset对象")
+@EqualsAndHashCode(callSuper = true)
+public class DownloadTask extends TenantEntity {
+
+	@Serial
+	private static final long serialVersionUID = 1L;
+
+	@Schema(description = "年份")
+	private String yearAndMonth;
+
+	@Schema(description = "过期时间")
+	@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
+	@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
+	private Date expireTime;
+
+	@Schema(description = "状态,0:进行中,2:已完成,3:已过期")
+	private Integer status;
+
+	@Schema(description = "压缩文件的路径")
+	private String zipUrl;
+
+	@Schema(description = "类型,0:一键下载,1:一键导出高新被查,2:一键导出加计被查")
+	private Integer type;
+}

+ 91 - 8
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/ArchiveCenterController.java

@@ -1,6 +1,8 @@
 
 package org.sky.scientific.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -8,12 +10,23 @@ import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
 import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
 import org.sky.core.boot.ctrl.KdController;
 import org.sky.core.tool.api.R;
+import org.sky.core.tool.utils.DateUtil;
+import org.sky.core.tool.utils.FileUtil;
+import org.sky.scientific.mapper.DownloadTaskMapper;
 import org.sky.scientific.pojo.entity.ArchiveAttachEntity;
+import org.sky.scientific.pojo.entity.DownloadTask;
 import org.sky.scientific.service.IArchiveService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.Date;
+
 /**
  * 科研档案管理 控制器
  *
@@ -26,7 +39,9 @@ import org.springframework.web.bind.annotation.*;
 @Tag(name = "科研档案管理")
 public class ArchiveCenterController extends KdController {
 
+	private static final Logger log = LoggerFactory.getLogger(ArchiveCenterController.class);
 	private final IArchiveService service;
+	private final DownloadTaskMapper downloadTaskMapper;
 
 	@GetMapping("fjbczl")
 	@ApiOperationSupport(order = 1)
@@ -45,29 +60,97 @@ public class ArchiveCenterController extends KdController {
 	@GetMapping("fjbczl/download")
 	@ApiOperationSupport(order = 5)
 	@Operation(summary = "附件补充资料-一键下载")
-	public void ownloadFjbczlZipFiles(HttpServletRequest request, HttpServletResponse response, String year){
-		service.downloadFjbczlZipFiles(request,response, year);
+	public void ownloadFjbczlZipFiles(HttpServletRequest request, HttpServletResponse response, String year) {
+		service.downloadFjbczlZipFiles(request, response, year);
 	}
 
+	@SneakyThrows
 	@GetMapping("center/download")
 	@ApiOperationSupport(order = 6)
 	@Operation(summary = "档案中心-一键下载")
-	public void downloadCenterZipFiles(HttpServletRequest request, HttpServletResponse response, String year){
-		service.downloadCenterZipFiles(request,response, year);
+	public void downloadCenterZipFiles(HttpServletResponse response, String year, Long taskId) {
+		if (taskId != null) {
+			DownloadTask task = downloadTaskMapper.selectById(taskId);
+			if (task == null) {
+				response.setContentType("application/json;charset=UTF-8");
+				PrintWriter writer = response.getWriter();
+				writer.write(JSON.toJSONString(R.fail("下载任务不存在,请联系管理员")));
+				writer.flush();
+			} else if (task.getStatus() == 2) {
+				if (task.getExpireTime() != null && new Date().compareTo(task.getExpireTime()) > 0) {
+					FileUtil.deleteQuietly(new File(task.getZipUrl()));
+					downloadTaskMapper.deleteById(taskId);
+					//24小时后需重新生成
+					response.setContentType("application/json;charset=UTF-8");
+					PrintWriter writer = response.getWriter();
+					writer.write(JSON.toJSONString(R.fail("文件已是24小时前生成的,请重新生成")));
+					writer.flush();
+				} else {
+					//将磁盘生成的目录及文件压缩成zip
+					OutputStream toClient = null;
+					try {
+						BufferedInputStream fis = new BufferedInputStream(new FileInputStream(task.getZipUrl()));
+						byte[] buffer = new byte[fis.available()];
+						fis.read(buffer);
+						fis.close();
+						response.reset();
+						toClient = new BufferedOutputStream(response.getOutputStream());
+						response.setCharacterEncoding(StandardCharsets.UTF_8.name());
+						response.setContentType("application/octet-stream");
+						response.setHeader("content-disposition", "attachment; filename=" + task.getZipUrl());
+						toClient.write(buffer);
+						toClient.flush();
+					} catch (Exception e) {
+						response.setContentType("application/json;charset=UTF-8");
+						PrintWriter writer = response.getWriter();
+						writer.write(JSON.toJSONString(R.fail("下载zip压缩包过程发生异常,请联系管理员")));
+						log.error("下载zip压缩包过程发生异常,{}", e.getLocalizedMessage());
+						writer.flush();
+					} finally {
+						if (toClient != null) {
+							try {
+								toClient.close();
+							} catch (IOException e) {
+								log.error("zip下载关流失败");
+							}
+						}
+					}
+				}
+			} else {
+				response.setContentType("application/json;charset=UTF-8");
+				PrintWriter writer = response.getWriter();
+				writer.write(JSON.toJSONString(R.fail("下载任务进行中,请耐心等待")));
+				writer.flush();
+			}
+		} else {
+			DownloadTask task = new DownloadTask();
+			task.setYearAndMonth(year);
+			task.setExpireTime(DateUtil.plusDays(new Date(), 1));
+			int result = downloadTaskMapper.insert(task);
+			if (result == 1) {
+				response.setContentType("application/json;charset=UTF-8");
+				PrintWriter writer = response.getWriter();
+				JSONObject data = new JSONObject();
+				data.put("taskId", task.getId());
+				writer.write(JSON.toJSONString(R.data(data)));
+				writer.flush();
+				service.downloadCenterZipFiles(year, task.getId());
+			}
+		}
 	}
 
 	@GetMapping("center/high-tech/download")
 	@ApiOperationSupport(order = 8)
 	@Operation(summary = "档案中心-一键导出高新备查")
-	public void downloadCenterHighTechZipFiles(HttpServletRequest request, HttpServletResponse response, String year){
-		service.downloadHighTechZipFiles(request,response, year);
+	public void downloadCenterHighTechZipFiles(HttpServletRequest request, HttpServletResponse response, String year) {
+		service.downloadHighTechZipFiles(request, response, year);
 	}
 
 	@GetMapping("center/deduction/download")
 	@ApiOperationSupport(order = 10)
 	@Operation(summary = "档案中心-一键导出加计备查")
-	public void downloadCenterDeductionZipFiles(HttpServletRequest request, HttpServletResponse response, String year){
-		service.downloadDeductionZipFiles(request,response, year);
+	public void downloadCenterDeductionZipFiles(HttpServletRequest request, HttpServletResponse response, String year) {
+		service.downloadDeductionZipFiles(request, response, year);
 	}
 
 }

+ 15 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/DownloadTaskMapper.java

@@ -0,0 +1,15 @@
+
+package org.sky.scientific.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.sky.scientific.pojo.entity.DownloadTask;
+
+/**
+ * 下载任务表 Mapper 接口
+ *
+ * @author Kd
+ * @since 2025-06-29
+ */
+public interface DownloadTaskMapper extends BaseMapper<DownloadTask> {
+
+}

+ 5 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/DownloadTaskMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.sky.scientific.mapper.DownloadTaskMapper">
+
+</mapper>

+ 1 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IArchiveService.java

@@ -22,7 +22,7 @@ public interface IArchiveService {
 
 	void downloadFjbczlZipFiles(HttpServletRequest request, HttpServletResponse response, String year);
 
-	void downloadCenterZipFiles(HttpServletRequest request, HttpServletResponse response, String year);
+	void downloadCenterZipFiles(String year,Long taskId);
 
 	void downloadHighTechZipFiles(HttpServletRequest request, HttpServletResponse response, String year);
 

+ 130 - 73
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/ArchiveServiceImpl.java

@@ -1,6 +1,8 @@
 package org.sky.scientific.service.impl;
 
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.IORuntimeException;
+import cn.hutool.core.util.ZipUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -18,6 +20,7 @@ import org.sky.core.secure.utils.SecureUtil;
 import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.Func;
 import org.sky.scientific.mapper.ArchiveAttachMapper;
+import org.sky.scientific.mapper.DownloadTaskMapper;
 import org.sky.scientific.mapper.SettingMapper;
 import org.sky.scientific.pojo.dto.*;
 import org.sky.scientific.pojo.entity.*;
@@ -27,6 +30,8 @@ import org.sky.scientific.utils.ZipDir;
 import org.sky.scientific.utils.ZipDownloadUtils;
 import org.sky.scientific.utils.ZipFileRef;
 import org.sky.system.cache.DictCache;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -37,6 +42,7 @@ import java.io.IOException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.zip.Deflater;
@@ -44,6 +50,7 @@ import java.util.zip.Deflater;
 @Service
 public class ArchiveServiceImpl implements IArchiveService {
 
+	private static final Logger log = LoggerFactory.getLogger(ArchiveServiceImpl.class);
 	@Value("${archive.dir}")
 	private String archiveDir;
 
@@ -109,6 +116,8 @@ public class ArchiveServiceImpl implements IArchiveService {
 	private ICgRjzzqService rjzzqService;
 	@Resource
 	private ICgQtService qtService;
+	@Resource
+	private DownloadTaskMapper downloadTaskMapper;
 
 	@Override
 	public ArchiveAttachEntity fjbczl(String year) {
@@ -251,7 +260,7 @@ public class ArchiveServiceImpl implements IArchiveService {
 	}
 
 	@Override
-	public void downloadCenterZipFiles(HttpServletRequest request, HttpServletResponse response, String year) {
+	public void downloadCenterZipFiles(String year, Long taskId) {
 		if (Func.isBlank(year)) {
 			throw new ServiceException("参数year不能为空");
 		}
@@ -260,68 +269,123 @@ public class ArchiveServiceImpl implements IArchiveService {
 		if (archiveAttach == null) {
 			archiveAttach = new ArchiveAttachEntity();
 		}
-
 		Path basePath = Paths.get(archiveDir, SecureUtil.getTenantId(), year);
 
-		//1 高新技术企业资格证书:基础资源管理-企业基本信息-高企证书上传(按年度)。未上传则为空
-		generateD1(Paths.get(basePath.toString(), "1.高新技术企业资格证书"), year);
-		//2 高新技术企业认定资料:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "2.高新技术企业认定资料"), Collections.singletonList(archiveAttach.getD3()));
-		//3 加计扣除情况说明:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "3.加计扣除情况说明"), Collections.singletonList(archiveAttach.getD10()));
-		//4 研发立项决议文件:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "4.研发立项决议文件"), Collections.singletonList(archiveAttach.getD13()));
-		//5 高新研发项目汇总表:对外报表-高新口径研发费用报表-高新-研发项目清单表
-		generateD5(Paths.get(basePath.toString(), "5.高新研发项目汇总表"), year, 2);
-		//6 加计扣除研发项目汇总表:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单表
-		generateD5(Paths.get(basePath.toString(), "6.加计扣除研发项目汇总表"), year, 3);
-		//7.高新研发项目全套技术资料:对外报表-高新口径研发费用报表-高新-研发项目清单中的所有研发项目的全套技术资料,每一个项目,都包括:项目立项表+上传的所有附件;项目实施表(含多个表)+所有附件;项目变更(多个表)+所有附件;项目结题(多个表)+所有附件;委外项目表+所有附件。
-		generateD7(Paths.get(basePath.toString(), "7.高新研发项目全套技术资料"), year, 2);
-		//8 加计扣除研发项目全套技术资料:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中的所有研发项目的全套技术资料,每一个项目,都包括:项目立项表+上传的所有附件;项目实施表(含多个表)+所有附件;项目变更(多个表)+所有附件;项目结题(多个表)+所有附件;委外项目表+所有附件。
-		generateD7(Paths.get(basePath.toString(), "8.加计扣除研发项目全套技术资料"), year, 3);
-		//9 高新研发人员与科技人员资料:改成高新科技人员资料:即科技人员管理-年高新科技人员汇总表资料表,选出:对外报表-高新口径研发费用报表-高新-研发项目清单中项目人员汇总
-		generateD9(Paths.get(basePath.toString(), "9.高新科技人员资料"), year, archiveAttach.getD6());
-		//10 加计扣除研发人员与科技人员资料:改成加计扣除项目科研人员资料:即科技人员管理-项目人员汇总表,选出:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中项目人员汇总
-		generateD10(Paths.get(basePath.toString(), "10.加计扣除项目科研人员资料"), year);
-		//11 11.全部知识产权资料(汇总表、附件):当年度所有科研成果列表导出,及所有附件资料的下载
-		generateD11(Paths.get(basePath.toString(), "11.全部知识产权资料"), 0, year);
-		//12 高新项目知识产权资料(汇总表、附件):对外报表-高新口径研发费用报表-高新-研发项目清单中的科研成果列表及所有附件资料的下载
-		generateD11(Paths.get(basePath.toString(), "12.高新项目知识产权资料"), 2, year);
-		//13 加计扣除项目知识产权资料(汇总表、附件):对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中的科研成果列表及所有附件资料的下载
-		generateD11(Paths.get(basePath.toString(), "13.加计扣除项目知识产权资料"), 3, year);
-		//14 会计口径研发费用辅助账:对外报表-会计加计扣除口径研发费用报表-会计-研发支出辅助账
-		generateD14(Paths.get(basePath.toString(), "14.会计口径研发费用辅助账"), year);
-		//15 高新口径研发费用辅助账:对外报表-高新口径研发费用报表-高新-研发支出辅助账
-		generateD15(Paths.get(basePath.toString(), "15.高新口径研发费用辅助账"), year, archiveAttach.getD9());
-		//16 加计扣除口径研发费用辅助账:对外报表-加计扣除口径研发费用报表-加计扣除-研发支出辅助账
-		generateD16(Paths.get(basePath.toString(), "16.加计扣除口径研发费用辅助账"), year);
-
-
-		//17.会计口径研发费用附件凭证资料及相关说明:对外报表-会计加计扣除口径研发费用报表-会计-研发项目(见列表详细)
-		generateD17(year, 1, "17.会计口径研发费用附件支撑资料及相关说明");
-		//18.高新研发费用附件凭证资料及相关说明:对外报表-高新口径研发费用报表-高新-研发项目(见列表详细)
-		generateD17(year, 2, "18.高新研发费用附件支持资料及相关说明");
-		//19.加计扣除研发费用附件凭证资料及相关说明:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目(见列表详细)
-		generateD17(year, 3, "19.加计扣除研发费用附件支撑资料及相关说明");
-
-		//20.A107012研发费用加计扣除优惠明细表:A107012导出表
-		generateD20(year, "20.A107012研发费用加计扣除优惠明细表");
-		//21.当年和前两个会计年度研发费用总额及占同期销售收入比例的说明:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "21.当年和前两个会计年度研发费用总额及占同期销售收入比例的说明"), Collections.singletonList(archiveAttach.getD7()));
-		//22.年度主要产品(服务)发挥核心支持作用的技术属于《国家重点支持的高新技术领域》规定范围的说明:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "22.年度主要产品(服务)发挥核心支持作用的技术属于《国家重点支持的高新技术领域》规定范围的说明"), Collections.singletonList(archiveAttach.getD4()));
-		//23.高新技术产品(服务)及对应收入资料:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "23.高新技术产品(服务)及对应收入资料"), Collections.singletonList(archiveAttach.getD5()));
-		//24.研发管理制度:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "24.研发管理制度"), Collections.singletonList(archiveAttach.getD8()));
-		//25.高新项目技术鉴定资料:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "25.高新项目技术鉴定资料"), Collections.singletonList(archiveAttach.getD1()));
-		//26.加计扣除项目技术鉴定资料:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "26.加计扣除项目技术鉴定资料"), Collections.singletonList(archiveAttach.getD2()));
-		//27.其他高新备查资料:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "27.其他高新备查资料"), Collections.singletonList(archiveAttach.getD11()));
-		//28.其他加计扣除备查资料:附件补充
-		this.downloadAttachFiles(Paths.get(basePath.toString(), "28.其他加计扣除备查资料"), Collections.singletonList(archiveAttach.getD12()));
+		ArchiveAttachEntity finalArchiveAttach = archiveAttach;
+		CompletableFuture<Void> task1 = CompletableFuture.runAsync(() -> {
+			//1 高新技术企业资格证书:基础资源管理-企业基本信息-高企证书上传(按年度)。未上传则为空
+			generateD1(Paths.get(basePath.toString(), "1.高新技术企业资格证书"), year);
+			//2 高新技术企业认定资料:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "2.高新技术企业认定资料"), Collections.singletonList(finalArchiveAttach.getD3()));
+			//3 加计扣除情况说明:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "3.加计扣除情况说明"), Collections.singletonList(finalArchiveAttach.getD10()));
+			//4 研发立项决议文件:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "4.研发立项决议文件"), Collections.singletonList(finalArchiveAttach.getD13()));
+		});
+		CompletableFuture<Void> task2 = CompletableFuture.runAsync(() -> {
+			//5 高新研发项目汇总表:对外报表-高新口径研发费用报表-高新-研发项目清单表
+			generateD5(Paths.get(basePath.toString(), "5.高新研发项目汇总表"), year, 2);
+			//6 加计扣除研发项目汇总表:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单表
+			generateD5(Paths.get(basePath.toString(), "6.加计扣除研发项目汇总表"), year, 3);
+		});
+//
+//		CompletableFuture<Void> task3 = CompletableFuture.runAsync(() -> {
+//			//7.高新研发项目全套技术资料:对外报表-高新口径研发费用报表-高新-研发项目清单中的所有研发项目的全套技术资料,每一个项目,都包括:项目立项表+上传的所有附件;项目实施表(含多个表)+所有附件;项目变更(多个表)+所有附件;项目结题(多个表)+所有附件;委外项目表+所有附件。
+//			generateD7(Paths.get(basePath.toString(), "7.高新研发项目全套技术资料"), year, 2);
+//		});
+//		CompletableFuture<Void> task4 = CompletableFuture.runAsync(() -> {
+//			//8 加计扣除研发项目全套技术资料:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中的所有研发项目的全套技术资料,每一个项目,都包括:项目立项表+上传的所有附件;项目实施表(含多个表)+所有附件;项目变更(多个表)+所有附件;项目结题(多个表)+所有附件;委外项目表+所有附件。
+//			generateD7(Paths.get(basePath.toString(), "8.加计扣除研发项目全套技术资料"), year, 3);
+//		});
+
+		CompletableFuture<Void> task5 = CompletableFuture.runAsync(() -> {
+			//9 高新研发人员与科技人员资料:改成高新科技人员资料:即科技人员管理-年高新科技人员汇总表资料表,选出:对外报表-高新口径研发费用报表-高新-研发项目清单中项目人员汇总
+			generateD9(Paths.get(basePath.toString(), "9.高新科技人员资料"), year, finalArchiveAttach.getD6());
+		});
+		CompletableFuture<Void> task6 = CompletableFuture.runAsync(() -> {
+			//10 加计扣除研发人员与科技人员资料:改成加计扣除项目科研人员资料:即科技人员管理-项目人员汇总表,选出:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中项目人员汇总
+			generateD10(Paths.get(basePath.toString(), "10.加计扣除项目科研人员资料"), year);
+		});
+		CompletableFuture<Void> task7 = CompletableFuture.runAsync(() -> {
+			//11 全部知识产权资料(汇总表、附件):当年度所有科研成果列表导出,及所有附件资料的下载
+			generateD11(Paths.get(basePath.toString(), "11.全部知识产权资料"), 0, year);
+		});
+		CompletableFuture<Void> task8 = CompletableFuture.runAsync(() -> {
+			//12 高新项目知识产权资料(汇总表、附件):对外报表-高新口径研发费用报表-高新-研发项目清单中的科研成果列表及所有附件资料的下载
+			generateD11(Paths.get(basePath.toString(), "12.高新项目知识产权资料"), 2, year);
+		});
+		CompletableFuture<Void> task9 = CompletableFuture.runAsync(() -> {
+			//13 加计扣除项目知识产权资料(汇总表、附件):对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中的科研成果列表及所有附件资料的下载
+			generateD11(Paths.get(basePath.toString(), "13.加计扣除项目知识产权资料"), 3, year);
+		});
+		CompletableFuture<Void> task10 = CompletableFuture.runAsync(() -> {
+			//14 会计口径研发费用辅助账:对外报表-会计加计扣除口径研发费用报表-会计-研发支出辅助账
+			generateD14(Paths.get(basePath.toString(), "14.会计口径研发费用辅助账"), year);
+		});
+		CompletableFuture<Void> task11 = CompletableFuture.runAsync(() -> {
+			//15 高新口径研发费用辅助账:对外报表-高新口径研发费用报表-高新-研发支出辅助账
+			generateD15(Paths.get(basePath.toString(), "15.高新口径研发费用辅助账"), year, finalArchiveAttach.getD9());
+		});
+		CompletableFuture<Void> task12 = CompletableFuture.runAsync(() -> {
+			//16 加计扣除口径研发费用辅助账:对外报表-加计扣除口径研发费用报表-加计扣除-研发支出辅助账
+			generateD16(Paths.get(basePath.toString(), "16.加计扣除口径研发费用辅助账"), year);
+		});
+		//todo 开始
+		CompletableFuture<Void> task13 = CompletableFuture.runAsync(() -> {
+			//17.会计口径研发费用附件凭证资料及相关说明:对外报表-会计加计扣除口径研发费用报表-会计-研发项目(见列表详细)
+			generateD17(Paths.get(basePath.toString(), "17.会计口径研发费用附件支撑资料及相关说明"),year, 1);
+		});
+		CompletableFuture<Void> task14 = CompletableFuture.runAsync(() -> {
+			//18.高新研发费用附件凭证资料及相关说明:对外报表-高新口径研发费用报表-高新-研发项目(见列表详细)
+			generateD17(Paths.get(basePath.toString(), "18.高新研发费用附件支持资料及相关说明"),year, 2);
+		});
+		CompletableFuture<Void> task15 = CompletableFuture.runAsync(() -> {
+			//19.加计扣除研发费用附件凭证资料及相关说明:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目(见列表详细)
+			generateD17(Paths.get(basePath.toString(), "19.加计扣除研发费用附件支撑资料及相关说明"),year, 3);
+		});
+		//todo 结束
+		CompletableFuture<Void> task16 = CompletableFuture.runAsync(() -> {
+			//20.A107012研发费用加计扣除优惠明细表:A107012导出表
+			generateD20(Paths.get(basePath.toString(), "20.A107012研发费用加计扣除优惠明细表"),year);
+		});
+		CompletableFuture<Void> task17 = CompletableFuture.runAsync(() -> {
+			//21.当年和前两个会计年度研发费用总额及占同期销售收入比例的说明:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "21.当年和前两个会计年度研发费用总额及占同期销售收入比例的说明"), Collections.singletonList(finalArchiveAttach.getD7()));
+			//22.年度主要产品(服务)发挥核心支持作用的技术属于《国家重点支持的高新技术领域》规定范围的说明:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "22.年度主要产品(服务)发挥核心支持作用的技术属于《国家重点支持的高新技术领域》规定范围的说明"), Collections.singletonList(finalArchiveAttach.getD4()));
+			//23.高新技术产品(服务)及对应收入资料:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "23.高新技术产品(服务)及对应收入资料"), Collections.singletonList(finalArchiveAttach.getD5()));
+			//24.研发管理制度:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "24.研发管理制度"), Collections.singletonList(finalArchiveAttach.getD8()));
+			//25.高新项目技术鉴定资料:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "25.高新项目技术鉴定资料"), Collections.singletonList(finalArchiveAttach.getD1()));
+			//26.加计扣除项目技术鉴定资料:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "26.加计扣除项目技术鉴定资料"), Collections.singletonList(finalArchiveAttach.getD2()));
+			//27.其他高新备查资料:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "27.其他高新备查资料"), Collections.singletonList(finalArchiveAttach.getD11()));
+			//28.其他加计扣除备查资料:附件补充
+			this.downloadAttachFiles(Paths.get(basePath.toString(), "28.其他加计扣除备查资料"), Collections.singletonList(finalArchiveAttach.getD12()));
+		});
+		Date date = new Date();
+//		CompletableFuture.allOf(task1, task2, task3,task4,task5,task6,task7,task8,task9,task10,task11,task12,task13,task14,task15,task16,task17).join();
+		CompletableFuture.allOf(task1, task2, task5,task6,task7,task8,task9,task10,task11,task12,task13,task14,task15,task16,task17).join();
+//		CompletableFuture.allOf(task1, task2, task5, task6).join();
+		long l = new Date().getTime() - date.getTime();
+
+		String zipPath = basePath+".zip";
+		try {
+			ZipUtil.zip(basePath.toString(), zipPath);
+		} catch (IORuntimeException e) {
+			log.error("创建zip文件失败,{}",e.getLocalizedMessage());
+		}
+
+		DownloadTask task = new DownloadTask();
+		task.setId(taskId);
+		//设置任务状态为 已完成
+		task.setStatus(2);
+		task.setZipUrl(zipPath);
+		downloadTaskMapper.updateById(task);
+		System.out.println("一键导出耗时:" + l / 1000 + "秒");
 	}
 
 	private boolean generateD14(Path path, String year) {
@@ -404,7 +468,7 @@ public class ArchiveServiceImpl implements IArchiveService {
 	private boolean generateD1(Path path, String year) {
 		try {
 			FileUtil.mkdir(path);
-			SettingEntity one = settingMapper.selectOne(Wrappers.<SettingEntity>lambdaQuery().eq(SettingEntity::getYearAndMonth, year));
+			SettingEntity one = settingMapper.selectOne(Wrappers.<SettingEntity>lambdaQuery().eq(SettingEntity::getYearAndMonth, year).eq(SettingEntity::getTenantId, SecureUtil.getTenantId()));
 			if (Func.notNull(one) && Func.isNotBlank(one.getHighTechUrl())) {
 				String[] urlList = one.getHighTechUrl().split(",");
 				int i = 1;
@@ -516,7 +580,6 @@ public class ArchiveServiceImpl implements IArchiveService {
 				List<XmJdxbgVO> xmJdxbgVOList = xmJdxbgService.selectByCondition(Condition.getPage(new Query().setCurrent(1).setSize(Integer.MAX_VALUE)), xmJdxbgEntity).getRecords();
 
 				Map<String, Integer> fileNameMap = new ConcurrentHashMap<>();
-
 				List<String> attachList = new ArrayList<>();
 				for (XmJdxbgVO vo : xmJdxbgVOList) {
 					XmEntity xmEntity = vo.getXmEntity();
@@ -541,7 +604,6 @@ public class ArchiveServiceImpl implements IArchiveService {
 				XmBgrzEntity xmBgrzEntity = new XmBgrzEntity();
 				xmBgrzEntity.setXmId(xm.getXmId());
 				List<XmBgrzVO> xmBgrzVOList = xmBgrzService.selectBgrzPage(xmBgrzEntity, Condition.getPage(new Query().setCurrent(1).setSize(Integer.MAX_VALUE))).getRecords();
-
 				attachList = new ArrayList<>();
 				for (XmBgrzVO vo : xmBgrzVOList) {
 					String fileName = xm.getXmmc() + "-" + vo.getZdmcStr() + "变更" + DateUtil.format(vo.getBgsxsj(), DateUtil.PATTERN_YYYYMMDD) + ".doc";
@@ -755,15 +817,12 @@ public class ArchiveServiceImpl implements IArchiveService {
 		return true;
 	}
 
-	private boolean generateD17(String year, Integer type, String title) {
+	private boolean generateD17(Path path, String year, Integer type) {
 		//17 会计口径研发费用附件凭证资料及相关说明
 		//18 高新研发费用附件凭证资料及相关说明
 		//19 加计扣除研发费用附件凭证资料及相关说明
-		Path path = Paths.get(archiveDir, SecureUtil.getTenantId(), year, title);
-
 		try {
 			FileUtil.mkdir(path);
-
 			XmFinanceEntity dto = new XmFinanceEntity();
 			dto.setYearAndMonth(year);
 			dto.setType(type);
@@ -919,13 +978,11 @@ public class ArchiveServiceImpl implements IArchiveService {
 		}
 	}
 
-	private boolean generateD20(String year, String title) {
+	private boolean generateD20(Path path, String year) {
 		//A107012研发费用加计扣除优惠明细表
-		Path path = Paths.get(archiveDir, SecureUtil.getTenantId(), year, title);
-		try {
+ 		try {
 			FileUtil.mkdir(path);
-
-			try (FileOutputStream out = new FileOutputStream(Paths.get(path.toString(), title + ".xlsx").toString())) {
+			try (FileOutputStream out = new FileOutputStream(Paths.get(path.toString(), "A107012研发费用加计扣除优惠明细表.xlsx").toString())) {
 				enterpriseInfoService.exportYffyjjkcyhmxbA107012(out, year);
 			}
 		} catch (Exception e) {

+ 1 - 1
kd-service/kd-scientific/src/main/resources/application-home.yml

@@ -10,4 +10,4 @@ spring:
     password: ${kd.datasource.test.password}
 
 archive:
-  dir: d:/archive
+  dir: F:/archive