2 次代码提交 825d3ad0b7 ... 9dd7ceb13d

作者 SHA1 备注 提交日期
  ryanemax 9dd7ceb13d Merge branch 'master' of http://git.fmode.cn:3000/bin/edu-textbook 2 月之前
  ryanemax a4eec1a151 fix: examine List in volume 2 月之前
共有 2 个文件被更改,包括 27 次插入14 次删除
  1. 25 13
      server/cloud/tbook/func-tbook-export.js
  2. 2 1
      server/cloud/tbook/test/test-export.js

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

@@ -229,7 +229,7 @@ export async function exportProcessReportDocs(processId,bookList) {
 
 module.exports.exportProcessReportDocs = exportProcessReportDocs
 
-function fixVolumeData(json,volumeData,index){
+function fixVolumeData(json,volumeData,index,totalJson){
     json.index = index + 1;
     // 教材基本信息
 
@@ -325,9 +325,8 @@ function fixVolumeData(json,volumeData,index){
     json.isBSQT = circleCheck[(importantProject?.indexOf("其他省部级")>-1)?1:0];
     json.isFirstNot = circleCheck[volumeData?.importantProject?.length > 0?0:1];
     // 作者列表 + 政治审查表
-    json.examineList = json.examineList || []
-    let examineMap = {}
-    json.examineList.forEach(item=>examineMap[item]=true)
+    totalJson.examineList = totalJson.examineList || []
+    // console.log(volumeData?.authorList)
     for (let index = 0; index < 6; index++) { // 补充空值
         if(!volumeData?.authorList?.[index]){
          volumeData.authorList.push({name:"",unit:"",birth:"",nationality:"",job:"",title:"",mobile:"",email:"",work:""})
@@ -337,17 +336,17 @@ function fixVolumeData(json,volumeData,index){
          item.index = index + 1
          item.birth = toYearMonth(item?.birth)
          if(item?.examine){
-            examineMap[item?.examine] = true;
+            totalJson.examineList = pushDistinctItem(totalJson.examineList,item)
          }
          return item
      })
+    //  console.log(totalJson.examineList)
      json.authorList = volumeData?.authorList;
-     json.examineList = Object.keys(examineMap)
 
     // 其他编者政治审查表
-    json.otherList = json.otherList || []
+    totalJson.otherList = totalJson.otherList || []
     if(volumeData?.otherEditor){
-        json.otherList.push(volumeData?.otherEditor)
+        totalJson.otherList = pushDistinctItem(totalJson.otherList,volumeData?.otherEditor)
     }
 
     // 成果列表
@@ -379,7 +378,19 @@ function fixVolumeData(json,volumeData,index){
      json.courses = volumeData?.courses;
      return json
 }
-
+function pushDistinctItem(list,item){
+    let isDistinct = true
+    if(list?.indexOf(item)>-1){
+        isDistinct = false;
+    }
+    if(list?.find(old=>old?.name&&old?.name==item?.name)){
+        isDistinct = false;
+    }
+    if(isDistinct){
+        list.push(item);
+    }
+    return list
+}
 function renderReportDocsByTextbook(textbook){
     console.log("renderReportDocsByTextbook")
     return new Promise(async (resolve)=>{
@@ -406,12 +417,12 @@ function renderReportDocsByTextbook(textbook){
     // 教材适用
     let characteristic = (json?.characteristic?.filter(item=>item?.checked).map(item=>item.label) || [])?.join(",")
 
-    json = fixVolumeData(json,book1Data,0)
+    json = fixVolumeData(json,book1Data,0,json)
     let volumeList = []
     for (let index = 0; index < 12; index++) {
         if(json?.childrens?.[index]){
             let volumeData = json?.childrens?.[index]
-            volumeData = fixVolumeData(volumeData,volumeData,index)
+            volumeData = fixVolumeData(volumeData,volumeData,index,json)
             volumeList.push(volumeData)
         }
     }
@@ -450,9 +461,10 @@ function renderReportDocsByTextbook(textbook){
     // console.log("json.examineList");
     // console.log(json.examineList);
 
-    json.examineList.forEach(fileurl=>{
-        if(fileurl) mergeFiles.push(fileurl)
+    json.examineList.forEach(author=>{
+        if(author?.examine) mergeFiles.push(author?.examine)
     })
+    // console.log(mergeFiles)
 
     let otherMap = {}
     json?.otherList?.forEach(item=>{ // 合并不重复其他编者政治审查表

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

@@ -23,7 +23,8 @@ async function main(){
         // console.log("测试列表")
         // console.log(await exportProcessReportDocs(null,["9V575dapEM"]))
         // console.log(await exportProcessReportDocs(null,["c2WUE5PgCo"]))
-        console.log(await exportProcessReportDocs(null,["KvvN9lWhri"]))
+        console.log(await exportProcessReportDocs(null,["R9r0XtMsK3"]))
+        // console.log(await exportProcessReportDocs(null,["KvvN9lWhri"]))
         // console.log(await exportProcessReportDocs(null,["F8eiOAfuC3"]))
         
         // console.log(await exportProcessReportDocs(null,["Oa1yB6n64u","j4pt2MMTXM","jAMGxwrl1F","BwZpEoOtS8","X10kCktA0r"]))