Selaa lähdekoodia

数据预处理,添加章级合计,总合计

MaiXinRong 5 vuotta sitten
vanhempi
commit
18169f804f
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      app/lib/rpt_data_analysis.js

+ 7 - 0
app/lib/rpt_data_analysis.js

@@ -777,6 +777,7 @@ const addSumChapter = {
         if (!gclData || !data.tender_info) return;
 
         const chapters = ctx.helper._.uniq(ctx.helper._.map(gclData, options.chapter));
+        const finalSum = options.sum ? {name: options.sum.name, chapterNum: 100000, chapterPart: 1} : null;
         for (const chapter of chapters) {
             const chapterInfo = data.tender_info.chapter.find(function (x) { return x.code === chapter});
             const chapterOptions = chapterInfo ? options.stdChapter : options.otherChapter;
@@ -790,6 +791,9 @@ const addSumChapter = {
                 cg.chapterNum = parseInt(cg[options.chapter]);
                 for (const f of options.fields) {
                     sum[f] = ctx.helper.add(sum[f], cg[f]);
+                    if (finalSum) {
+                        finalSum[f] = ctx.helper.add(finalSum[f], cg[f]);
+                    }
                 }
             }
             if (chapterOptions.sum !== undefined) {
@@ -808,6 +812,9 @@ const addSumChapter = {
                 gclData.push(title);
             }
         }
+        if (finalSum) {
+            gclData.push(finalSum);
+        }
         gclData.sort(function (a, b) {
             if (a.chapter !== b.chapter) {
                 return a.chapterNum - b.chapterNum;