|
@@ -9,7 +9,7 @@ if(!fs.existsSync(TemplateDocxDir)){
|
|
|
}
|
|
|
const tempDir = path.join(__dirname , "temp");
|
|
|
|
|
|
-
|
|
|
+const crypto = require('crypto');
|
|
|
|
|
|
/**
|
|
|
* 常用Word字符
|
|
@@ -212,7 +212,10 @@ export async function exportProcessReportDocs(processId,bookList) {
|
|
|
if(docsList?.length){
|
|
|
let now = new Date();
|
|
|
let fileList = docsList?.map(item=>item?.pdfPath);
|
|
|
- let zipName = `申报书导出-${now.getFullYear()}${now.getMonth()+1}${now.getDate()}-${now.getHours()}${now.getMinutes()}${now.getSeconds()}.zip`
|
|
|
+ // zip包md5生成
|
|
|
+ let md5 = crypto.createHash('md5');
|
|
|
+ let fileListMd5 = md5.update(fileList?.join("")).digest('hex')
|
|
|
+ let zipName = `申报书导出-${now.getFullYear()}${now.getMonth()+1}${now.getDate()}${now.getHours()}${now.getMinutes()}${now.getSeconds()}${now.getMilliseconds()}-${fileListMd5}.zip`
|
|
|
zipPath = await createZip(fileList,zipName,{tempDir:null})
|
|
|
if(zipPath){
|
|
|
zipUrl = (await uploadFileToOSS(zipPath))?.url || null
|
|
@@ -222,7 +225,7 @@ export async function exportProcessReportDocs(processId,bookList) {
|
|
|
fs.rmSync(path.dirname(tempFile),{recursive:true,force:true});
|
|
|
})
|
|
|
}
|
|
|
- docsList = docsList.map(item=>{return {code:item.code,title:item.title,url:item?.url,urlPdf:item?.urlPdf}})
|
|
|
+ docsList = docsList.map(item=>{return {code:item.code,objectId:item?.objectId,title:item.title,url:item?.url,urlPdf:item?.urlPdf}})
|
|
|
}
|
|
|
|
|
|
let result = {
|
|
@@ -534,7 +537,7 @@ function renderReportDocsByTextbook(textbook){
|
|
|
}
|
|
|
|
|
|
|
|
|
- let bookTempDir = path.join(tempDir,bookid)
|
|
|
+ let bookTempDir = path.join(tempDir,json?.objectId)
|
|
|
if(!fs.existsSync(bookTempDir)) fs.mkdirSync(bookTempDir)
|
|
|
|
|
|
|
|
@@ -629,9 +632,9 @@ function renderReportDocsByTextbook(textbook){
|
|
|
|
|
|
// mergeFiles 处理七八九是否签名或后置问题
|
|
|
let lastPageList = []
|
|
|
- let docx7 = await getPageDocx(bookid,"七",bookData);
|
|
|
- let docx8 = await getPageDocx(bookid,"八",bookData);
|
|
|
- let docx9 = await getPageDocx(bookid,"九",bookData);
|
|
|
+ let docx7 = await getPageDocx(json?.objectId,bookid,"七",bookData);
|
|
|
+ let docx8 = await getPageDocx(json?.objectId,bookid,"八",bookData);
|
|
|
+ let docx9 = await getPageDocx(json?.objectId,bookid,"九",bookData);
|
|
|
lastPageList.push(json?.authorSignPDF?.url||docx7);
|
|
|
lastPageList.push(json?.unitMaterial?.url||docx8);
|
|
|
lastPageList.push(docx9);
|
|
@@ -668,13 +671,14 @@ function renderReportDocsByTextbook(textbook){
|
|
|
pdfPath = await docxToPdf(filePath,pdfPath,options) || filePath // 成功用pdf,失败继续用docx
|
|
|
console.log("PDF CREATED:",filePath)
|
|
|
if(pdfPath){
|
|
|
- urlPdf = (await uploadFileToOSS(pdfPath))?.url || null
|
|
|
+ urlPdf = (await uploadFileToOSS(pdfPath,json?.objectId))?.url || null
|
|
|
}
|
|
|
}catch(err){
|
|
|
console.error(err)
|
|
|
}
|
|
|
resolve({
|
|
|
code:bookid,
|
|
|
+ objectId:json?.objectId,
|
|
|
title:json?.title,
|
|
|
filePath,
|
|
|
pdfPath,
|
|
@@ -685,10 +689,10 @@ function renderReportDocsByTextbook(textbook){
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-async function getPageDocx(bookid,pageName,bookData){
|
|
|
+async function getPageDocx(objectId,bookid,pageName,bookData){
|
|
|
let tplPath = path.join(TemplateDocxDir,`模板-本科教材申报书-${pageName}.docx`);
|
|
|
let title = bookData?.title?.replaceAll("/","")
|
|
|
- let tempFileName = path.join(`${bookid}_${title}_申报书及附件_${pageName}.docx`);
|
|
|
+ let tempFileName = path.join(objectId,`${bookid}_${title}_申报书及附件_${pageName}.docx`);
|
|
|
let filePath = renderDocx(tplPath,tempFileName,bookData);
|
|
|
return filePath;
|
|
|
// 转pdf
|