浏览代码

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

zhangweicheng 5 年之前
父节点
当前提交
b0f6e62719

+ 2 - 2
modules/pm/facade/pm_facade.js

@@ -1945,11 +1945,11 @@ async function importTenderDetail(tenderData) {
         task.push(billsModel.insertMany(tenderData.bills));
     }
     // 暂估价材料表
-    if (tenderData.evaluationList.length) {
+    if (tenderData.evaluationList && tenderData.evaluationList.length) {
         task.push(evaluateListModel.insertMany(tenderData.evaluationList));
     }
     // 评标材料表
-    if (tenderData.bidEvaluationList.length) {
+    if (tenderData.evaluationList && tenderData.bidEvaluationList.length) {
         task.push(bidListModel.insertMany(tenderData.bidEvaluationList));
     }
     if (task.length) {

+ 2 - 1
web/building_saas/standard_interface/export/anhui_chizhou.js

@@ -318,6 +318,7 @@ INTERFACE_EXPORT = (() => {
             }
 
             for (let i = 0; i < vJRG.children.length; i++) {
+                debugger;
                 vKind = vJRG.children[i];
                 let attrs = [
                     { name: '序号', value: vKind.row() },
@@ -328,7 +329,7 @@ INTERFACE_EXPORT = (() => {
                 vKindNode = new CreateNode('计日工信息标题', attrs);
                 jiRGXXB.children.push(vKindNode);
 
-                for (let j = 0; j < vKind.children.length; i++) {
+                for (let j = 0; j < vKind.children.length; j++) {
                     vChild = vKind.children[j];
 
                     let attrs = [

+ 17 - 0
web/building_saas/standard_interface/export/anhui_maanshan.js

@@ -101,6 +101,12 @@ INTERFACE_EXPORT = (() => {
           { name: 'ZbrDbSfzh', value: getValueByKey(information, 'tenderAuthorizerIDNo') }, // 招标人法定代表人或其授权人身份证号
           { name: 'ZxrDbSfzh', value: getValueByKey(information, 'consultantAuthorizerTaxpayerIdentificationNo') }, // 造价咨询人法定代表或其授权人纳税识别号
         ],
+        '亳州': [
+          { name: 'ZbrNssbh', value: getValueByKey(information, 'tendereeTaxpayerIdentificationNo') }, // 招标人纳税识别号
+          { name: 'ZxrNssbh', value: getValueByKey(information, 'costConsultantTaxpayerIdentificationNo') }, // 造价咨询人纳税识别号
+          { name: 'ZbrDbSfzh', value: getValueByKey(information, 'tenderAuthorizerIDNo') }, // 招标人法定代表人或其授权人身份证号
+          { name: 'ZxrDbSfzh', value: getValueByKey(information, 'consultantAuthorizerTaxpayerIdentificationNo') }, // 造价咨询人法定代表或其授权人纳税识别号
+        ],
       };
       if (extraMap[subArea]) {
         attrs.push(...extraMap[subArea]);
@@ -135,6 +141,12 @@ INTERFACE_EXPORT = (() => {
           { name: 'ZbrDbSfzh', value: getValueByKey(information, 'tenderAuthorizerIDNo') }, // 招标人法定代表人或其授权人身份证号
           { name: 'ZxrDbSfzh', value: getValueByKey(information, 'consultantAuthorizerTaxpayerIdentificationNo') }, // 造价咨询人法定代表或其授权人纳税识别号
         ],
+        '亳州': [
+          { name: 'ZbrNssbh', value: getValueByKey(information, 'tendereeTaxpayerIdentificationNo') }, // 招标人纳税识别号
+          { name: 'ZxrNssbh', value: getValueByKey(information, 'costConsultantTaxpayerIdentificationNo') }, // 造价咨询人纳税识别号
+          { name: 'ZbrDbSfzh', value: getValueByKey(information, 'tenderAuthorizerIDNo') }, // 招标人法定代表人或其授权人身份证号
+          { name: 'ZxrDbSfzh', value: getValueByKey(information, 'consultantAuthorizerTaxpayerIdentificationNo') }, // 造价咨询人法定代表或其授权人纳税识别号
+        ],
       };
       if (extraMap[subArea]) {
         attrs.push(...extraMap[subArea]);
@@ -164,6 +176,11 @@ INTERFACE_EXPORT = (() => {
           { name: 'TbrNssbh', value: getValueByKey(information, 'bidderTaxpayerIdentificationNo') }, // 投标人纳税识别号
           { name: 'TbrDbSfzh', value: getValueByKey(information, 'bidderAuthorizerTaxpayerIdentificationNo') }, // 投标人法定代表或其授权人身份证号
         ],
+        '亳州': [
+          { name: 'ZbrNssbh', value: getValueByKey(information, 'tendereeTaxpayerIdentificationNo') }, // 招标人纳税识别号
+          { name: 'TbrNssbh', value: getValueByKey(information, 'bidderTaxpayerIdentificationNo') }, // 投标人纳税识别号
+          { name: 'TbrDbSfzh', value: getValueByKey(information, 'bidderAuthorizerTaxpayerIdentificationNo') }, // 投标人法定代表或其授权人身份证号
+        ],
       };
       if (extraMap[subArea]) {
         attrs.push(...extraMap[subArea]);

+ 9 - 2
web/building_saas/standard_interface/export/base.js

@@ -103,7 +103,7 @@ const INTERFACE_EXPORT_BASE = (() => {
   function Element(name, attrs = []) {
     this.name = name;
     this.attrs = attrs;
-    check(this.attrs);
+    this.attrs = check(this.attrs);
     handleXMLEntity(this.attrs);
     this.children = [];
   }
@@ -154,15 +154,21 @@ const INTERFACE_EXPORT_BASE = (() => {
    * 检查
    * 创建节点时检查节点的数据(原本是用于自检,现在来处理默认值)
    * @param {Array}datas 需要检查的属性数据
-   * @return {void}
+   * @return {Array}
    * */
   function check(datas) {
+    const rst = [];
     for (const data of datas) {
       // 错误提示
       if (data.fail && data.fail.hint) {
         _cache.failList.push(data.fail);
       }
       const isHasValue = hasValue(data.value);
+      // 设置了mustHasValue,意味着必须要有值才输出该属性
+      if (data.mustHasValue && !isHasValue) {
+        continue;
+      }
+      rst.push(data);
       // 值统一转换成String,并且处理各类型属性空值时的默认取值
       data.value = !isHasValue ?
         DEFAULT_VALUE[data.type] ?
@@ -199,6 +205,7 @@ const INTERFACE_EXPORT_BASE = (() => {
         data.value = DEFAULT_VALUE[TYPE.BOOL];
       }
     }
+    return rst;
   }
   // 等待一段时间
   function setTimeoutSync(handle, time) {

+ 142 - 0
web/building_saas/standard_interface/import/anhui_chizhou.js

@@ -0,0 +1,142 @@
+/*
+ * @Descripttion: 安徽池州导入接口
+ * @Author: vian
+ * @Date: 2020-09-21 17:40:45
+ */
+
+// INTERFACE_EXPORT =,必须这么写,这样才能在导入时动态加载脚本后,覆盖前端代码
+INTERFACE_IMPORT = (() => {
+  'use strict';
+  /**
+   * 
+   * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
+   * @param {Object} xmlObj - xml经过x2js转换后的xml对象
+   * @return {Object} - 返回的格式需要统一,具体参考函数内返回的内容。返回的内容会经过一系列的统一处理形成可入库的数据。
+   */
+  async function entry(areaKey, xmlObj) {
+    const {
+      UTIL: {
+        getValue,
+        arrayValue,
+        extractItemsRecur,
+      }
+    } = INTERFACE_EXPORT_BASE;
+
+    const subArea = areaKey.split('@')[1];
+
+    // 提取基本信息,xml中提取出来的基本信息,最终会与模板基本信息进行合并处理。(接口内不需要处理合并)
+    function setupInformation(projectSrc) {
+      const gcxx = getValue(projectSrc, ['工程信息']);
+      const zbxx = getValue(projectSrc, ['招投标信息', '招标信息']);
+      // key:基本信息模板中的key,作为合并时的匹配字段
+      const info = [
+        { key: 'projNum', value: getValue(gcxx, ['_项目编号']) },
+        { key: 'constructingUnits', value: getValue(gcxx, ['_建设单位']) },
+        { key: 'startChainages', value: getValue(gcxx, ['_起始桩号']) },
+        { key: 'endChainages', value: getValue(gcxx, ['_终点桩号']) },
+        { key: 'constructionAddress', value: getValue(gcxx, ['_建设地址']) },
+        { key: 'projOverview', value: getValue(gcxx, ['_项目概况']) },
+        { key: 'natureConstruction', value: getValue(gcxx, ['_建设性质']) },
+        { key: 'roadGrade', value: getValue(gcxx, ['_专业划分']) },
+        { key: 'roadDistance', value: getValue(gcxx, ['_道路里程']) },
+        { key: 'designUnit', value: getValue(gcxx, ['_设计单位']) },
+        { key: 'taxMode', value: getValue(gcxx, ['_计税方式']) },
+        { key: 'projType', value: getValue(gcxx, ['_文件类型']) },
+        { key: 'tendereeName', value: getValue(zbxx, ['_招标人']) },
+        { key: 'tendereeTaxpayerIdentificationNo', value: getValue(zbxx, ['_招标人纳税识别号']) },
+        { key: 'tenderAuthorizer', value: getValue(zbxx, ['_招标法定代表人或其授权人']) },
+        { key: 'tenderAuthorizerIDNo', value: getValue(zbxx, ['_招标法人或其授权人身份证号']) },
+        { key: 'costConsultant', value: getValue(zbxx, ['_造价咨询人']) },
+        { key: 'costConsultantTaxpayerIdentificationNo', value: getValue(zbxx, ['_造价咨询人纳税识别号']) },
+        { key: 'consultantAuthorizer', value: getValue(zbxx, ['_造价咨询人法定代表人或其授权人']) },
+        { key: 'consultantAuthorizerTaxpayerIdentificationNo', value: getValue(zbxx, ['_造价咨询法人或其授权人身份证号']) },
+        { key: 'compileApprover', value: getValue(zbxx, ['_编制人']) },
+        { key: 'compileCertNo', value: getValue(zbxx, ['_编制人资格证号']) },
+        { key: 'compileDate', value: getValue(zbxx, ['_编制日期']) },
+        { key: 'reviewApprover', value: getValue(zbxx, ['_复核人']) },
+        { key: 'reviewCertNo', value: getValue(zbxx, ['_复核人资格证号']) },
+        { key: 'reviewDate', value: getValue(zbxx, ['_复核日期']) },
+      ];
+      return info;
+    }
+
+    // 提取清单数据
+    function setupBills(rootSrc, oneSevenSrc, dayWorkSrc) {
+      // 章次为空的造价汇总表数据,为大项费用数据
+      const roots = arrayValue(rootSrc, ['造价汇总明细'])
+        .filter(item => !getValue(item, ['_章次']))
+        .map(item => ({
+          name: getValue(item, ['_名称']),
+          remark: getValue(item, ['_备注'])
+        }));
+      let oneSevenBills;
+      let dayWorkBills;
+      roots.forEach(item => {
+        const simpleName = item.name ? item.name.replace(/\s/g, '') : '';
+        if (/100章至第700章|100章至700章/.test(simpleName)) {
+          oneSevenBills = item;
+        } else if (/计日工合计/.test(simpleName)) {
+          dayWorkBills = item;
+        }
+      });
+      // 第100-700章的数据
+      if (oneSevenBills) {
+        oneSevenBills.children = extractItemsRecur(oneSevenSrc, [['工程量清单明细']], (src) => ({
+          code: getValue(src, ['_子目号']),
+          name: getValue(src, ['_子目名称']),
+          unit: getValue(src, ['_单位']),
+          quantity: getValue(src, ['_数量']),
+          remark: getValue(src, ['_备注']),
+        }));
+      }
+      // 计日工数据
+      if (dayWorkBills) {
+        const title = '计日工信息标题';
+        const detail = '计日工信息明细';
+        dayWorkBills.children = extractItemsRecur(dayWorkSrc, [[title], [detail]], (src, curField) => {
+          const name = getValue(src, ['_名称']);
+          const simpleName = name ? name.replace(/\s/g, '') : ''
+          if (curField === title && /计日工合计/.test(simpleName)) { // 计日工标题在根节点中已经提取了,不重复提取
+            return null;
+          }
+          const item = { name };
+          if (curField === detail) {
+            item.code = getValue(src, ['_编号']);
+            item.unit = getValue(src, ['_单位']);
+            item.quantity = getValue(src, ['_暂定数量']);
+          }
+          return item;
+        });
+      }
+      return roots;
+    }
+
+    // 提取单位工程数据
+    function setupTender(tenderSrc) {
+      const oneSevenSrc = getValue(tenderSrc, ['工程量清单表']);
+      const dayWorkSrc = getValue(tenderSrc, ['计日工信息表']);
+      const rootSrc = getValue(tenderSrc, ['造价汇总表']);
+      return {
+        name: getValue(tenderSrc, ['_标段名称']),
+        bills: setupBills(rootSrc, oneSevenSrc, dayWorkSrc)
+      };
+    }
+
+    // 从xml对象提取需要的数据
+    function setupProject(projectSrc) {
+      const tenders = arrayValue(projectSrc, ['公路工程数据', '公路标段工程'])
+        .map(tenderSrc => setupTender(tenderSrc));
+      return {
+        name: getValue(projectSrc, ['工程信息', '_项目名称']),
+        info: setupInformation(projectSrc),
+        tenders,
+      };
+    }
+    return setupProject(getValue(xmlObj, ['池州公路工程']));
+  }
+
+  return {
+    entry
+  };
+
+})();

+ 17 - 5
web/building_saas/standard_interface/import/base.js

@@ -165,11 +165,19 @@ const INTERFACE_EXPORT_BASE = (() => {
     for (const field of fields) {
       const itemsSrc = arrayValue(src, field);
       if (itemsSrc.length) {
-        const items = itemsSrc.map(itemSrc => {
+        /* const items = itemsSrc.map(itemSrc => {
           const obj = extractFuc(itemSrc, field[0]);
           obj.children = extractItemsRecur(itemSrc, fields, extractFuc);
           return obj;
-        });
+        }); */
+        const items = [];
+        itemsSrc.forEach(itemSrc => {
+          const obj = extractFuc(itemSrc, field[0]);
+          if (obj) {
+            obj.children = extractItemsRecur(itemSrc, fields, extractFuc);
+            items.push(obj);
+          }
+        })
         rst.push(...items);
       }
     }
@@ -338,7 +346,7 @@ const INTERFACE_EXPORT_BASE = (() => {
       }
       const taxData = engineeringLib.lib.tax_group[0];
       const featureSource = [
-        ...tender.feature,
+        ...(tender.feature || []),
         { key: 'valuationType', value: '工程量清单' }, // 导入的时候以下项不一定有数据,但是需要自动生成
         { key: 'feeStandard', value: engineeringLib.lib.feeName },
       ];
@@ -371,8 +379,12 @@ const INTERFACE_EXPORT_BASE = (() => {
         glj.ID = uuid.v1();
         glj.projectID = tender.ID;
       }
-      tender.evaluationList.forEach(setGLJRefFunc);
-      tender.bidEvaluationList.forEach(setGLJRefFunc);
+      if (tender.evaluationList && tender.evaluationList.length) {
+        tender.evaluationList.forEach(setGLJRefFunc);
+      }
+      if (tender.bidEvaluationList && tender.bidEvaluationList.length) {
+        tender.bidEvaluationList.forEach(setGLJRefFunc);
+      }
     });
   }