Browse Source

fix: volume duplicate author file

ryanemax 5 months ago
parent
commit
23cd05edb7
2 changed files with 15 additions and 7 deletions
  1. 13 6
      server/cloud/tbook/func-tbook-export.js
  2. 2 1
      server/cloud/tbook/test/test-export.js

+ 13 - 6
server/cloud/tbook/func-tbook-export.js

@@ -234,7 +234,8 @@ export async function exportProcessReportDocs(processId,bookList) {
 
 module.exports.exportProcessReportDocs = exportProcessReportDocs
 
-function fixVolumeData(json,volumeData,index,totalJson){
+function fixVolumeData(json,volumeData,index,totalJson,isChildren){
+    let volumeIndex = index;
     json.index = index + 1;
     // 教材基本信息
 
@@ -346,8 +347,11 @@ function fixVolumeData(json,volumeData,index,totalJson){
          item.index = index + 1
          item.birth = toYearMonth(item?.birth)
          if(item?.examine){
-            // totalJson.examineList = pushDistinctItem(totalJson.examineList,item) // 名称去重
-            totalJson.examineList.push(item); // 全量导出
+            if(!(isChildren&&volumeIndex==0)){ // 子册第一册不重复导出
+                // totalJson.examineList = pushDistinctItem(totalJson.examineList,item) // 名称去重
+                console.log(item)
+                totalJson.examineList.push(item); // 全量导出
+            }
          }
          return item
      })
@@ -357,8 +361,11 @@ function fixVolumeData(json,volumeData,index,totalJson){
     // 其他编者政治审查表
     totalJson.otherList = totalJson.otherList || []
     if(volumeData?.otherEditor){
-        // totalJson.otherList = pushDistinctItem(totalJson.otherList,volumeData?.otherEditor) // 名称去重
-        totalJson.otherList.push(volumeData?.otherEditor); //全量导出
+        if(!(isChildren&&volumeIndex==0)){ // 子册第一册不重复导出
+            // totalJson.otherList = pushDistinctItem(totalJson.otherList,volumeData?.otherEditor) // 名称去重
+            console.log(volumeData?.otherEditor)
+            totalJson.otherList.push(volumeData?.otherEditor); //全量导出
+        }
     }
 
     // 成果列表
@@ -434,7 +441,7 @@ function renderReportDocsByTextbook(textbook){
     for (let index = 0; index < 12; index++) {
         if(json?.childrens?.[index]){
             let volumeData = json?.childrens?.[index]
-            volumeData = fixVolumeData(volumeData,volumeData,index,json)
+            volumeData = fixVolumeData(volumeData,volumeData,index,json,true)
             volumeList.push(volumeData)
         }
     }

+ 2 - 1
server/cloud/tbook/test/test-export.js

@@ -50,7 +50,8 @@ async function main(){
         // console.log(await exportProcessReportDocs(null,["TsjBrECA4m"])) // pdf 加密
         // console.log(await exportProcessReportDocs(null,["z7yhFusOns"])) 
         // console.log(await exportProcessReportDocs(null,["ybzJWkXqQG"])) 
-        console.log(await exportProcessReportDocs(null,["4UAwQ4nc5A"])) 
+        // console.log(await exportProcessReportDocs(null,["4UAwQ4nc5A"])) 
+        console.log(await exportProcessReportDocs(null,["ybzJWkXqQG"])) 
         
         
         // console.log(await exportProcessReportDocs(null,["3wJSkW9HNV"]))