|
|
@@ -143,7 +143,7 @@ public class ArchiveServiceImpl implements IArchiveService {
|
|
|
throw new ServiceException("参数year为年份,如2025");
|
|
|
}
|
|
|
|
|
|
- ArchiveAttachEntity attach = attachMapper.selectOne(Wrappers.<ArchiveAttachEntity>lambdaQuery().eq(ArchiveAttachEntity::getYearAndMonth, year));
|
|
|
+ ArchiveAttachEntity attach = getArchiveAttachEntity(year);
|
|
|
if (Func.isNull(attach)) {
|
|
|
attach = new ArchiveAttachEntity();
|
|
|
}
|
|
|
@@ -299,7 +299,7 @@ public class ArchiveServiceImpl implements IArchiveService {
|
|
|
}
|
|
|
Date date = new Date();
|
|
|
|
|
|
- ArchiveAttachEntity archiveAttach = attachMapper.selectOne(Wrappers.<ArchiveAttachEntity>lambdaQuery().eq(ArchiveAttachEntity::getYearAndMonth, year));
|
|
|
+ ArchiveAttachEntity archiveAttach = getArchiveAttachEntity(year);
|
|
|
if (archiveAttach == null) {
|
|
|
archiveAttach = new ArchiveAttachEntity();
|
|
|
}
|
|
|
@@ -523,6 +523,227 @@ public class ArchiveServiceImpl implements IArchiveService {
|
|
|
downloadTaskMapper.updateById(task);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void downloadCenterFiles(DownloadTask task) {
|
|
|
+ String year = task.getYearAndMonth();
|
|
|
+ if (Func.isBlank(year)) {
|
|
|
+ throw new ServiceException("参数year不能为空");
|
|
|
+ }
|
|
|
+ String dir = "";
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ ArchiveAttachEntity archiveAttach = getArchiveAttachEntity(year);
|
|
|
+ if (archiveAttach == null) {
|
|
|
+ archiveAttach = new ArchiveAttachEntity();
|
|
|
+ }
|
|
|
+ Path basePath = Paths.get(archiveDir, UUID.randomUUID().toString());
|
|
|
+ if (FileUtil.exist(basePath.toString())) {
|
|
|
+ FileUtil.del(basePath.toString());
|
|
|
+ }
|
|
|
+ RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
|
|
+ ArchiveAttachEntity finalArchiveAttach = archiveAttach;
|
|
|
+ List<CompletableFuture<Void>> futureList = new ArrayList<>();
|
|
|
+ if (task.getType() == 1){
|
|
|
+ //1 高新技术企业资格证书:基础资源管理-企业基本信息-高企证书上传(按年度)。未上传则为空
|
|
|
+ dir = "1.高新技术企业资格证书";
|
|
|
+ generateD1(Paths.get(basePath.toString(), dir), year);
|
|
|
+ }else if (task.getType() == 2){
|
|
|
+ //2 高新技术企业认定资料:附件补充
|
|
|
+ dir = "2.高新技术企业认定资料";
|
|
|
+ Path path2 = FileUtil.mkdir(Paths.get(basePath.toString(), "2.高新技术企业认定资料"));
|
|
|
+ this.downloadAttachFiles(path2, Collections.singletonList(finalArchiveAttach.getD3()));
|
|
|
+ }else if (task.getType() == 3){
|
|
|
+ //3 加计扣除情况说明:附件补充
|
|
|
+ dir = "3.加计扣除情况说明";
|
|
|
+ Path path3 = FileUtil.mkdir(Paths.get(basePath.toString(), "3.加计扣除情况说明"));
|
|
|
+ this.downloadAttachFiles(path3, Collections.singletonList(finalArchiveAttach.getD10()));
|
|
|
+ }else if (task.getType() == 4){
|
|
|
+ //4 研发立项决议文件:附件补充
|
|
|
+ dir = "4.研发立项决议文件";
|
|
|
+ Path path4 = FileUtil.mkdir(Paths.get(basePath.toString(), "4.研发立项决议文件"));
|
|
|
+ this.downloadAttachFiles(path4, Collections.singletonList(finalArchiveAttach.getD13()));
|
|
|
+ }else if (task.getType() == 5){
|
|
|
+ //5 高新研发项目汇总表:对外报表-高新口径研发费用报表-高新-研发项目清单表
|
|
|
+ dir = "5.高新研发项目汇总表";
|
|
|
+ generateD5(Paths.get(basePath.toString(), "5.高新研发项目汇总表"), year, 3);
|
|
|
+ }else if (task.getType() == 6){
|
|
|
+ //6 加计扣除研发项目汇总表:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单表
|
|
|
+ dir = "6.加计扣除研发项目汇总表";
|
|
|
+ generateD5(Paths.get(basePath.toString(), "6.加计扣除研发项目汇总表"), year, 2);
|
|
|
+ }else if (task.getType() == 7){
|
|
|
+ //7 高新研发项目全套技术资料:对外报表-高新口径研发费用报表-高新-研发项目清单表
|
|
|
+ dir = "7.高新研发项目全套技术资料";
|
|
|
+ Path path7 = FileUtil.mkdir(Paths.get(basePath.toString(), "7.高新研发项目全套技术资料"));
|
|
|
+ XmFinanceEntity dto = new XmFinanceEntity();
|
|
|
+ dto.setYearAndMonth(year);
|
|
|
+ dto.setType(3);
|
|
|
+ List<XmFinanceEntity> list = xmFinanceService.selectXmFinanceList(dto);
|
|
|
+ AtomicInteger iii = new AtomicInteger(1);
|
|
|
+ for (XmFinanceEntity xm : list) {
|
|
|
+ futureList.add(CompletableFuture.runAsync(() -> {
|
|
|
+ RequestContextHolder.setRequestAttributes(requestAttributes);
|
|
|
+ generateD7(path7, iii.getAndIncrement(), xm);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ }else if (task.getType() == 8){
|
|
|
+ Path path8 = FileUtil.mkdir(Paths.get(basePath.toString(), "8.加计扣除研发项目全套技术资料"));
|
|
|
+ dir = "8.加计扣除研发项目全套技术资料";
|
|
|
+ XmFinanceEntity dto = new XmFinanceEntity();
|
|
|
+ dto.setYearAndMonth(year);
|
|
|
+ dto.setType(2);
|
|
|
+ List<XmFinanceEntity> list = xmFinanceService.selectXmFinanceList(dto);
|
|
|
+ AtomicInteger jjj = new AtomicInteger(1);
|
|
|
+ for (XmFinanceEntity xm : list) {
|
|
|
+ futureList.add(CompletableFuture.runAsync(() -> {
|
|
|
+ RequestContextHolder.setRequestAttributes(requestAttributes);
|
|
|
+ generateD7(path8, jjj.getAndIncrement(), xm);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ }else if (task.getType() == 9){
|
|
|
+ //9 高新研发人员与科技人员资料:改成高新科技人员资料:即科技人员管理-年高新科技人员汇总表资料表,选出:对外报表-高新口径研发费用报表-高新-研发项目清单中项目人员汇总
|
|
|
+ dir = "9.高新科技人员资料";
|
|
|
+ generateD9(Paths.get(basePath.toString(), "9.高新科技人员资料"), year, finalArchiveAttach.getD6());
|
|
|
+ }else if (task.getType() == 10){
|
|
|
+ //10 加计扣除研发人员与科技人员资料:改成加计扣除项目科研人员资料:即科技人员管理-项目人员汇总表,选出:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中项目人员汇总
|
|
|
+ dir = "10.加计扣除项目科研人员资料";
|
|
|
+ generateD10(Paths.get(basePath.toString(), "10.加计扣除项目科研人员资料"), year);
|
|
|
+ }else if (task.getType() == 11){
|
|
|
+ //11 全部知识产权资料(汇总表、附件):当年度所有科研成果列表导出,及所有附件资料的下载
|
|
|
+ dir = "11.全部知识产权资料";
|
|
|
+ generateD11(Paths.get(basePath.toString(), "11.全部知识产权资料"), 0, year);
|
|
|
+ }else if (task.getType() == 12){
|
|
|
+ //12 高新项目知识产权资料(汇总表、附件):对外报表-高新口径研发费用报表-高新-研发项目清单中的科研成果列表及所有附件资料的下载
|
|
|
+ dir = "12.高新项目知识产权资料";
|
|
|
+ generateD11(Paths.get(basePath.toString(), "12.高新项目知识产权资料"), 2, year);
|
|
|
+ }else if (task.getType() == 13){
|
|
|
+ //13 加计扣除项目知识产权资料(汇总表、附件):对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中的科研成果列表及所有附件资料的下载
|
|
|
+ generateD11(Paths.get(basePath.toString(), "13.加计扣除项目知识产权资料"), 3, year);
|
|
|
+ }else if (task.getType() == 14){
|
|
|
+ //14 会计口径研发费用辅助账:对外报表-会计加计扣除口径研发费用报表-会计-研发支出辅助账
|
|
|
+ dir = "14.会计口径研发费用辅助账";
|
|
|
+ generateD14(Paths.get(basePath.toString(), "14.会计口径研发费用辅助账"), year);
|
|
|
+ }else if (task.getType() == 15){
|
|
|
+ //15 加计扣除项目知识产权资料(汇总表、附件):对外报表-加计扣除口径研发费用报表-加计扣除-研发项目清单中的科研成果列表及所有附件资料的下载
|
|
|
+ dir = "15.加计扣除项目知识产权资料";
|
|
|
+ generateD15(Paths.get(basePath.toString(), "15.高新口径研发费用辅助账"), year, finalArchiveAttach.getD9());
|
|
|
+ }else if (task.getType() == 16){
|
|
|
+ //16 高新项目知识产权资料(汇总表、附件):对外报表-高新口径研发费用报表-高新-研发项目清单中的科研成果列表及所有附件资料的下载
|
|
|
+ dir = "16.高新项目知识产权资料";
|
|
|
+ generateD16(Paths.get(basePath.toString(), "16.加计扣除口径研发费用辅助账"), year);
|
|
|
+ }else if (task.getType() == 17){
|
|
|
+ //17.会计口径研发费用附件凭证资料及相关说明:对外报表-会计加计扣除口径研发费用报表-会计-研发项目(见列表详细)
|
|
|
+ Path path17 = FileUtil.mkdir(Paths.get(basePath.toString(), "17.会计口径研发费用附件支撑资料及相关说明"));
|
|
|
+ dir = "17.会计口径研发费用附件支撑资料及相关说明";
|
|
|
+ try {
|
|
|
+ XmFinanceEntity dto2 = new XmFinanceEntity();
|
|
|
+ dto2.setYearAndMonth(year);
|
|
|
+ dto2.setType(1);
|
|
|
+ generateD17(path17, xmFinanceService.selectXmFinanceList(dto2), year, futureList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }else if (task.getType() == 18){
|
|
|
+ //18.高新研发费用附件凭证资料及相关说明:对外报表-高新口径研发费用报表-高新-研发项目(见列表详细)
|
|
|
+ dir = "18.高新研发费用附件支持资料及相关说明";
|
|
|
+ Path path18 = FileUtil.mkdir(Paths.get(basePath.toString(), "18.高新研发费用附件支持资料及相关说明"));
|
|
|
+ try {
|
|
|
+ XmFinanceEntity dto2 = new XmFinanceEntity();
|
|
|
+ dto2.setYearAndMonth(year);
|
|
|
+ dto2.setType(3);
|
|
|
+ generateD17(path18, xmFinanceService.selectXmFinanceList(dto2), year, futureList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }else if (task.getType() == 19){
|
|
|
+ //19.加计扣除研发费用附件凭证资料及相关说明:对外报表-加计扣除口径研发费用报表-加计扣除-研发项目(见列表详细)
|
|
|
+ dir = "19.加计扣除研发费用附件支持资料及相关说明";
|
|
|
+ Path path19 = FileUtil.mkdir(Paths.get(basePath.toString(), "19.加计扣除研发费用附件支撑资料及相关说明"));
|
|
|
+ try {
|
|
|
+ XmFinanceEntity dto2 = new XmFinanceEntity();
|
|
|
+ dto2.setYearAndMonth(year);
|
|
|
+ dto2.setType(2);
|
|
|
+ generateD17(path19, xmFinanceService.selectXmFinanceList(dto2), year, futureList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }else if (task.getType() == 20){
|
|
|
+ dir = "20.A107012研发费用加计扣除优惠明细表";
|
|
|
+ futureList.add(CompletableFuture.runAsync(() -> {
|
|
|
+ RequestContextHolder.setRequestAttributes(requestAttributes);
|
|
|
+ //20.A107012研发费用加计扣除优惠明细表:A107012导出表
|
|
|
+ generateD20(Paths.get(basePath.toString(), "20.A107012研发费用加计扣除优惠明细表"), year);
|
|
|
+ }));
|
|
|
+ }else if (task.getType() == 21){
|
|
|
+ //21.当年和前两个会计年度研发费用总额及占同期销售收入比例的说明:附件补充
|
|
|
+ dir = "21.当年和前两个会计年度研发费用总额及占同期销售收入比例的说明";
|
|
|
+ Path path21 = FileUtil.mkdir(Paths.get(basePath.toString(), "21.当年和前两个会计年度研发费用总额及占同期销售收入比例的说明"));
|
|
|
+ this.downloadAttachFiles(path21, Collections.singletonList(finalArchiveAttach.getD7()));
|
|
|
+ }else if (task.getType() == 22){
|
|
|
+ //22.年度主要产品(服务)发挥核心支持作用的技术属于《国家重点支持的高新技术领域》规定范围的说明:附件补充
|
|
|
+ dir = "22.年度主要产品(服务)发挥核心支持作用的技术属于《国家重点支持的高新技术领域》规定范围的说明";
|
|
|
+ Path path22 = FileUtil.mkdir(Paths.get(basePath.toString(), "22.年度主要产品(服务)发挥核心支持作用的技术属于《国家重点支持的高新技术领域》规定范围的说明"));
|
|
|
+ this.downloadAttachFiles(path22, Collections.singletonList(finalArchiveAttach.getD4()));
|
|
|
+ }else if (task.getType() == 23){
|
|
|
+ //23.高新技术产品(服务)及对应收入资料:附件补充
|
|
|
+ Path path23 = FileUtil.mkdir(Paths.get(basePath.toString(), "23.高新技术产品(服务)及对应收入资料"));
|
|
|
+ dir = "23.高新技术产品(服务)及对应收入资料";
|
|
|
+ this.downloadAttachFiles(path23, Collections.singletonList(finalArchiveAttach.getD5()));
|
|
|
+ }else if (task.getType() == 24){
|
|
|
+ //24.研发管理制度:附件补充
|
|
|
+ dir = "24.研发管理制度";
|
|
|
+ Path path24 = FileUtil.mkdir(Paths.get(basePath.toString(), "24.研发管理制度"));
|
|
|
+ this.downloadAttachFiles(path24, Collections.singletonList(finalArchiveAttach.getD8()));
|
|
|
+ }else if (task.getType() == 25){
|
|
|
+ //25.高新项目技术鉴定资料:附件补充
|
|
|
+ dir = "25.高新项目技术鉴定资料";
|
|
|
+ Path path25 = FileUtil.mkdir(Paths.get(basePath.toString(), "25.高新项目技术鉴定资料"));
|
|
|
+ this.downloadAttachFiles(path25, Collections.singletonList(finalArchiveAttach.getD1()));
|
|
|
+ }else if (task.getType() == 26){
|
|
|
+ //26.加计扣除项目技术鉴定资料:附件补充
|
|
|
+ dir = "26.加计扣除项目技术鉴定资料";
|
|
|
+ Path path26 = FileUtil.mkdir(Paths.get(basePath.toString(), "26.加计扣除项目技术鉴定资料"));
|
|
|
+ this.downloadAttachFiles(path26, Collections.singletonList(finalArchiveAttach.getD2()));
|
|
|
+ }else if (task.getType() == 27){
|
|
|
+ //27.其他高新备查资料:附件补充
|
|
|
+ dir = "27.其他高新备查资料";
|
|
|
+ Path path27 = FileUtil.mkdir(Paths.get(basePath.toString(), "27.其他高新备查资料"));
|
|
|
+ this.downloadAttachFiles(path27, Collections.singletonList(finalArchiveAttach.getD11()));
|
|
|
+ }else if (task.getType() == 28){
|
|
|
+ //28.其他加计扣除备查资料:附件补充
|
|
|
+ dir = "28.其他加计扣除备查资料";
|
|
|
+ Path path28 = FileUtil.mkdir(Paths.get(basePath.toString(), "28.其他加计扣除备查资料"));
|
|
|
+ this.downloadAttachFiles(path28, Collections.singletonList(finalArchiveAttach.getD12()));
|
|
|
+ }else {
|
|
|
+ throw new ServiceException("参数type错误");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])).join();
|
|
|
+ log.info("导出耗时:{}", (new Date().getTime() - date.getTime()) / 1000 + "秒");
|
|
|
+
|
|
|
+
|
|
|
+ Path zipPath = Paths.get(archiveDir,year+"年" + dir + ".zip");
|
|
|
+ try {
|
|
|
+ ZipUtil.zip(basePath.toString(), zipPath.toString());
|
|
|
+ } catch (IORuntimeException e) {
|
|
|
+ log.error("创建zip文件失败,{}", e.getLocalizedMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //设置任务状态为 已完成
|
|
|
+ task.setStatus(2);
|
|
|
+ task.setDoneTime(new Date());
|
|
|
+ task.setZipUrl(zipPath.toString());
|
|
|
+ task.setFileSize(FileUtil.size(FileUtil.file(zipPath.toString())));
|
|
|
+ downloadTaskMapper.updateById(task);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ArchiveAttachEntity getArchiveAttachEntity(String year) {
|
|
|
+ ArchiveAttachEntity archiveAttach = attachMapper.selectOne(Wrappers.<ArchiveAttachEntity>lambdaQuery().eq(ArchiveAttachEntity::getYearAndMonth, year));
|
|
|
+ return archiveAttach;
|
|
|
+ }
|
|
|
+
|
|
|
private void generateD17(Path path, List<XmFinanceEntity> list, String year, List<CompletableFuture<Void>> futureList) {
|
|
|
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
|
|
for (XmFinanceEntity xm : list) {
|
|
|
@@ -912,7 +1133,9 @@ 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).eq(SettingEntity::getTenantId, SecureUtil.getTenantId()));
|
|
|
+ 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;
|