Tony Kang 2 년 전
부모
커밋
5c772bbfa5
1개의 변경된 파일69개의 추가작업 그리고 9개의 파일을 삭제
  1. 69 9
      web/building_saas/standard_interface/export/shandong_common.js

+ 69 - 9
web/building_saas/standard_interface/export/shandong_common.js

@@ -147,8 +147,7 @@ INTERFACE_EXPORT = (() => {
       "暂列金额(不含计日工总额)": "16",
       "投标报价": "17"
     } 
-  
-  
+
     const ratioCodeMap = { 
       "01ZJF":"0",
       "02JXF":"1",
@@ -1478,7 +1477,7 @@ INTERFACE_EXPORT = (() => {
             if (bill.jobContent && bill.jobContent.length > 0) {
               jobContent = bill.jobContent.toString();
             } else {
-              jobContent = bill.jobContentText;
+              jobContent = (bill.jobContentText) ? bill.jobContentText : '';
             }
             let attrs = [
               {name: 'ItemNo', value: sno + 1},
@@ -2611,23 +2610,42 @@ INTERFACE_EXPORT = (() => {
 
     function _extractBillCalcRefs(currentBill) {
       const rst = [];
-      if (typeof currentBill.calcBase === 'string' && currentBill.calcBase.length > 37) {
+      function _extract(spliter, excluded = true, nextGap) {
         let currentBillCalcBase = currentBill.calcBase;
-        let currentIdx = currentBillCalcBase.indexOf('@');
+        let currentIdx = currentBillCalcBase.indexOf(spliter);
+        let exCnt = 0;
+        if (excluded) exCnt = spliter.length;
         while (currentIdx >= 0) {
-          let bId = currentBillCalcBase.substr(currentIdx + 1, 36);
+          let bId = currentBillCalcBase.substr(currentIdx + excluded, nextGap);
           if (!rst.includes(bId)) {
             rst.push(bId);
           }
-          currentBillCalcBase = currentBillCalcBase.substr(currentIdx + 37);
-          currentIdx = currentBillCalcBase.indexOf('@');
+          currentBillCalcBase = currentBillCalcBase.substr(currentIdx + excluded + nextGap);
+          currentIdx = currentBillCalcBase.indexOf(spliter);
         }
       }
+      if (typeof currentBill.calcBase === 'string') {
+        //1. 抽取@引用
+        _extract('@', true, 36);
+        //2. 抽取特殊引用
+        // 2.1 {各章清单合计}
+        _extract('{各章清单合计}', false, '{各章清单合计}'.length);
+        // 2.2 {100章以外清单合计}
+        _extract('{100章以外清单合计}', false, '{100章以外清单合计}'.length);
+      }
       return rst;
     }
 
     function _preCodeingForBills(tenderProject) {
       const cacheObj = {};
+      function _chkAdhocChapterBill(bill) {
+        let rst = false;
+        if (typeof bill.name === 'string' && bill.name.includes('00章') && bill.name.includes('清单')) {
+          rst = true;
+        }
+        return rst;
+      }
+
       function _setCache(bNode) {
         cacheObj['_' + bNode.data.ID] = bNode.data;
         if (bNode.children && bNode.children.length > 0) {
@@ -2642,6 +2660,36 @@ INTERFACE_EXPORT = (() => {
       }
 
       let cnt = 1;
+      let billsForAcc = [];
+      for (let bill of tenderProject.Bills.datas) {
+        //这一步设置特殊清单(各章清单合计, 100章~1200章)
+        cacheObj['_{100章以外清单合计}'] = {};
+        if (_billStrFilter(bill.name) == '第100章至700章清单' || sectionNameMap[_billStrFilter(bill.name)] || _chkAdhocChapterBill(bill)) {
+          if (cacheObj['_' + bill.ID]) {
+            if (!cacheObj['_' + bill.ID].hasOwnProperty('formulaCode')) {
+              cacheObj['_' + bill.ID].formulaCode = `F${cnt}`;
+              cnt++;
+            }
+          }
+          if (_billStrFilter(bill.name).includes('第100章至700章清单')) {
+            cacheObj['_{各章清单合计}'] = {};
+            cacheObj['_{各章清单合计}'].formulaCode = `{F${cnt - 1}}`;
+          } else {
+            billsForAcc.push(`F${cnt - 1}`);
+          }
+        }
+      }
+      let tmpStr = ''
+      for (let idx = 0; idx < billsForAcc.length; idx++) {
+        if (idx === 0) {
+          tmpStr = '( ' + `{${billsForAcc[idx]}}`;
+        } else {
+          tmpStr = tmpStr + ` + {${billsForAcc[idx]}}`;
+        }
+        if (idx === billsForAcc.length - 1) tmpStr = tmpStr + ' )';
+      }
+      cacheObj['_{100章以外清单合计}'].formulaCode = tmpStr;
+
       for (let bill of tenderProject.Bills.datas) {
         let billRefs = _extractBillCalcRefs(bill);
         for (let refBillId of billRefs) {
@@ -2658,7 +2706,8 @@ INTERFACE_EXPORT = (() => {
 
     function _getFormulaDispName(cacheForFormula, currentBill) {
       let rst = currentBill.calcBase;
-      if (typeof currentBill.calcBase === 'string' && currentBill.calcBase.length > 37) {
+      if (typeof currentBill.calcBase === 'string') {
+        //1. @引用
         let currentBillCalcBase = currentBill.calcBase;
         let currentIdx = currentBillCalcBase.indexOf('@');
         let bIdArr = [], replaceArr = [];
@@ -2681,6 +2730,17 @@ INTERFACE_EXPORT = (() => {
         for (let idx = 0; idx < bIdArr.length; idx++) {
           tempBillCalcBase = tempBillCalcBase.replace('@' + bIdArr[idx], replaceArr[idx]);
         }
+        //2. 特殊引用
+        //{各章清单合计} {100章以外清单合计}
+        if (tempBillCalcBase.includes('{各章清单合计}')) {
+          console.log(`特殊引用清单{各章清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
+          tempBillCalcBase = tempBillCalcBase.replace('{各章清单合计}', cacheForFormula['_{各章清单合计}'].formulaCode);
+        }
+        if (tempBillCalcBase.includes('{100章以外清单合计}')) {
+          console.log(`特殊引用清单{100章以外清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
+          tempBillCalcBase = tempBillCalcBase.replace('{100章以外清单合计}', cacheForFormula['_{100章以外清单合计}'].formulaCode);
+        }
+        // 
         rst = tempBillCalcBase;
       }
       return rst;