Browse Source

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuCost

TonyKang 4 years ago
parent
commit
e885111a62

+ 13 - 3
modules/main/facade/project_facade.js

@@ -420,15 +420,22 @@ function getReportData(nameList, items, prjTypeNames, compilationScopes, decimal
         tem.billsAmounts.push(0);
         tem.billsAmounts.push(0);
         tem['技术经济指标'].push(scMathUtil.roundForObj(p, 2));
         tem['技术经济指标'].push(scMathUtil.roundForObj(p, 2));
       }
       }
-      if (rootFlag == fixedFlag.MAINTENANCE_EXPENSES) { //如果是第三部分下的子清单,才要计算累计的相关信息
+      //如果是第三部分下的子清单,才要计算累计的相关信息
+      // 10-26 需求变更,所有清单都算累计
+      /* if (rootFlag == fixedFlag.MAINTENANCE_EXPENSES) { 
         if (bills.baseProgressiveFees[n]) {
         if (bills.baseProgressiveFees[n]) {
           bt = scMathUtil.roundForObj(bills.baseProgressiveFees[n], decimal.bills.totalPrice);
           bt = scMathUtil.roundForObj(bills.baseProgressiveFees[n], decimal.bills.totalPrice);
           baseTotal = scMathUtil.roundForObj(bt + baseTotal, decimal.process);
           baseTotal = scMathUtil.roundForObj(bt + baseTotal, decimal.process);
         }
         }
+      } */
+      if (bills.baseProgressiveFees[n]) {
+        bt = scMathUtil.roundForObj(bills.baseProgressiveFees[n], decimal.bills.totalPrice);
+        baseTotal = scMathUtil.roundForObj(bt + baseTotal, decimal.process);
       }
       }
     }
     }
     tem.billsTtlPrice = scMathUtil.roundForObj(total, decimal.bills.totalPrice);
     tem.billsTtlPrice = scMathUtil.roundForObj(total, decimal.bills.totalPrice);
