vian 2 лет назад
Родитель
Сommit
7d7b0add20

+ 3 - 0
modules/all_models/bills.js

@@ -113,6 +113,9 @@ let billsSchema = new Schema({
   }, // 叶子清单的计算类型。末定义:按定额计算。1:用户输入金额。2:用户输入单价。3:用户输入设计单价。
   bookmarkBackground: String, //书签背景色
   bookmarkAnnotation: String, //批注
+  keyIDData: { // 广西接口需要
+    type: Schema.Types.Mixed
+  }
 });
 
 mongoose.model("bills", billsSchema);

+ 13 - 10
modules/all_models/projects.js

@@ -10,17 +10,17 @@ const deleteSchema = require('../all_schemas/delete_schema');
 const collectionName = 'projects';
 const shareSchema = new Schema({
     userID: String, //userID
-    allowCopy: {type: Boolean, default: false},
-    allowCooperate: {type: Boolean, default: false},
+    allowCopy: { type: Boolean, default: false },
+    allowCooperate: { type: Boolean, default: false },
     shareDate: String,
-}, {versionKey: false, _id: false});
+}, { versionKey: false, _id: false });
 const ProjectSchema = new Schema({
-    "ID":{type: Number, index: true},
+    "ID": { type: Number, index: true },
     "GUID": String, // 接口需要
     "ParentID": Number,
     "NextSiblingID": Number,
     "userID": String,
-    "importedByInterface": {type: Boolean, default: false},
+    "importedByInterface": { type: Boolean, default: false },
     "name": String,
     "projType": String,
     "recentDateTime": Date,
@@ -33,17 +33,20 @@ const ProjectSchema = new Schema({
         type: Schema.Types.Mixed,
         default: {}
     },
-    "location":String,//工程所在地
-    "summaryFees":{
+    "location": String,//工程所在地
+    "summaryFees": {
         totalFee: String,
         estimateFee: String,
         safetyFee: String,
         chargeFee: String
     },
-    "changeMark":String,//更新标记  feeRate:费率文件发生了改变,unitFile 单件文件发生了改变
-    "remark":String, //备注
+    "changeMark": String,//更新标记  feeRate:费率文件发生了改变,unitFile 单件文件发生了改变
+    "remark": String, //备注
     "fileVer": String,  // 创建时程序版本号
-    "lastFileVer": String  // 最新打开并计算时的程序版本号
+    "lastFileVer": String,  // 最新打开并计算时的程序版本号
+    "keyIDData": { // 广西接口需要
+        type: Schema.Types.Mixed,
+    },
 });
 
 mongoose.model(collectionName, ProjectSchema, collectionName);

Разница между файлами не показана из-за своего большого размера
+ 1896 - 1893
web/building_saas/standard_interface/export/guangxi_common.js


+ 1 - 0
web/building_saas/standard_interface/import/base.js

@@ -500,6 +500,7 @@ const INTERFACE_EXPORT_BASE = (() => {
    * @return {Promise<Object>}
    */
   async function handleImportData(importData, areaKey, onlyImportMatchBills) {
+    debugger;
     const valuationID = compilationData.ration_valuation[0].id;
     if (!Array.isArray(importData.tenders) && !importData.tenders.length) {
       throw "导入的文件中不存在有效的标段数据。";

+ 220 - 171
web/building_saas/standard_interface/import/guangxi_common.js

@@ -6,185 +6,234 @@
 
 // INTERFACE_EXPORT =,必须这么写,这样才能在导入时动态加载脚本后,覆盖前端代码
 INTERFACE_IMPORT = (() => {
-    'use strict';
-    /**
-     * 
-     * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
-     * @param {Object} xmlObj - xml经过x2js转换后的xml对象
-     * @return {Object} - 返回的格式需要统一,具体参考函数内返回的内容。返回的内容会经过一系列的统一处理形成可入库的数据。
-     */
-    const RoadGradeMap = {
-      "0": "高速公路",
-      "1": "一级公路",
-      "2": "二级公路",
-      "3": "三级公路",
-      "4": "四级公路",
-      "5": "等外公路",
-      "6": "独立桥梁",
-      "7":"独立隧道"
+  'use strict';
+  /**
+   * 
+   * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
+   * @param {Object} xmlObj - xml经过x2js转换后的xml对象
+   * @return {Object} - 返回的格式需要统一,具体参考函数内返回的内容。返回的内容会经过一系列的统一处理形成可入库的数据。
+   */
+  const RoadGradeMap = {
+    "0": "高速公路",
+    "1": "一级公路",
+    "2": "二级公路",
+    "3": "三级公路",
+    "4": "四级公路",
+    "5": "等外公路",
+    "6": "独立桥梁",
+    "7": "独立隧道"
+  }
+
+  function formateDataString(dstring) {
+    if (!dstring || dstring == "") return "";
+    const strArr = dstring.split("T");
+    return strArr[0]
+  }
+
+  async function entry(areaKey, xmlObj) {
+    const {
+      UTIL: {
+        getValue,
+        arrayValue,
+        getBool,
+        extractItemsRecur,
+      }
+    } = INTERFACE_EXPORT_BASE;
+    let info = [];
+    let tenders = [];
+    let CprjInfo = getValue(xmlObj, ['CprjInfo']);
+    let EprjInfos = arrayValue(CprjInfo, ["EprjInfo"]);
+    if (EprjInfos.length > 0) {
+      let MakeInfo = EprjInfos[0].MakeInfo;
+      let Params = EprjInfos[0].Params;
+      let BuildType = getValue(Params, ['_BuildType']);
+      let natureConstruction = "";
+      if (BuildType == "0") natureConstruction = "新建";
+      if (BuildType == "1") natureConstruction = "改扩建";
+
+      let terrainCategory = "";
+      let Terrain = getValue(Params, ['_Terrain']);
+      if (Terrain == "0") terrainCategory = "平原微丘";
+      if (Terrain == "1") terrainCategory = "山岭重丘";
+      let RoadGrade = getValue(Params, ['_RoadGrade']);
+      let roadGrade = "";
+      if (RoadGradeMap[RoadGrade]) roadGrade = RoadGradeMap[RoadGrade];
+
+
+
+      info = [
+        { key: 'constructingUnit', value: getValue(MakeInfo, ['_Manage']) },
+        { key: 'designUnit', value: getValue(MakeInfo, ['_Designer']) },
+        { key: 'compileUnit', value: getValue(MakeInfo, ['_Compile']) },
+        { key: 'compileApprover', value: getValue(MakeInfo, ['_CompileApprover']) },
+        { key: 'compileCertNo', value: getValue(MakeInfo, ['_CompileCertNo']) },
+        { key: 'compileDate', value: formateDataString(getValue(MakeInfo, ['_CompileDate'])) },
+        { key: 'reviewUnit', value: getValue(MakeInfo, ['_Review']) },
+        { key: 'reviewApprover', value: getValue(MakeInfo, ['_ReviewApprover']) },
+        { key: 'reviewCertNo', value: getValue(MakeInfo, ['_ReviewCertNo']) },
+        { key: 'reviewDate', value: formateDataString(getValue(MakeInfo, ['_ReviewDate'])) },
+        { key: 'startChainages', value: getValue(Params, ['_StartPileNo']) },
+        { key: 'endChainages', value: getValue(Params, ['_EndPileNo']) },
+        { key: 'location', value: getValue(Params, ['_PrjArea']) },
+        { key: 'natureConstruction', value: natureConstruction },
+        { key: 'terrainCategory', value: terrainCategory },
+        { key: 'roadGrade', value: roadGrade },
+        { key: 'makeDate', value: getValue(CprjInfo, ['SystemInfo', '_MakeDate']) },
+        // { key: 'keyId', value: getValue(CprjInfo, ['SystemInfo','KeyId']) },
+
+      ]
+      for (let t of EprjInfos) {
+        tenders.push(setupTender(t))
+      }
+
+
     }
-    
-    function formateDataString(dstring) { 
-      if (!dstring || dstring == "") return "";
-      const strArr = dstring.split("T");
-      return strArr[0]
+
+    // 获取需要存的KeyId(建设项目内只有一个的,可以存到一个字段。清单的无法这么处理,清单的keyId数据要存到清单本身)
+    function getConstructionKeyIDData() {
+      const cprjInfo = getValue(xmlObj, ['CprjInfo', '_KeyId']);
+      const systemInfo = getValue(xmlObj, ['CprjInfo', 'SystemInfo', '_KeyId']);
+      const costBasis = getValue(xmlObj, ['CprjInfo', 'CostBasis', '_KeyId']);
+      const rate = getValue(xmlObj, ['CprjInfo', 'Rate', '_KeyId']);
+      const pract = getValue(xmlObj, ['CprjInfo', 'Pract', '_KeyId']);
+      const eprjInfo = getValue(xmlObj, ['CprjInfo', 'EprjInfo', '_KeyId']);
+      const indexs = getValue(xmlObj, ['CprjInfo', 'Indexs', '_KeyId']);
+      const rateParams = getValue(xmlObj, ['CprjInfo', 'Rate', 'RateParams', '_KeyId']);
+      const rateValues = getValue(xmlObj, ['CprjInfo', 'Rate', 'RateValues', '_KeyId']);
+      const mps = getValue(xmlObj, ['CprjInfo', 'Pract', 'Mps', '_KeyId']);
+      const materials = getValue(xmlObj, ['CprjInfo', 'Pract', 'Materials', '_KeyId']);
+      const mechs = getValue(xmlObj, ['CprjInfo', 'Pract', 'Mechs', '_KeyId']);
+      const makeInfo = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'MakeInfo', '_KeyId']);
+      const params = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'Params', '_KeyId']);
+      const items = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'Items', '_KeyId']);
+      return {
+        cprjInfo,
+        systemInfo,
+        costBasis,
+        rate,
+        pract,
+        eprjInfo,
+        indexs,
+        rateParams,
+        rateValues,
+        mps,
+        materials,
+        mechs,
+        makeInfo,
+        params,
+        items,
+      }
     }
-  
-    async function entry(areaKey, xmlObj) {
-      const {
-        UTIL: {
-          getValue,
-          arrayValue,
-          getBool,
-          extractItemsRecur,
-        }
-      } = INTERFACE_EXPORT_BASE;
-      let info = [];
-      let tenders = [];
-      let CprjInfo = getValue(xmlObj, ['CprjInfo']);
-      let EprjInfos = arrayValue(CprjInfo, ["EprjInfo"]);
-      if (EprjInfos.length > 0) { 
-        let MakeInfo = EprjInfos[0].MakeInfo;
-        let Params = EprjInfos[0].Params;
-        let BuildType = getValue(Params, ['_BuildType']);
-        let natureConstruction = "";
-        if (BuildType == "0") natureConstruction = "新建";
-        if (BuildType == "1") natureConstruction = "改扩建";
-  
-        let terrainCategory = "";
-        let Terrain = getValue(Params, ['_Terrain']);
-        if (Terrain == "0") terrainCategory = "平原微丘";
-        if (Terrain == "1") terrainCategory = "山岭重丘";
-        let RoadGrade = getValue(Params, ['_RoadGrade']);
-        let roadGrade = "";
-        if (RoadGradeMap[RoadGrade]) roadGrade = RoadGradeMap[RoadGrade];
-  
-  
-  
-        info = [
-          { key: 'constructingUnit', value: getValue(MakeInfo, ['_Manage']) },
-          { key: 'designUnit', value: getValue(MakeInfo, ['_Designer']) },
-          { key: 'compileUnit', value: getValue(MakeInfo, ['_Compile']) },
-          { key: 'compileApprover', value: getValue(MakeInfo, ['_CompileApprover']) },
-          { key: 'compileCertNo', value: getValue(MakeInfo, ['_CompileCertNo']) },
-          { key: 'compileDate', value: formateDataString(getValue(MakeInfo, ['_CompileDate'])) },
-          { key: 'reviewUnit', value: getValue(MakeInfo, ['_Review']) },
-          { key: 'reviewApprover', value: getValue(MakeInfo, ['_ReviewApprover']) },
-          { key: 'reviewCertNo', value: getValue(MakeInfo, ['_ReviewCertNo']) },
-          { key: 'reviewDate', value: formateDataString(getValue(MakeInfo, ['_ReviewDate'])) },
-          { key: 'startChainages', value: getValue(Params, ['_StartPileNo'])},
-          { key: 'endChainages', value: getValue(Params, ['_EndPileNo']) },  
-          { key: 'location', value: getValue(Params, ['_PrjArea']) },  
-          { key: 'natureConstruction', value: natureConstruction },  
-          { key: 'terrainCategory', value: terrainCategory },  
-          { key: 'roadGrade', value: roadGrade },  
-          { key: 'makeDate', value: getValue(CprjInfo, ['SystemInfo','_MakeDate']) },
-          { key: 'keyId', value: getValue(CprjInfo, ['KeyId']) },
-          { key: 'systemInfoKeyId', value: getValue(CprjInfo, ['SystemInfo','KeyId']) },
-          { key: 'CostBasisKeyId', value: getValue(CprjInfo, ['CostBasis','KeyId']) },
-          // { key: 'keyId', value: getValue(CprjInfo, ['SystemInfo','KeyId']) },
-  
-        ]
-        for (let t of EprjInfos) { 
-          tenders.push(setupTender(t))
-        }
-  
-  
+
+    function setupTender(EprjInfo) {
+      let tender = {};
+      let Params = EprjInfo.Params;
+      // let SummaryOfCost = EprjInfo.SummaryOfCost;
+      tender.name = EprjInfo._Name;
+      tender.bills = [];
+      tender.bidEvaluationList = [];
+      tender.evaluationList = [];
+      // let ProvisionalSums = getValue(SummaryOfCost, ['_ProvisionalSums']);
+      let Structure = getValue(Params, ['_Structure']);
+      let pavementStructure = "";
+      if (Structure == "0") pavementStructure = "沥青路面";
+      if (Structure == "1") pavementStructure = "水泥混凝土路面";
+      if (Structure == "2") pavementStructure = "其他类型路面";
+      tender.feature = [
+        // { key: 'tenderSumLimit', value: getValue(SummaryOfCost, ['_TenderSumLimit'])},//招标控制价
+        { key: 'designSpeed', value: getValue(Params, ['_DesignSpeed']) },// --todo
+        { key: 'pavementStructure', value: pavementStructure },// --todo
+        { key: 'subgradeWidth', value: getValue(Params, ['_SubgradeWidth']) },
+        { key: 'roadLength', value: getValue(Params, ['_RoadLength']) },// --todo
+        { key: 'bridgeLength', value: getValue(Params, ['_BridgeLength']) },
+        { key: 'tunnelLength', value: getValue(Params, ['_TunnelLength']) },// --todo
+        { key: 'briTunRate', value: getValue(Params, ['_BriTunRate']) },// --todo
+        { key: 'interchangeNum', value: getValue(Params, ['_InterchangeNum']) },// --todo
+        { key: 'stubLengths', value: getValue(Params, ['_StubLengths']) },// --todo
+        { key: 'laneLength', value: getValue(Params, ['_LaneLength']) },// --todo
+      ]
+      const items = arrayValue(EprjInfo, ['Items', 'Item']);
+      for (let i of items) {
+        let bill = setupBills(i);
+        // if (bill.name == "暂列金额(不含计日工总额)") { 
+        //   bill.fees = [{ fieldName: "common",tenderTotalFee:ProvisionalSums, tenderUnitFee: "0", totalFee: ProvisionalSums, unitFee: "0" }];
+        //   bill.calcBase = ProvisionalSums;
+        //   bill.calcFlag = 1;
+        // } 
+        tender.bills.push(bill);
       }
-  
-      function setupTender(EprjInfo) { 
-        let tender = {};
-        let Params = EprjInfo.Params;
-        // let SummaryOfCost = EprjInfo.SummaryOfCost;
-        tender.name = EprjInfo._Name;
-        tender.bills = [];
-        tender.bidEvaluationList = [];
-        tender.evaluationList = [];
-        // let ProvisionalSums = getValue(SummaryOfCost, ['_ProvisionalSums']);
-        let Structure = getValue(Params, ['_Structure']);
-        let pavementStructure = "";
-        if (Structure == "0") pavementStructure = "沥青路面";
-        if (Structure == "1") pavementStructure = "水泥混凝土路面";
-        if (Structure == "2") pavementStructure = "其他类型路面";
-        tender.feature = [
-          // { key: 'tenderSumLimit', value: getValue(SummaryOfCost, ['_TenderSumLimit'])},//招标控制价
-          { key: 'designSpeed', value: getValue(Params, ['_DesignSpeed']) },// --todo
-          { key: 'pavementStructure', value: pavementStructure},// --todo
-          { key: 'subgradeWidth', value: getValue(Params, ['_SubgradeWidth']) },
-          { key: 'roadLength', value: getValue(Params, ['_RoadLength']) },// --todo
-          { key: 'bridgeLength', value: getValue(Params, ['_BridgeLength']) },
-          { key: 'tunnelLength', value: getValue(Params, ['_TunnelLength']) },// --todo
-          { key: 'briTunRate', value: getValue(Params, ['_BriTunRate']) },// --todo
-          { key: 'interchangeNum', value: getValue(Params, ['_InterchangeNum']) },// --todo
-          { key: 'stubLengths', value: getValue(Params, ['_StubLengths']) },// --todo
-          { key: 'laneLength', value: getValue(Params, ['_LaneLength']) },// --todo
-        ]
-        const items = arrayValue(EprjInfo, ['Items', 'Item']);
-        for (let i of items) {
-          let bill = setupBills(i);
-          // if (bill.name == "暂列金额(不含计日工总额)") { 
-          //   bill.fees = [{ fieldName: "common",tenderTotalFee:ProvisionalSums, tenderUnitFee: "0", totalFee: ProvisionalSums, unitFee: "0" }];
-          //   bill.calcBase = ProvisionalSums;
-          //   bill.calcFlag = 1;
-          // } 
-          tender.bills.push(bill);
-        }
-        const BidEvaluationMainMaterial = arrayValue(EprjInfo, ['BidEvaluationMainMaterial']);
-        for (let b of BidEvaluationMainMaterial) { 
-          tender.bidEvaluationList.push(setUpBidEvaluation(b))
-        }
-        
-        return tender;
+      const BidEvaluationMainMaterial = arrayValue(EprjInfo, ['BidEvaluationMainMaterial']);
+      for (let b of BidEvaluationMainMaterial) {
+        tender.bidEvaluationList.push(setUpBidEvaluation(b))
       }
-  
-  
-      function setupBills(item) { 
-        let bill = {
-          code: item._ListCode,
-          name: item._ListName,
-          unit: item._Unit,
-          quantity: item._Num,
-          remark: item._Remarks,
-          jobContentText: item._Content,
-          specialProvisional: '',
-          children: []
-        }
-        if (item._ProvisionalType == '0') bill.specialProvisional = '材料';
-        if (item._ProvisionalType == '1') bill.specialProvisional = '工程设备';
-        if (item._ProvisionalType == '2') bill.specialProvisional = '工程设备';
-        let subItems = arrayValue(item, ['Item']);
-        if (subItems && subItems.length > 0) { 
-          for (let i of subItems) { 
-            bill.children.push(setupBills(i))
-          }
-        }
-        return bill;
+
+      return tender;
+    }
+
+    // 获取清单相关的KeyId数据
+    function getBillKeyIDData(billItem) {
+      const item = getValue(billItem, ['_KeyId']);
+      const costComposition = getValue(billItem, ['CostComposition', '_KeyId']);
+      const formula = getValue(billItem, ['Formula', '_KeyId']);
+      const costStructure = getValue(billItem, ['CostStructure', '_KeyId']) || getValue(billItem, ['CostComposition', 'Cost', 'CostStructure', '_KeyId']);
+      return {
+        item,
+        costComposition,
+        formula,
+        costStructure
+      }
+    }
+
+
+    function setupBills(item) {
+      let bill = {
+        code: item._ListCode,
+        name: item._ListName,
+        unit: item._Unit,
+        quantity: item._Num,
+        remark: item._Remarks,
+        jobContentText: item._Content,
+        specialProvisional: '',
+        keyIDData: getBillKeyIDData(item),
+        children: []
       }
-  
-      function setUpBidEvaluation(b) { 
-        return {
-          seq: b._Code,
-          code: b._Number,
-          name: b._Name,
-          specs: b._Specification,
-          unit: b._Unit,
-          market_price: b._Price,
-          quantity: b._Quantity,
-          remark:b._Remark
+      if (item._ProvisionalType == '0') bill.specialProvisional = '材料';
+      if (item._ProvisionalType == '1') bill.specialProvisional = '工程设备';
+      if (item._ProvisionalType == '2') bill.specialProvisional = '工程设备';
+      let subItems = arrayValue(item, ['Item']);
+      if (subItems && subItems.length > 0) {
+        for (let i of subItems) {
+          bill.children.push(setupBills(i))
         }
       }
-      
-  
+      return bill;
+    }
+
+    function setUpBidEvaluation(b) {
       return {
-        name: CprjInfo._CprjName,
-        info,
-        tenders,
-      };
-  
+        seq: b._Code,
+        code: b._Number,
+        name: b._Name,
+        specs: b._Specification,
+        unit: b._Unit,
+        market_price: b._Price,
+        quantity: b._Quantity,
+        remark: b._Remark
+      }
     }
-  
+
+
     return {
-      entry
+      name: CprjInfo._CprjName,
+      info,
+      tenders,
+      keyIDData: getConstructionKeyIDData()
     };
-  
-  })();
+
+  }
+
+  return {
+    entry
+  };
+
+})();

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

@@ -66,6 +66,7 @@ const IMPORT_VIEW = (() => {
           areaKey = curAreaKey;
           await STD_INTERFACE.loadScriptByArea(areaKey, STD_INTERFACE.ScriptType.IMPORT);
           const onlyImportMatchBills = areaKey === '广东@中山';
+          debugger;
           importData = await INTERFACE_EXPORT_BASE.extractImportData(INTERFACE_IMPORT.entry, file, areaKey, false, onlyImportMatchBills);
         }
         const constructionName = $('#import-rename').is(':visible') ? $('#import-rename-input').val() : importData.name;