-    if (progressiveInterval && isProgressiveType && rootFlag == fixedFlag.MAINTENANCE_EXPENSES) {
+    // 10-26 需求变更,所有清单都算累计   && rootFlag == fixedFlag.MAINTENANCE_EXPENSES
+    if (progressiveInterval && isProgressiveType) {
       let baseArr = calcUtil.getProgressive(bills.calcBase, overWrite ? overWrite.progression : undefined);
       let baseArr = calcUtil.getProgressive(bills.calcBase, overWrite ? overWrite.progression : undefined);
       if (baseArr.length > 0) {
       if (baseArr.length > 0) {
         let deficiency = overWrite && overWrite.deficiency || null;
         let deficiency = overWrite && overWrite.deficiency || null;
@@ -881,5 +888,8 @@ async function calcProjectGLJQuantity(projectID, projectGLJDatas, property) {
   let rationDatas = await ration_model.model.find({
   let rationDatas = await ration_model.model.find({
     'projectID': projectID
     'projectID': projectID
   });
   });
-  gljUtil.calcProjectGLJQuantity(projectGLJDatas, rationGLJDatas, rationDatas, [], q_decimal)
+  let billDatas = await bill_model.model.find({
+    'projectID': projectID
+  });
+  gljUtil.calcProjectGLJQuantity(projectGLJDatas, rationGLJDatas, rationDatas, billDatas, q_decimal)
 }
 }

+ 5 - 0
modules/pm/facade/pm_facade.js

@@ -2006,6 +2006,11 @@ async function importInterfaceProject(importObj, userID, compilation, overWriteU
         if (!data.property.decimal) {
         if (!data.property.decimal) {
             //小数位数 需要修改,所以深拷贝
             //小数位数 需要修改,所以深拷贝
             data.property.decimal = JSON.parse(JSON.stringify(defaultDecimal));
             data.property.decimal = JSON.parse(JSON.stringify(defaultDecimal));
+            if (data.property.areaKey === '广东@中山') {
+                data.property.decimal.bills.totalPrice = 2;
+                data.property.decimal.ration.totalPrice = 2;
+                delete data.property.areaKey;
+            }
         }
         }
         //清单工程量精度 需要修改,所以深拷贝
         //清单工程量精度 需要修改,所以深拷贝
         data.property.billsQuantityDecimal = JSON.parse(JSON.stringify(billsQuantityDecimal));
         data.property.billsQuantityDecimal = JSON.parse(JSON.stringify(billsQuantityDecimal));

+ 16 - 3
web/building_saas/standard_interface/export/guangdong_zhongshan.js

@@ -903,7 +903,7 @@ INTERFACE_EXPORT = (() => {
       function BidEvaluationMainMaterial(b, index) {
       function BidEvaluationMainMaterial(b, index) {
         const attrs = [{
         const attrs = [{
             name: "Code",
             name: "Code",
-            value: index,
+            value: b.seq,
           },
           },
           {
           {
             name: "Number",
             name: "Number",
@@ -1099,7 +1099,9 @@ INTERFACE_EXPORT = (() => {
             },
             },
             {
             {
               name: "QtyFormula",
               name: "QtyFormula",
-              value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : ""//data.calcBase //data.calcBase ? cbParser.toFExpr(data.calcBase, tenderProject.mainTree.items) : "",
+              value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",//data.calcBase //data.calcBase ? cbParser.toFExpr(data.calcBase, tenderProject.mainTree.items) : "",
+              type: TYPE.DECIMAL,
+              toFix:2
             },
             },
             {
             {
               name: "Price",
               name: "Price",
@@ -1528,27 +1530,38 @@ INTERFACE_EXPORT = (() => {
       let attrs = [{
       let attrs = [{
           name: "TenderSumLimit",
           name: "TenderSumLimit",
           value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
           value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
-          type: TYPE.DECIMAL
+          type: TYPE.DECIMAL,
+          toFix:2,
         },
         },
         {
         {
           name: "BidTotal",
           name: "BidTotal",
           value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
           value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
+          type: TYPE.DECIMAL,
+          toFix:2,
         },
         },
         {
         {
           name: "BillTotal",
           name: "BillTotal",
           value: oneToSevenItem.feesIndex && oneToSevenItem.feesIndex.common && oneToSevenItem.feesIndex.common.tenderTotalFee ? oneToSevenItem.feesIndex.common.tenderTotalFee : 0,
           value: oneToSevenItem.feesIndex && oneToSevenItem.feesIndex.common && oneToSevenItem.feesIndex.common.tenderTotalFee ? oneToSevenItem.feesIndex.common.tenderTotalFee : 0,
+          type: TYPE.DECIMAL,
+          toFix:2,
         },
         },
         {
         {
           name: "CostForHSE",
           name: "CostForHSE",
           value: safeItem && safeItem.feesIndex && safeItem.feesIndex.common && safeItem.feesIndex.common.tenderTotalFee ? safeItem.feesIndex.common.tenderTotalFee : 0,
           value: safeItem && safeItem.feesIndex && safeItem.feesIndex.common && safeItem.feesIndex.common.tenderTotalFee ? safeItem.feesIndex.common.tenderTotalFee : 0,
+          type: TYPE.DECIMAL,
+          toFix:2,
         },
         },
         {
         {
           name: "ProvisionalSums",
           name: "ProvisionalSums",
           value: proItem.feesIndex && proItem.feesIndex.common && proItem.feesIndex.common.tenderTotalFee ? proItem.feesIndex.common.tenderTotalFee : 0,
           value: proItem.feesIndex && proItem.feesIndex.common && proItem.feesIndex.common.tenderTotalFee ? proItem.feesIndex.common.tenderTotalFee : 0,
+          type: TYPE.DECIMAL,
+          toFix:2,
         },
         },
         {
         {
           name: "Appraisal",
           name: "Appraisal",
           value: totalItem.feesIndex && totalItem.feesIndex.estimate && totalItem.feesIndex.estimate.tenderTotalFee ? totalItem.feesIndex.estimate.tenderTotalFee : 0,
           value: totalItem.feesIndex && totalItem.feesIndex.estimate && totalItem.feesIndex.estimate.tenderTotalFee ? totalItem.feesIndex.estimate.tenderTotalFee : 0,
+          type: TYPE.DECIMAL,
+          toFix:2,
         },
         },
       ];
       ];
       if (isBidInvitation) { 
       if (isBidInvitation) { 

+ 38 - 11
web/building_saas/standard_interface/import/base.js

@@ -243,9 +243,10 @@ const INTERFACE_EXPORT_BASE = (() => {
    * @param {Array} source - 从xml提取出来的清单
    * @param {Array} source - 从xml提取出来的清单
    * @param {Array} target - 清单模板数据
    * @param {Array} target - 清单模板数据
    * @param {Object} parent - 匹配到模板清单的父清单
    * @param {Object} parent - 匹配到模板清单的父清单
+   * @param {Boolean} onlyImportMatchBills - 是否只导入文件中的清单,未匹配的模板清单不生成
    * @return {void}
    * @return {void}
    */
    */
-  function mergeBills(source, target, parent) {
+  function mergeBills(source, target, parent, matchedFlags) {
     source.forEach((bills, index) => {
     source.forEach((bills, index) => {
       // 为了大项费用排序
       // 为了大项费用排序
       if (!parent) {
       if (!parent) {
@@ -281,15 +282,15 @@ const INTERFACE_EXPORT_BASE = (() => {
         }
         }
       }
       }
       if (matched) {
       if (matched) {
+        matchedFlags.push(getFlag(matched));
         assignAttr(matched, bills);
         assignAttr(matched, bills);
         if (bills.children && bills.children.length) {
         if (bills.children && bills.children.length) {
-          mergeBills(bills.children, matched.children, matched);
+          mergeBills(bills.children, matched.children, matched, matchedFlags);
         }
         }
       } else {
       } else {
         target.push(bills);
         target.push(bills);
       }
       }
     });
     });
-
   }
   }
 
 
   /**
   /**
@@ -297,12 +298,33 @@ const INTERFACE_EXPORT_BASE = (() => {
    * @param {Array} tenderBills - 从xml提取出来的清单
    * @param {Array} tenderBills - 从xml提取出来的清单
    * @param {Array} billsTarget - 拷贝一份的模板清单,用于合并提取清单
    * @param {Array} billsTarget - 拷贝一份的模板清单,用于合并提取清单
    * @param {Number} tenderID - 单位工程ID
    * @param {Number} tenderID - 单位工程ID
+   * @param {Boolean} onlyImportMatchBills - 是否只导入文件中的清单,未匹配的模板清单不生成
    * @return {Array}
    * @return {Array}
    */
    */
-  function handleBills(tenderBills, billsTarget, tenderID) {
+  function handleBills(tenderBills, billsTarget, tenderID, onlyImportMatchBills) {
     const rst = [];
     const rst = [];
     // 将提取的清单数据合并进清单模板数据
     // 将提取的清单数据合并进清单模板数据
-    mergeBills(tenderBills, billsTarget, null);
+    const matchedFlags = [];
+    mergeBills(tenderBills, billsTarget, null, matchedFlags);
+
+    // 如果只导入文件中有的清单,除100-700/900章清单、报价清单外,其他未匹配到的固定清单模板,均不导入
+    function removeNotMatchFlagBills(bills) {
+      const rst = [];
+      bills.forEach(item => {
+        const flag = getFlag(item);
+        if (!flag || [fixedFlag.ONE_SEVEN_BILLS, fixedFlag.TOTAL_COST].includes(flag) || matchedFlags.includes(flag)) {
+          rst.push(item);
+        }
+        if (flag && ![fixedFlag.ONE_SEVEN_BILLS, fixedFlag.TOTAL_COST].includes(flag) && item.children && item.children.length) {
+          item.children = removeNotMatchFlagBills(item.children);
+        }
+      });
+      return rst;
+    }
+    if (onlyImportMatchBills) {
+      billsTarget = removeNotMatchFlagBills(billsTarget)
+    }
+
     // 大项费用按照清单标题排序
     // 大项费用按照清单标题排序
     billsTarget.sort((a, b) => a.seq - b.seq);
     billsTarget.sort((a, b) => a.seq - b.seq);
     // 给清单设置数据
     // 给清单设置数据
@@ -399,7 +421,7 @@ const INTERFACE_EXPORT_BASE = (() => {
   }
   }
 
 
   // 处理单位工程数据
   // 处理单位工程数据
-  function handleTenderData(tenders, templateData, rationValuationData, engineeringLib) {
+  function handleTenderData(tenders, templateData, rationValuationData, engineeringLib, areaKey, onlyImportMatchBills) {
     tenders.forEach((tender, index) => {
     tenders.forEach((tender, index) => {
       tender.compilation = compilationData._id;
       tender.compilation = compilationData._id;
       tender.userID = userID;
       tender.userID = userID;
@@ -422,6 +444,7 @@ const INTERFACE_EXPORT_BASE = (() => {
         featureSource.push({ key: 'engineering', value: engineeringLib.lib.name });
         featureSource.push({ key: 'engineering', value: engineeringLib.lib.name });
       }
       }
       tender.property = {
       tender.property = {
+        areaKey,
         rootProjectID: tender.ParentID,
         rootProjectID: tender.ParentID,
         region: '全省',
         region: '全省',
         engineering_id: engineeringLib.engineering_id,
         engineering_id: engineeringLib.engineering_id,
@@ -445,7 +468,7 @@ const INTERFACE_EXPORT_BASE = (() => {
       };
       };
       delete tender.feature;
       delete tender.feature;
       const tenderDataBills = getTemplateBillsTarget(templateData.bills);
       const tenderDataBills = getTemplateBillsTarget(templateData.bills);
-      tender.bills = handleBills(tender.bills, tenderDataBills, tender.ID,); // 必须要拷贝一份,否则多单位工程情况下,前单位工程的清单数据会被后单位工程的覆盖
+      tender.bills = handleBills(tender.bills, tenderDataBills, tender.ID, onlyImportMatchBills); // 必须要拷贝一份,否则多单位工程情况下,前单位工程的清单数据会被后单位工程的覆盖
       // 给暂估材料和评标材料设置项目数据
       // 给暂估材料和评标材料设置项目数据
       const setGLJRefFunc = glj => {
       const setGLJRefFunc = glj => {
         glj.ID = uuid.v1();
         glj.ID = uuid.v1();
@@ -465,9 +488,11 @@ const INTERFACE_EXPORT_BASE = (() => {
    * 因为无法保证这一套逻辑能不能兼容以后的所有接口,因此提取数据与标准数据模板的合并放在前端进行。
    * 因为无法保证这一套逻辑能不能兼容以后的所有接口,因此提取数据与标准数据模板的合并放在前端进行。
    * 当统一逻辑无法满足某一接口时,接口可以根据标准模板数据自行进行相关处理。
    * 当统一逻辑无法满足某一接口时,接口可以根据标准模板数据自行进行相关处理。
    * @param {Object} importData - 各接口从xml提取出来的数据
    * @param {Object} importData - 各接口从xml提取出来的数据
+   * @param {String} areaKey - 接口地区
+   * @param {Boolean} onlyImportMatchBills - 是否只导入文件中的清单,未匹配的模板清单不生成
    * @return {Promise<Object>}
    * @return {Promise<Object>}
    */
    */
-  async function handleImportData(importData) {
+  async function handleImportData(importData, areaKey, onlyImportMatchBills) {
     const valuationID = compilationData.ration_valuation[0].id;
     const valuationID = compilationData.ration_valuation[0].id;
     if (!Array.isArray(importData.tenders) && !importData.tenders.length) {
     if (!Array.isArray(importData.tenders) && !importData.tenders.length) {
       throw '导入的文件中不存在有效的标段数据。';
       throw '导入的文件中不存在有效的标段数据。';
@@ -514,7 +539,7 @@ const INTERFACE_EXPORT_BASE = (() => {
     };
     };
     delete importData.info;
     delete importData.info;
     // 处理单位工程数据
     // 处理单位工程数据
-    handleTenderData(importData.tenders, templateData, rationValuationData, engineeringLib);
+    handleTenderData(importData.tenders, templateData, rationValuationData, engineeringLib, areaKey, onlyImportMatchBills);
     console.log(importData);
     console.log(importData);
   }
   }
 
 
@@ -542,9 +567,10 @@ const INTERFACE_EXPORT_BASE = (() => {
    * @param {File} file - 导入的文件
    * @param {File} file - 导入的文件
    * @param {String} areaKey - 地区标识,如:'安徽@马鞍山'
    * @param {String} areaKey - 地区标识,如:'安徽@马鞍山'
    * @param {Boolean} escape - 是否需要避免xml中的实体字符转换
    * @param {Boolean} escape - 是否需要避免xml中的实体字符转换
+   * @param {Boolean} onlyImportMatchBills - 是否只导入文件中的清单,未匹配的模板清单不生成
    * @return {Promise<Object>}
    * @return {Promise<Object>}
    */
    */
-  async function extractImportData(entryFunc, file, areaKey, escape = false) {
+  async function extractImportData(entryFunc, file, areaKey, escape = false, onlyImportMatchBills = false) {
     // 将二进制文件转换成字符串
     // 将二进制文件转换成字符串
     let xmlStr = await readAsTextSync(file);
     let xmlStr = await readAsTextSync(file);
     if (escape) {
     if (escape) {
@@ -560,7 +586,8 @@ const INTERFACE_EXPORT_BASE = (() => {
       throw '无有效数据。';
       throw '无有效数据。';
     }
     }
     const importData = await entryFunc(areaKey, xmlObj);
     const importData = await entryFunc(areaKey, xmlObj);
-    await handleImportData(importData);
+    console.log(areaKey);
+    await handleImportData(importData, areaKey, onlyImportMatchBills);
     return importData;
     return importData;
   }
   }
 
 

+ 2 - 1
web/building_saas/standard_interface/import/view.js

@@ -57,7 +57,8 @@ const IMPORT_VIEW = (() => {
         }
         }
         const areaKey = `${parentArea}@${subArea}`;
         const areaKey = `${parentArea}@${subArea}`;
         await STD_INTERFACE.loadScriptByArea(areaKey, STD_INTERFACE.ScriptType.IMPORT);
         await STD_INTERFACE.loadScriptByArea(areaKey, STD_INTERFACE.ScriptType.IMPORT);
-        const importData = await INTERFACE_EXPORT_BASE.extractImportData(INTERFACE_IMPORT.entry, file, areaKey);
+        const onlyImportMatchBills = areaKey === '广东@中山';
+        const importData = await INTERFACE_EXPORT_BASE.extractImportData(INTERFACE_IMPORT.entry, file, areaKey, false, onlyImportMatchBills);
         $('#interface-import-modal').modal('hide');
         $('#interface-import-modal').modal('hide');
         $.bootstrapLoading.progressStart('导入文件', true);
         $.bootstrapLoading.progressStart('导入文件', true);
         $("#progress_modal_body").text('正在导入接口文件,请稍候……');
         $("#progress_modal_body").text('正在导入接口文件,请稍候……');