ソースを参照

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

TonyKang 4 年 前
コミット
72287e4bb6

+ 2 - 0
modules/all_models/bills.js

@@ -10,6 +10,7 @@ let billsSchema = new Schema({
     type: String,
     index: true
   },
+  "GUID": String, // 接口需要(导入导出不可变,因此不可用ID作为GUID)
   ParentID: String,
   NextSiblingID: String,
   projectID: {
@@ -99,6 +100,7 @@ let billsSchema = new Schema({
   specialProvisional: String,
   outPutMaxPrice:{type:Schema.Types.Mixed,default:false},//输出最高限价 true 是,false否,null 不确定,三个状态
   outPutLimitPrice:{type:Schema.Types.Mixed,default:false},//输出限价 true 是,false否,null 不确定,三个状态
+  appraisalBills:{type:Schema.Types.Mixed,default:false},//true 是,false否,null 不确定,三个状态
   maxPrice:String,//最高限价
   minPrice:String,//最低限价
   remark: String,

+ 1 - 0
modules/all_models/projects.js

@@ -16,6 +16,7 @@ const shareSchema = new Schema({
 }, {versionKey: false, _id: false});
 const ProjectSchema = new Schema({
     "ID":{type: Number, index: true},
+    "GUID": String, // 接口需要
     "ParentID": Number,
     "NextSiblingID": Number,
     "userID": String,

+ 1 - 0
modules/all_models/ration.js

@@ -29,6 +29,7 @@ let rationSchema = new Schema({
     // 公用属性部分
     ID: {type: String, index: true},
     projectID: {type: Number, index: true},
+    "GUID": String, // 接口需要(导入导出不可变,因此不可用ID作为GUID)
     billsItemID: String,
     serialNo: Number,
     code: String,

+ 32 - 2
modules/fee_rates/facade/fee_rates_facade.js

@@ -297,7 +297,34 @@ async function getAllSubRatesMap(feeRateID){
 }
 
 function sumParentRate(IDMap,childrenMap,decimal){
-    for(let ParentID in  childrenMap){
+
+    for(let ID in IDMap){
+        if(childrenMap[ID]) continue;//找出最底层的叶子节点
+        sum(ID);
+    }
+    
+    function sum(subID){
+        let subRate = IDMap[subID];
+        if(subRate.name === '雨季施工增加费'){
+            console.log('a');
+        }
+        let parent = IDMap[subRate.ParentID];
+        if(parent &&parent.sum === true&& childrenMap[parent.ID]){
+            let childrenList = childrenMap[subRate.ParentID];
+            let total = 0;
+            for(let c of childrenList){
+                let tem = c.rate?c.rate:0;
+                tem = scMathUtil.roundForObj(tem,decimal);
+                total = scMathUtil.roundForObj(tem + total,6);
+            }
+            total = scMathUtil.roundForObj(total,decimal);
+            parent.rate = total;
+            sum(parent.ID);
+        }
+
+    }
+
+  /*   for(let ParentID in  childrenMap){
         if(IDMap[ParentID] && IDMap[ParentID].sum !== true) continue;
         let childrenList = childrenMap[ParentID];
         let total = 0;
@@ -308,7 +335,10 @@ function sumParentRate(IDMap,childrenMap,decimal){
         }
         total = scMathUtil.roundForObj(total,decimal);
         if(IDMap[ParentID])IDMap[ParentID].rate = total;
-    }
+    } */
+
+
+     
 }
 
 function setRatesByMap(newFeeRate,subMap,decimal){

+ 13 - 5
modules/pm/controllers/pm_controller.js

@@ -105,6 +105,7 @@ module.exports = {
     updateMixDatas: async function (req, res) {
         let datas = JSON.parse(req.body.data).mixDataArr;
         let functions = [];
+        let specialResult = {};
 
         function updateFunc(model, cod, doc) {
             return function (cb) {
@@ -134,13 +135,20 @@ module.exports = {
                 const engineeringItem = _.find(datas.properties['property.projectFeature'], { key: 'engineering' });
                 const feeStandardItem = _.find(datas.properties['property.projectFeature'], { key: 'feeStandard' });
                 if (engineeringItem && engineeringItem.value && feeStandardItem && feeStandardItem.value) {
-                    const project = await projectModel.findOne({ ID: datas.projectID }, { 'property.valuation': 1 }).lean();
+                    const project = await projectModel.findOne({ ID: datas.projectID }, { 'property.valuation': 1, 'property.engineering_id': 1 }).lean();
                     if (project) {
-                        const engineering = await engineeringModel.findOne({ valuationID: project.property.valuation, name: engineeringItem.value, feeName: feeStandardItem.value }, { _id: 1 }).lean();
-                        if (engineering) {
+                        const orgEngineeringID = project.property.engineering_id;
+                        const engineering = await engineeringModel.findOne({ valuationID: project.property.valuation, name: engineeringItem.value, feeName: feeStandardItem.value }, { _id: 1, tax_group: 1, bill_lib: 1 }).lean();
+                        if (engineering && orgEngineeringID !== engineering._id.toString()) {
                             datas.properties['property.engineeringName'] = engineeringItem.value;
                             datas.properties['property.feeStandardName'] = feeStandardItem.value;
                             datas.properties['property.engineering_id'] = engineering._id.toString();
+                            if (engineering.tax_group && engineering.tax_group[0] && engineering.tax_group[0].fee_lib) {
+                                // 工程专业变更,需要更改费率
+                                specialResult.newFeeLibID = engineering.tax_group[0].fee_lib.id;
+                            }
+                            specialResult.billLibs = engineering.bill_lib;
+                            
                         }
                     }
                 }
@@ -175,7 +183,7 @@ module.exports = {
         asyncTool.parallel(functions, function (err, result) {
             {
                 if (!err) {
-                    res.json({ error: 0, message: err, data: result });
+                    res.json({ error: 0, message: err, data: specialResult});
                 } else {
                     res.json({ error: 1, message: err, data: null });
                 }
@@ -1044,7 +1052,7 @@ module.exports = {
     getImportTemplateData: async function (req, res) {
         try {
             const data = JSON.parse(req.body.data);
-            const templateData = await pm_facade.getImportTemplateData(req.session.sessionCompilation._id, data.feeName, data.valuationID, data.projectCount);
+            const templateData = await pm_facade.getImportTemplateData(req.session.sessionCompilation._id, data.valuationID, data.engineeringID, data.projectCount);
             callback(req, res, 0, 'success', templateData);
         } catch (err) {
             callback(req, res, 1, err, null);

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

@@ -572,6 +572,7 @@ async function copyExample(userID, compilation, projIDs,nameMap){
         data.NextSiblingID = IDMapping[data.NextSiblingID] ? IDMapping[data.NextSiblingID] : -1;
         data.createDateTime = newDate;
         data.userID = userID;
+        data.GUID = uuidV1();
         data.compilation = compilation;
         data.fileVer = await index.getVersion();
         data.shareInfo = [];
@@ -662,6 +663,7 @@ async function copyProject(userID, compilationID, data, newProjectID = null, del
     logger.info("复制项目: 旧项目ID: "+originalID+ " ------- 新项目ID: "+newProjectID);
     //更新项目的属性;
     projectMap['copy'].document.ID = newProjectID;
+    projectMap['copy'].document.GUID = uuidV1();
     if(projectMap['copy'].document.property.calcProgramFile){
         projectMap['copy'].document.property.calcProgramFile.ID = calcProgramFileID;
     }
@@ -2329,6 +2331,7 @@ async function handleMainProjectDatas(mainData,updateData,userID) {
             p.ParentID = projectIDMap[p.ParentID];
             p.NextSiblingID = projectIDMap[p.NextSiblingID];
         }
+        p.GUID = uuidV1(); // 接口需要
         p.userID =userID;
         p.shareInfo=[];
         if(p.projType == "Tender"){
@@ -2637,8 +2640,10 @@ async function getBasicInfo(compilationID, fileKind = null) {
 }
 
 // 获取导入接口功能的模板数据,用于将导入数据与模板数据进行合并生成新的项目
-async function getImportTemplateData(compilationID, feeName, valuationID, projectCount) {
-    const engineeringLib = await engineeringModel.findOne({ feeName, valuationID }).lean();
+async function getImportTemplateData(compilationID, valuationID, engineeringID, projectCount) {
+    const engineeringLib = engineeringID 
+        ? await engineeringModel.findOne({ _id: mongoose.Types.ObjectId(engineeringID) }).lean()
+        : await engineeringModel.findOne({ valuationID }).lean()
     if (!engineeringLib) {
         return null;
     }

+ 2 - 0
modules/pm/models/project_model.js

@@ -53,6 +53,7 @@ let Projects = mongoose.model('projects');
 let mainColLibModel = mongoose.model('std_main_col_lib');
 let projSettingModel = mongoose.model('proj_setting');
 let optionModel = mongoose.model('options');
+const uuidV1 = require('uuid/v1');
 
 function ProjectsDAO() {
 }
@@ -140,6 +141,7 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                 if(compilation.overWriteUrl && compilation.overWriteUrl!=""){
                     overWrite = require("../../.."+compilation.overWriteUrl);
                 }
+                data.updateData.GUID = uuidV1();
                 data.updateData['userID'] = userId;
                 data.updateData['compilation'] = compilationId;
                 data.updateData['createDateTime'] = new Date();

+ 3 - 1
public/web/tree_sheet/tree_sheet_helper.js

@@ -187,8 +187,10 @@ var TREE_SHEET_HELPER = {
                 if (colSetting.data.getText && Object.prototype.toString.apply(colSetting.data.getText) === "[object Function]") {
                     if(colSetting.data.field=="quantity") sheet.setFormatter(iRow, iCol, '@');//输入 % 号时会出现奇怪的现像, %一直追加在后面
                     cell.value(colSetting.data.getText(node));
-                } else if(['outPutMaxPrice', 'outPutLimitPrice'].includes(colSetting.data.field) && node.sourceType === projectObj.project.Bills.getSourceType()){//主要清单有三种状态,所以直接显示就好,不走最后的逻辑
+                } else if((colSetting.data.field=="appraisalBills" && MainTreeCol.appraisalBillsEnable(node)) || (['outPutMaxPrice', 'outPutLimitPrice'].includes(colSetting.data.field) && node.sourceType === projectObj.project.Bills.getSourceType())){//主要清单有三种状态,所以直接显示就好,不走最后的逻辑
                     cell.value(node.data[colSetting.data.field]===undefined?false:node.data[colSetting.data.field]);
+                } else if((colSetting.data.field=="appraisalBills" && !MainTreeCol.appraisalBillsEnable(node))) {
+                    cell.value('');
                 } else {
                     cell.value(getFieldText2());
                 }

+ 1 - 1
web/building_saas/main/html/main.html

@@ -113,7 +113,7 @@
                               </div>
                               <!--<a href="javascript:void(0);" id="ZLFB_btn" class="dropdown-item" data-placement="bottom"><i class="fa fa-retweet" aria-hidden="true"></i> 整理分部</a>
                                 <a id="switchTznr" href="javascript:void(0);"  class="dropdown-item"><i class="fa fa-eye" aria-hidden="true"></i> 显示特征</a>-->
-                            <% if((compilationName === '公路造价(2018)' || compilationName === '安徽养护(2018)' || compilationName === '广东公路造价(2018)') && boqType) { %>
+                            <% if((compilationName === '公路造价(2018)' || compilationName === '安徽养护(2018)' || compilationName === '广东公路造价(2018)' || compilationName === '浙江养护(2005)') && boqType) { %>
                                 <a class="dropdown-item" id="open-export-modal" href="javascript:void(0);"><i class="fa fa-code-fork"></i> 数据接口</a>
                                 <!-- <a class="dropdown-item" id="open-export-modal" href="javascript:void(0);" data-toggle="modal" data-target="#interface-export-modal"><i class="fa fa-code-fork"></i> 数据接口</a> -->
                             <% }%>

+ 15 - 0
web/building_saas/main/js/models/cache_tree.js

@@ -177,6 +177,21 @@ var cacheTree = {
             return iCount;
         };
 
+        // 获取节点所有后代节点
+        Node.prototype.getPosterity = function() {
+            let posterity = [];
+            getNodes(this.children);
+            return posterity;
+            function getNodes(nodes) {
+                for (let node of nodes) {
+                    posterity.push(node);
+                    if (node.children.length > 0){
+                        getNodes(node.children);
+                    }
+                }
+            }
+        };
+
         Node.prototype.setExpanded = function (expanded) {
             var setNodesVisible = function (nodes, visible) {
                 nodes.forEach(function (node) {

+ 2 - 2
web/building_saas/main/js/views/divide_view.js

@@ -258,8 +258,8 @@ let divideObj = {
     this.execBillsSheet.setRowCount(this.execBillsDatas.length);
   },
 
-  getExeBillCode:function(ID){//从后面往前匹配好像简单一点,可能想得复杂了
-    let bNode = projectObj.project.mainTree.findNode(ID);
+  getExeBillCode:function(ID,tree=projectObj.project.mainTree){//从后面往前匹配好像简单一点,可能想得复杂了
+    let bNode = tree.findNode(ID);
     if(!bNode) return "";
     let nodes= [];
     getNodes(bNode);

+ 26 - 21
web/building_saas/main/js/views/fee_rate_view.js

@@ -498,30 +498,35 @@ var feeRateObject={
         }
         me.updateFeerateWhenCellsChange(changeCells);
     },
-    sumParentRate:function (rateID,value,updateDatas) {
+    sumParentRate:function (subRateID,subValue,updateDatas) {
         let feeRate = projectObj.project.FeeRate;
-        let rate = feeRate.getFeeRateByID(rateID);
-        let parent = feeRate.getFeeRateByID(rate.ParentID);
-        if(parent && parent.sum == true){
-            let suRates = feeRate.getChildrenByID(parent.ID);
-            let total = 0;
-            for(let r of suRates) {
-                let tem = r.rate ? r.rate:0;
-                tem = scMathUtil.roundForObj(tem,getDecimal("feeRate"));
-                if (rateID == r.ID){
-                    tem = value;
+        sum(subRateID,subValue);
+
+        function sum(rateID,value){
+            let rate = feeRate.getFeeRateByID(rateID);
+            let parent = feeRate.getFeeRateByID(rate.ParentID);
+            if(parent && parent.sum == true){
+                let suRates = feeRate.getChildrenByID(parent.ID);
+                let total = 0;
+                for(let r of suRates) {
+                    let tem = r.rate ? r.rate:0;
+                    tem = scMathUtil.roundForObj(tem,getDecimal("feeRate"));
+                    if (rateID == r.ID){
+                        tem = value;
+                    }else {
+                        let u = _.find(updateDatas,{"rateID":r.ID})//看是不是更新的过程中包含了汇总的数据
+                        if(u && gljUtil.isDef(u.doc.rate)) tem = u.doc.rate;
+                    }
+                    total = scMathUtil.roundForObj(tem + total,getDecimal('process'))
+                }
+                total = scMathUtil.roundForObj(total,getDecimal("feeRate"));
+                let tp =  _.find(updateDatas,{"rateID":parent.ID});//如果父节点也在更新列表中
+                if(tp){
+                    tp.doc.rate = total
                 }else {
-                    let u = _.find(updateDatas,{"rateID":r.ID})//看是不是更新的过程中包含了汇总的数据
-                    if(u && gljUtil.isDef(u.doc.rate)) tem = u.doc.rate;
+                    updateDatas.push({rateID:parent.ID,doc:{rate:total}});
                 }
-                total = scMathUtil.roundForObj(tem + total,getDecimal('process'))
-            }
-            total = scMathUtil.roundForObj(total,getDecimal("feeRate"));
-            let tp =  _.find(updateDatas,{"rateID":parent.ID});//如果父节点也在更新列表中
-            if(tp){
-                tp.doc.rate = total
-            }else {
-                updateDatas.push({rateID:parent.ID,doc:{rate:total}});
+                sum(parent.ID,total);
             }
         }
 

+ 11 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -441,7 +441,18 @@ let MainTreeCol = {
       };
       return sheetCommonObj.getTipsText(tips, setting, node);
     } */
+    appraisalBills:function (node) {
+      if(MainTreeCol.appraisalBillsEnable(node)) {
+          return projectObj.project.projectInfo.property.lockBills 
+              ? sheetCommonObj.getReadOnlyCheckBox()
+              : sheetCommonObj.getCheckBox(true)
+      };
+},
   },
+  appraisalBillsEnable:function (node) {
+    let Bills = projectObj.project.Bills;
+    return Bills.isBelongOneToSeven(node) && node.sourceType === ModuleNames.bills && node.getFlag() !== fixedFlag.ONE_SEVEN_BILLS;
+},
   editChecking: function (node) {
     if (node.sourceType == projectObj.project.Bills.getSourceType() && projectObj.project.isBillsLocked() && projectObj.project.withinBillsLocked(node)) {
       return true;

+ 43 - 23
web/building_saas/main/js/views/project_view.js

@@ -1923,7 +1923,7 @@ var projectObj = {
             projectObj.onEvaluationProjectClic(node,info);
         }else if(fieldName == "unitPriceAnalysis"){
             projectObj.onUnitPriceAnalysisClick(node,info);
-        }else if(fieldName == "lockUnitPrice"||fieldName == "outPutMaxPrice"||fieldName=="outPutLimitPrice"){
+        }else if(fieldName == 'appraisalBills' || fieldName == "lockUnitPrice"||fieldName == "outPutMaxPrice"||fieldName=="outPutLimitPrice"){
           projectObj.onCasCadeButtonClick(node,info,fieldName);
       }
     },
@@ -2758,32 +2758,52 @@ $('#property_ok').click(function () {
 
     if(hasMixData()){
         CommonAjax.post('/pm/api/updateMixDatas', {user_id: userID, mixDataArr: mixDatas}, function (rstData) {
-            //需要重载页面
-            if(needToReload(mixDatas)){
-                window.location.href = '/main?project=' + projectID;
-            }
-            else{
-                if(mixDatas.properties.hasOwnProperty('property.maxPriceRate')){
-                    projectObj.project.property.maxPriceRate = maxPriceRate;
-                }
-                if(mixDatas.properties.hasOwnProperty('property.minPriceRate')){
-                    projectObj.project.property.minPriceRate = minPriceRate;
-                }
-                if(mixDatas.properties.hasOwnProperty('property.basicInformation')){
-                    basicInfoView.orgDatas = basicInfoView.toViewDatas(mixDatas.properties['property.basicInformation']);
+            const doAferSuccess = () => {
+                $.bootstrapLoading.end();
+                //需要重载页面
+                if(needToReload(mixDatas)){
+                    window.location.href = '/main?project=' + projectID;
                 }
-                if(mixDatas.properties.hasOwnProperty('property.projectFeature')){
-                    projFeatureView.orgDatas = projFeatureView.toViewDatas(mixDatas.properties['property.projectFeature']);
+                else{
+                    if(mixDatas.properties.hasOwnProperty('property.maxPriceRate')){
+                        projectObj.project.property.maxPriceRate = maxPriceRate;
+                    }
+                    if(mixDatas.properties.hasOwnProperty('property.minPriceRate')){
+                        projectObj.project.property.minPriceRate = minPriceRate;
+                    }
+                    if(mixDatas.properties.hasOwnProperty('property.basicInformation')){
+                        basicInfoView.orgDatas = basicInfoView.toViewDatas(mixDatas.properties['property.basicInformation']);
+                    }
+                    if(mixDatas.properties.hasOwnProperty('property.projectFeature')){
+                        projFeatureView.orgDatas = projFeatureView.toViewDatas(mixDatas.properties['property.projectFeature']);
+                    }
+                    if(mixDatas.options && mixDatas.options.updateData){
+                        let v1 = mixDatas.options.updateData['rationQuanACToBillsQuan'],
+                            v2 = mixDatas.options.updateData['rationQuanACToRationUnit'],
+                            progressiveType = mixDatas.options.updateData['progressiveType']  ;
+                        optionsOprObj.updateOptions(optionsOprObj.options, {type: optionsOprObj.optionsTypes.GENERALOPTS, opt: 'rationQuanACToBillsQuan', value: v1});
+                        optionsOprObj.updateOptions(optionsOprObj.options, {type: option-sOprObj.optionsTypes.GENERALOPTS, opt: 'rationQuanACToRationUnit', value: v2});
+                        optionsOprObj.updateOptions(optionsOprObj.options, {type: optionsOprObj.optionsTypes.GENERALOPTS, opt: 'progressiveType', value: progressiveType});
+                    }
                 }
-                if(mixDatas.options && mixDatas.options.updateData){
-                    let v1 = mixDatas.options.updateData['rationQuanACToBillsQuan'],
-                        v2 = mixDatas.options.updateData['rationQuanACToRationUnit'],
-                        progressiveType = mixDatas.options.updateData['progressiveType']  ;
-                    optionsOprObj.updateOptions(optionsOprObj.options, {type: optionsOprObj.optionsTypes.GENERALOPTS, opt: 'rationQuanACToBillsQuan', value: v1});
-                    optionsOprObj.updateOptions(optionsOprObj.options, {type: optionsOprObj.optionsTypes.GENERALOPTS, opt: 'rationQuanACToRationUnit', value: v2});
-                    optionsOprObj.updateOptions(optionsOprObj.options, {type: optionsOprObj.optionsTypes.GENERALOPTS, opt: 'progressiveType', value: progressiveType});
+            }
+            // 改变清单库
+            if (rstData && rstData.billLibs) {
+                projectObj.project.projectInfo.engineeringInfo.bill_lib = rstData.billLibs;
+                $('#stdBillsGuidanceLibSelect').empty();
+                if ($('#zy').is(':visible')) {
+                    billsGuidance.initLibs(rstData.billLibs);
                 }
             }
+            // 需要改变费率
+            if (rstData && rstData.newFeeLibID) {
+                $.bootstrapLoading.start();
+                feeRateObject.feeRateSTDLoaded = false;
+                feeRateObject.feeRateSTDList = [];
+                projectObj.project.FeeRate.changeFeeRateStandard(rstData.newFeeLibID,doAferSuccess);
+            } else {
+                doAferSuccess();
+            }
         });
     }
 });

+ 1 - 1
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -1330,7 +1330,7 @@ const billsGuidance = (function () {
         }
     }
 
-    return {initViews, bindBtn, refreshWorkBook, setColumnWidthByRate, locateAtBills, bills, elfItem, overwrite};
+    return {initViews, initLibs, bindBtn, refreshWorkBook, setColumnWidthByRate, locateAtBills, bills, elfItem, overwrite};
 })();
 
 $(document).ready(function(){

+ 2 - 2
web/building_saas/pm/js/pm_newMain.js

@@ -338,7 +338,7 @@ const projTreeObj = {
             name: '导入接口文件',
             icon: 'fa-cloud-upload',
             visible: function () {
-                const names = ['公路造价(2018)', '安徽养护(2018)', '广东公路造价(2018)'];
+                const names = ['公路造价(2018)', '安徽养护(2018)', '广东公路造价(2018)', '浙江养护(2005)'];
                 return compilationData && names.includes(compilationData.name);
             },
             callback: function () {
@@ -346,7 +346,7 @@ const projTreeObj = {
                     () => $('#interface-import-modal').modal('show'),
                     () => alert(`${commonUtil.getVersionText()}不提供此功能。`)
                 );
-                //$('#interface-import-modal').modal('show');
+                // $('#interface-import-modal').modal('show');
             }
         },
         manageFiles: {

+ 9 - 1
web/building_saas/standard_interface/config.js

@@ -103,13 +103,21 @@ const INTERFACE_CONFIG = (() => {
         [CONTROL]: '.xjglkzjx',
       },
     },
-    '甘肃@张掖': {
+    /* '甘肃@张掖': {
       scriptName: 'anhui_maanshan.js',
       fileSuffix: {
         [BID_INVITATION]: '.ZYEGLZB',
         [BID_SUBMISSION]: '.ZYEGLTB',
         [CONTROL]: '.ZYEGLKZJ',
       },
+    }, */
+    '浙江@宁海': {
+      scriptName: 'zhejiang_ninghai.js',
+      fileSuffix: {
+        [BID_INVITATION]: '.zjglzb',
+        [BID_SUBMISSION]: '.zjgltb',
+        [CONTROL]: '.zjglzbkzj',
+      },
     }
   };
 })()

+ 8 - 3
web/building_saas/standard_interface/export/base.js

@@ -241,8 +241,8 @@ const INTERFACE_EXPORT_BASE = (() => {
    * @return {Number}
    * @example getFee(source.fees, 'common.totalFee')
    * */
-  function getFee(fees, feeFields) {
-    if (!Array.isArray(fees)) {
+  function getFee(fees, feeFields, exportKind = null) {
+    if (exportKind === EXPORT_KIND.BID_INVITATION || !Array.isArray(fees)) {
       return 0;
     }
     const fields = feeFields.split('.');
@@ -255,7 +255,7 @@ const INTERFACE_EXPORT_BASE = (() => {
 
   //取单价等
   function getUnitFee(fee,quantity,decimal){
-    if(!!quantity && quantity!==0){
+    if(!!+quantity && +quantity !== 0){
       return scMathUtil.roundForObj(fee/parseFloat(quantity),decimal)
     }
     return fee
@@ -274,6 +274,10 @@ const INTERFACE_EXPORT_BASE = (() => {
     const node = items.find(node => node.getFlag() === flag);
     return node ? getFee(node.data.fees, feeFields) : '0';
   }
+  // 获取固定类别节点
+  function getNodeByFlag(tree, flag) {
+    return tree.items.find(node => node.getFlag() === flag);
+  }
   /*
    * 根据key获取对应的基本信息、工程特征数据
    * @param  {Array}data
@@ -699,6 +703,7 @@ const INTERFACE_EXPORT_BASE = (() => {
     getUnitFee,
     getAggregateFee,
     getFeeByFlag,
+    getNodeByFlag,
     getPlainAttrs,
     getValueByKey,
     getRelGLJ,

+ 780 - 0
web/building_saas/standard_interface/export/zhejiang_ninghai.js

@@ -0,0 +1,780 @@
+// 浙江-宁海
+INTERFACE_EXPORT = (() => {
+  'use strict';
+
+  /**
+   * 
+   * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
+   * @param {Number} exportKind - 导出类型,招标、投标、控制价
+   * @param {Object} projectData - 项目表数据:{ 建设项目Data, children: [单位工程...] }
+   * @param {Object} tenderDetailMap - 单位工程ID与getData接口数据(projectObj.project的结构)的映射。
+   * @return {Promise<Array>} - 返回的数据结构必须按照规定:[{ data, exportKind, fileName }],参考web\building_saas\standard_interface\index.js中的注释说明
+   */
+  async function entry(areaKey, exportKind, projectData, tenderDetailMap) {
+    const {
+      CONFIG: {
+        TYPE,
+        WHITE_SPACE
+      },
+      UTIL: {
+        getValueByKey,
+        getHan,
+        getFee,
+        getUnitFee,
+        getNodeByFlag,
+        generateHardwareId,
+      },
+      Element,
+    } = INTERFACE_EXPORT_BASE;
+
+    const {
+      EXPORT_KIND: { BID_INVITATION, BID_SUBMISSION, CONTROL },
+      fixedFlag,
+      RationType,
+    } = window.commonConstants
+
+    const GljType = gljUtil.gljType;
+
+    const { isEmptyVal, isDef } = window.commonUtil;
+
+    const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
+    const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
+    const isControl = exportKind === CONTROL; // 是否是控制价
+
+    
+    const subArea = areaKey.split('@')[1];
+    const info = projectData.property && projectData.property.basicInformation || [];
+    const { summaryInfo } = projectData;
+    const constructionSummary = summaryInfo[projectData.ID];
+    let curTender;
+
+    // 小数位数(按照需求固定)
+    const qD = 4; // 消耗量
+    const fD = 2; // 费用
+    const pD = 6; // 中间过程
+    
+    // 值映射表
+    const valueMap = {
+      '新建': '1',
+      '改扩建': '2',
+      '养护': '3',
+      '养护(年度经费)': '4',
+      '养护(年度经费)': '4',
+
+      '高速公路': '1',
+      '一级公路': '2',
+      '二级公路': '3',
+      '三级公路': '4',
+      '四级公路': '5',
+      '桥梁工程': '6',
+      '独立桥梁': '6',
+      '隧道工程': '7',
+      '独立隧道': '7',
+      '其他工程': '8',
+      '等外工程': '8',
+
+      '一般计税': '1',
+      '简易计税': '2',
+    }
+
+    // 是否是材料
+    const isMaterial = (type) => {
+      return /^2/.test(type);
+    }
+    
+    // 是否是机械
+    const isMachine = (type) => {
+      return /^3/.test(type);
+    }
+    
+    // 获取预算价
+    const getMarketPrice = (glj) => {
+      const tenderCoe = gljUtil.getTenderPriceCoe(glj, curTender.property);
+      return gljUtil.getMarketPrice(glj, curTender.projectGLJ.datas, curTender.property.calcOptions, curTender.labourCoe.datas, curTender.property.decimal, false, _, scMathUtil, tenderCoe); 
+    }
+
+    // 获取人工单价
+    const getLabourPrice = () => {
+      if (isBidInvitation) {
+        return 0;
+      }
+      const glj = curTender.projectGLJ.datas.gljList.find(glj => glj.type === 1);
+      if (!glj) {
+        return 0;
+      }
+      return getMarketPrice(glj);
+    }
+
+    const subTypeKeyArr = ['code', 'name', 'specs', 'unit', 'subType']
+
+    // 获取人工消耗量
+    const getLabourQuantity = (node) => {
+      if (isBidInvitation) {
+        return 0;
+      }
+      const quantity = +node.data.quantity || 1;
+      let total = 0;
+      const posterity = node.getPosterity();
+      const rations = posterity.filter(item => calcTools.isRationItem(item));
+      rations.forEach(ration => {
+        const labours = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && glj.type === 1);
+        labours.forEach(labour => {
+          total = scMathUtil.roundForObj(total + labour.tenderQuantity * ration.data.tenderQuantity, qD);
+        });
+      });
+      const labourRations = posterity.filter(item => (calcTools.isVolumePrice(item) || calcTools.isGljRation(item)) && item.data.subType === 1);
+      labourRations.forEach(labour => {
+        total = scMathUtil.roundForObj(total + +labour.data.tenderQuantity, qD);
+      });
+      return total / quantity;
+    }
+
+    // 获取主材费、辅材费
+    const getMaterialFee = (node) => {
+      const rst = {
+        mainFee: 0,
+        assFee: 0,
+      };
+      if (isBidInvitation) {
+        return rst;
+      }
+      let quantity = calcTools.isBill(node) ? node.data.quantity : node.data.tenderQuantity;
+      quantity = +quantity || 1;
+      const posterity = calcTools.isBill(node) ? node.getPosterity() : [node];
+      // 计算定额下的费用(限定材料)
+      const rations = posterity.filter(item => calcTools.isRationItem(item));
+      rations.forEach(ration => {
+        const rationGljData = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && isMaterial(glj.type));
+        rationGljData.forEach(rGlj => {
+          const key = gljUtil.getIndex(rGlj);
+          const projectGlj = curTender.projectGLJ.datas.gljMap[key];
+          if (projectGlj) {
+            const gljUnitFee = scMathUtil.roundForObj(rGlj.tenderQuantity * getMarketPrice(projectGlj), pD);
+            const gljTotalFee = scMathUtil.roundForObj(gljUnitFee * ration.data.tenderQuantity, fD);
+            if (projectGlj.is_main_material) {
+              rst.mainFee = scMathUtil.roundForObj(rst.mainFee + gljTotalFee, fD);
+            } else {
+              rst.assFee = scMathUtil.roundForObj( rst.assFee + gljTotalFee, fD);
+            }
+          }
+        });
+      });
+
+      // 计算工料机类型定额、量价(限定材料)
+      const materialRations = posterity.filter(item => calcTools.isGljRation(item) && isMaterial(item.data.subType));
+      materialRations.forEach(ration => {
+        const key = gljUtil.getIndex(ration.data, subTypeKeyArr);
+        const projectGlj = curTender.projectGLJ.datas.gljMap[key];
+        if (projectGlj) {
+          if (projectGlj.is_main_material) {
+            rst.mainFee = scMathUtil.roundForObj(rst.mainFee + getFee(ration.data.fees, 'common.tenderTotalFee'), fD);
+          } else {
+            rst.assFee = scMathUtil.roundForObj(rst.assFee + getFee(ration.data.fees, 'common.tenderTotalFee'), fD);
+          }
+        }
+      });
+
+      const volumes = posterity.filter(item => calcTools.isVolumePrice(item) && isMaterial(item.data.subType));
+      volumes.forEach(vol => {
+        rst.mainFee = scMathUtil.roundForObj(rst.mainFee + getFee(vol.data.fees, 'common.tenderTotalFee'), fD);
+      });
+      rst.mainFee = scMathUtil.roundForObj(rst.mainFee / quantity, fD);
+      rst.assFee = scMathUtil.roundForObj(rst.assFee / quantity, fD);
+      return rst;
+    }
+    
+    // 节点定义--------------------------------
+
+    /* 工程信息 */
+    function GongCXX() {
+      const attrs = [
+          { name: '项目编号', value: getValueByKey(info, 'projNum'), minLen: 1 },
+          { name: '项目名称', value: projectData.name, minLen: 1 },
+          { name: '建设单位', value: getValueByKey(info, 'constructingUnits'), minLen: 1 },
+          { name: '起始桩号', value: getValueByKey(info, 'startChainages') },
+          { name: '终点桩号', value: getValueByKey(info, 'endChainages') },
+          { name: '建设地址', value: getValueByKey(info, 'constructionAddress') },
+          { name: '项目概况', value: getValueByKey(info, 'projOverview') },
+          { name: '项目类型', value: valueMap[getValueByKey(info, 'natureConstruction')] },
+          { name: '专业划分', value: valueMap[getValueByKey(info, 'roadGrade')] },
+          { name: '道路里程-公里', value: getValueByKey(info, 'roadDistance') },
+          { name: '设计单位', value: getValueByKey(info, 'designUnit') },
+          { name: '计税方式', value: valueMap[getValueByKey(info, 'taxMode')] },
+          {name: '文件类型', value: isBidInvitation ? 1 : (isControl ? 2 : 3)},    // 1=工程量清单;2=招标控制价;3=投标报价;
+          { name: '标准版本号', value: '1.0' },
+          { name: 'GUID', value: projectData.GUID }
+      ];
+      Element.call(this, '工程信息', attrs);
+    }
+
+    /* 招标信息 */
+    function ZhaoBiaoXX() {
+      const attrs = [
+          { name: '招标人', value: getValueByKey(info, 'tendereeName'), minLen: 1 },
+          { name: '招标法定代表人或其授权人', value: getValueByKey(info, 'tenderAuthorizer') },
+          { name: '编制人', value: getValueByKey(info, 'compileApprover') },
+          { name: '编制人资格证号', value: getValueByKey(info, 'compileCertNo') },
+          { name: '编制日期', value: getValueByKey(info, 'compileDate'), type: TYPE.DATE},
+          { name: '招标代理机构', value: getValueByKey(info, 'proxy'), minLen: 1},
+          { name: '招标范围', value: getValueByKey(info, 'scopeofBidding')},
+          { name: '总工期日历天', value: getValueByKey(info, 'timeLimit'), minLen: 1},
+      ];
+      Element.call(this, '招标信息', attrs);
+    }
+
+    /* 招标控制价 */
+    function ZhaoBiaoKZJ() {
+      const attrs = [
+          { name: '招标人', value: getValueByKey(info, 'tendereeName'), minLen: 1 },
+          { name: '招标法定代表人或其授权人', value: getValueByKey(info, 'tenderAuthorizer') },
+          { name: '编制人', value: getValueByKey(info, 'compileApprover') },
+          { name: '编制人资格证号', value: getValueByKey(info, 'compileCertNo') },
+          { name: '编制日期', value: getValueByKey(info, 'compileDate'), type: TYPE.DATE},
+          { name: '编制说明', value: getValueByKey(info, 'preparationDescription') },
+          { name: '复核人', value: getValueByKey(info, 'reviewApprover') },
+          { name: '复核人资格证号', value: getValueByKey(info, 'reviewCertNo') },
+          { name: '复核日期', value: getValueByKey(info, 'reviewDate'), type: TYPE.DATE },
+          { name: '审核人', value: getValueByKey(info, 'examineApprover') },
+          { name: '审核人资格证号', value: getValueByKey(info, 'examineCertNo') },
+          { name: '审核日期', value: getValueByKey(info, 'examineDate'), type: TYPE.DATE },
+          { name: '控制价总价', value: constructionSummary.totalCost, type: TYPE.DECIMAL },
+          { name: '备注', value: getValueByKey(info, '') },
+      ];
+      Element.call(this, '招标控制价', attrs);
+    }
+
+    /* 投标信息 */
+    function TouBiaoXX() {
+      let hardID = generateHardwareId();
+      let [cpuId, diskId, macId] = hardID.split(";");
+
+      const attrs = [
+          { name: '投标人', value: getValueByKey(info, 'bidderName'), minLen: 1 },
+          { name: '投标人法人或其授权人', value: getValueByKey(info, 'bidderAuthorizer') },
+          { name: '投标人资质证号', value: getValueByKey(info, 'bidderCertNo') },
+          { name: '总工期日历天', value: getValueByKey(info, 'timeLimit')},
+          { name: '投标总价', value: constructionSummary.totalCost, type: TYPE.DECIMAL },
+          { name: '投标下浮率', value: getValueByKey(info, 'downwardFloatingRateOfBid') },
+          { name: '投标报价说明', value: getValueByKey(info, 'descriptionOfTenderOffer') },
+          { name: '质量承诺', value: getValueByKey(info, 'qualityCommitment') },
+          { name: '投标保证金', value: getValueByKey(info, 'bidBond') },
+          { name: '项目经理或项目负责人', value: getValueByKey(info, 'projectManagers') },
+          { name: '项目经理或项目负责人资格证号', value: getValueByKey(info, 'projectmanagersCertNo') },
+          { name: '造价软件品牌', value: '纵横公路云造价', minLen: 1 },
+          { name: '造价软件版本', value: 'Ver' + VERSION, minLen: 1 },
+          { name: '造价软件加密锁编号', value: userID, minLen: 1 },
+          { name: '计算机硬件信息', value: cpuId + diskId + macId, minLen: 1 },
+          { name: '备注', value: getValueByKey(info, '') },
+      ];
+      Element.call(this, '投标信息', attrs);
+    }
+    
+    /* 工程量清单明细 */
+    let billSeq = 1;
+    // 获取数据类型
+    function getBillDataType(node) {
+      // 目录
+      if (!calcTools.isLeafBill(node)) {
+        return '1';
+      }
+      // 专项暂定
+      if (node.data.specialProvisional == '专业工程') {
+        return '21';
+      }
+      // 安全生产费
+      if (node.data.code == '102-3') {
+        return '22'
+      }
+      // 工程一切险
+      if ((node.data.code == '-a') && (node.parent && (node.parent.data.code == '101-1'))) {
+        return '23'
+      }
+      // 第三者责任险
+      if ((node.data.code == '-b') && (node.parent && (node.parent.data.code == '101-1'))) {
+        return '24'
+      }
+      return '20';
+    }
+
+    // 获取清单章节
+    const getBillSection = (node) => {
+      const parentFlag = node.parent ? node.parent.getFlag() : null;
+      if (parentFlag !== fixedFlag.ONE_SEVEN_BILLS) {
+        let cur = node;
+        while (cur) {
+          if (cur.data.sectionCode) {
+            return cur.data.sectionCode;
+          }
+          cur = cur.parent;
+        }
+        return (cur.data.name || '').replace(/[^0-9]/g, '');
+      } else {
+        const sectionCode = (node.data.name || '').replace(/[^0-9]/g, '');
+        node.data.sectionCode = sectionCode;
+        return sectionCode
+      }
+    }
+
+    // 获取子目号
+    const getBillCode = (node) => {
+      if (node.data.code) {
+        return node.data.code;
+      }
+      const parentFlag = node.parent ? node.parent.getFlag() : null;
+      if (parentFlag === fixedFlag.ONE_SEVEN_BILLS) {
+        return getBillSection(node);
+      }
+      return node.data.code;
+    }
+    function GongCLQDMX(node) {
+      const { mainFee, assFee } = getMaterialFee(node);
+      const billDataType = getBillDataType(node);
+      let unitFee = 0;
+      let totalFee = 0;
+      if (!isBidInvitation || billDataType === '21') {
+        unitFee = getFee(node.data.fees, 'common.tenderUnitFee');
+        totalFee = getFee(node.data.fees, 'common.tenderTotalFee');
+      }
+      const attrs = [
+        {name: '序号', value: billSeq ++ },
+        {name: 'GUID', value: node.data.GUID || node.data.ID },
+        {name: '清单章节', value: getBillSection(node), minLen: 1, enumeration: [
+          '100', '200', '300', '400', '500', '600', '700', '800', '900', '1000', '1100', 
+          '1200', '1300', '1400', '1500', '1600', '1700', '1800', '1900', '2000', 
+        ]},
+        {name: '子目长编号', value: divideObj.getExeBillCode(node.data.ID, node. tree)},
+        {name: '子目号', value: getBillCode(node), minLen: 1},
+        {name: '子目名称', value: node.data.name, minLen: 1},
+        {name: '单位', value: node.data.unit},
+        {name: '数量', value: node.data.quantity, type: TYPE.DECIMAL},
+        {name: '单价', value: unitFee, type: TYPE.DECIMAL},
+        {name: '合价', value: totalFee, type: TYPE.DECIMAL},
+        {name: '备注', value: node.data.remark },
+        {name: '数据类型', value: billDataType },
+        {name: '人工费', value: getUnitFee(getFee(node.data.fees, 'marketLabour.tenderTotalFee', exportKind), node.data.quantity, 2), type: TYPE.DECIMAL},
+        {name: '人工单价', value: getLabourPrice(), type: TYPE.DECIMAL},
+        {name: '人工消耗量', value: getLabourQuantity(node), type: TYPE.DECIMAL},
+        {name: '主材费', value: mainFee, type: TYPE.DECIMAL},
+        {name: '辅材费', value: assFee, type: TYPE.DECIMAL},
+        {name: '设备费', value: getUnitFee(getFee(node.data.fees, 'equipment.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
+        {name: '机械使用费', value:  getUnitFee(getFee(node.data.fees, 'machine.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
+        {name: '措施费1', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'measure1.tenderTotalFee', exportKind) : getFee(node.data.fees, 'otherDirect.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
+        {name: '措施费2', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'measure2.tenderTotalFee', exportKind) : getFee(node.data.fees, 'composite.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
+        {name: '企业管理费', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'manage.tenderTotalFee', exportKind) : getFee(node.data.fees, 'local.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
+        {name: '规费', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'force.tenderTotalFee', exportKind) : getFee(node.data.fees, 'indirect.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
+        {name: '利润', value: getUnitFee(getFee(node.data.fees, 'profit.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
+        {name: '税金', value: getUnitFee(getFee(node.data.fees, 'tax.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
+        {name: '评审清单', value: isNaN(+node.data.appraisalBills) ? 0 : +node.data.appraisalBills},
+      ];
+      Element.call(this, '工程量清单明细', attrs);
+    }
+
+    /* 清单主材表明细 */
+    let mainMaterialSeq = 1;
+    function QDZCBMX(material) {
+      const attrs = [
+        { name: '序号', value: mainMaterialSeq++, minLen: 1 },
+        { name: '材料编码', value: material.code, minLen: 1 },
+        { name: '主材名称', value: material.name, minLen: 1 },
+        { name: '单位', value: material.unit, minLen: 1 },
+        { name: '主材消耗量', value: material.quantity, type: TYPE.DECIMAL },
+        { name: '单价', value: material.unitPrice, type: TYPE.DECIMAL },
+        { name: '合价', value: material.totalPrice , type: TYPE.DECIMAL},
+        { name: '备注', value: material.remark },
+      ];
+      Element.call(this, '清单主材明细', attrs);
+    }
+
+    /* 定额信息表 */
+    let rationSeq = 1;
+    // 获取数据类型
+    const getRationDataType = (node) => {
+      const programText = curTender.calcProgram.compiledTemplateMaps[node.data.programID];
+      return programText === '费率为0' ? '4' : '3';
+    }
+    function DEXXB(node) {
+      const { mainFee, assFee } = getMaterialFee(node);
+      const attrs = [
+        {name: '序号', value: rationSeq ++ },
+        {name: 'GUID', value: node.data.GUID || node.data.ID },
+        {name: '定额编号', value: node.data.code},
+        {name: '定额名称', value: node.data.name, minLen: 1 },
+        {name: '单位', value: node.data.unit, minLen: 1 },
+        {name: '数量', value: node.data.tenderQuantity, type: TYPE.DECIMAL},
+        {name: '单价', value: getFee(node.data.fees, 'common.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
+        {name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee', exportKind), type: TYPE.DECIMAL},
+        {name: '备注', value: node.data.remark },
+        {name: '数据类型', value: getRationDataType(node) },
+        {name: '人工费', value: getUnitFee(getFee(node.data.fees, 'marketLabour.tenderTotalFee', exportKind), node.data.tenderQuantity, 2), type: TYPE.DECIMAL},
+        {name: '主材费', value: mainFee, type: TYPE.DECIMAL},
+        {name: '辅材费', value: assFee, type: TYPE.DECIMAL},
+        {name: '设备费', value: getUnitFee(getFee(node.data.fees, 'equipment.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
+        {name: '机械使用费', value:  getUnitFee(getFee(node.data.fees, 'machine.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
+        {name: '措施费1', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'measure1.tenderTotalFee', exportKind) : getFee(node.data.fees, 'otherDirect.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
+        {name: '措施费2', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'measure2.tenderTotalFee', exportKind) : getFee(node.data.fees, 'composite.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
+        {name: '企业管理费', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'manage.tenderTotalFee', exportKind) : getFee(node.data.fees, 'local.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
+        {name: '规费', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'force.tenderTotalFee', exportKind) : getFee(node.data.fees, 'indirect.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
+        {name: '利润', value: getUnitFee(getFee(node.data.fees, 'profit.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
+        {name: '税金', value: getUnitFee(getFee(node.data.fees, 'tax.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
+      ];
+      Element.call(this, '定额信息表', attrs);
+    }
+
+    /* 造价汇总明细 */
+    let hzSeq = 1;
+    // 获取章次
+    const getSection = (node) => {
+      const parentFlag = node.parent ? node.parent.getFlag() : null;
+      if (parentFlag !== fixedFlag.ONE_SEVEN_BILLS) {
+        return '';
+      }
+      return (node.data.name || '').replace(/[^0-9]/g, '')
+    }
+    let curLB = 7;
+    // 获取类别
+    const getLB = (node) => {
+      const flag = node.getFlag();
+      const parentFlag = node.parent ? node.parent.getFlag() : null;
+      if (parentFlag === fixedFlag.ONE_SEVEN_BILLS) {
+        return getSection(node);
+      }
+      switch (flag) {
+        case fixedFlag.ONE_SEVEN_BILLS:
+          return '1';
+        case fixedFlag.PROVISIONAL_TOTAL:
+          return '2';
+        case fixedFlag.BILLS_TOTAL_WT_PROV:
+          return '3';
+        case fixedFlag.DAYWORK_LABOR:
+          return '4';
+        case fixedFlag.PROVISIONAL:
+          return '5';
+        case fixedFlag.TOTAL_COST:
+          return '6';
+        default:
+          return curLB++;
+      }
+
+    }
+    function ZJHZMX(node) {
+      const attrs = [
+        {name: '序号', value: hzSeq++ },
+        {name: '章次', value: getSection(node) },
+        {name: '名称', value: node.data.name, minLen: 1 },
+        {name: '金额', value: getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL },
+        {name: '类别', value: getLB(node) },
+        {name: '备注', value: node.data.remark },
+
+      ];
+      Element.call(this, '造价汇总明细', attrs);
+    }
+    
+    /* 人材机汇总明细表 */
+    // 获取人材机类别
+    const getGljLB = (glj) => {
+      if (glj.type === 1) {
+        return '1';
+      }
+      if (!glj.is_main_material && isMaterial(glj.type) && ![202, 203, 204 ].includes(glj.type)) {
+        return '2';
+      }
+      if (isMachine(glj.type) && glj.type !== 301) {
+        return '3';
+      }
+      if (glj.type === 5) {
+        return '4';
+      }
+      if ([202, 203, 204].includes(glj.type)) {
+        return '5';
+      }
+      if (glj.type === 301) {
+        return '6';
+      }
+      if (glj.is_main_material && isMaterial(glj.type) && ![202, 203, 204 ].includes(glj.type)) {
+        return '7';
+      }
+      return '2';
+    }
+    function RCJHZMXB(glj) {
+      const attrs = [
+        {name: '人材机编号', value: glj.code, minLen: 1  },
+        {name: '人材机名称', value: glj.name, minLen: 1 },
+        {name: '规格型号', value: glj.specs },
+        {name: '单位', value: glj.unit, minLen: 1 },
+        {name: '数量', value: glj.tenderQuantity },
+        {name: '单价', value: glj.priceInfo.tenderPrice, type: TYPE.DECIMAL },
+        {name: '人材机类别', value: getGljLB(glj) },
+        {name: '是否主要材料', value: +glj.is_main_material },
+        {name: '是否甲供', value: 0 },
+        {name: '备注', value: glj.remark },
+  
+      ];
+      Element.call(this, '人材机汇总明细表', attrs);
+      
+    }
+
+    // 组装数据 ------------------------------------------------------------
+
+    /* 生成清单主材表 */
+    function createQDZCB(node) {
+      const qdzcb = new Element('清单主材表');
+
+      // 获取主材
+      const mainMaterials = [];
+      const materialMap = {};
+      node.children.forEach(ration => {
+        const materials = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && isMaterial(glj.type));
+        materials.forEach(material => {
+          const key = gljUtil.getIndex(material);
+          const projectGlj = curTender.projectGLJ.datas.gljMap[key];
+          if (projectGlj && projectGlj.is_main_material) {
+            if (!materialMap[key]) {
+              materialMap[key] = {
+                code: projectGlj.code,
+                name: projectGlj.name,
+                unit: projectGlj.unit,
+                quantity: +material.tenderQuantity,
+                unitPrice: getMarketPrice(projectGlj),
+                totalPrice: 0,
+                remark: projectGlj.remark,
+              };
+              mainMaterials.push(materialMap[key]);
+            } else {
+              materialMap[key].quantity = scMathUtil.roundForObj(materialMap[key].quantity + +material.tenderQuantity, qD);
+            }
+          }
+        });
+      });
+      mainMaterials.forEach(material => {
+        material.totalPrice = scMathUtil.roundForObj(material.quantity * material.unitPrice, fD);
+        qdzcb.children.push(new QDZCBMX(material));
+      });
+      return qdzcb.children.length ? qdzcb : null;
+    }
+
+    /* 生成定额信息表 */
+    function createDEXXB(node) {
+      const rst = [];
+      node.children.forEach(ration => {
+        const dexxb = new DEXXB(ration);
+        rst.push(dexxb);
+
+        // 生成定额人材机含量明细
+        const rGljData = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID);
+        rGljData.forEach(rGlj => {
+          const projectGlj = curTender.projectGLJ.datas.gljMap[gljUtil.getIndex(rGlj)];
+          if (!projectGlj) {
+            return;
+          }
+          const attrs = [
+            { name: '人材机编号', value: projectGlj.code },
+            { name: '人材机含量', value: rGlj.tenderQuantity, type: TYPE.DECIMAL },
+          ]
+          const dercjhlmx = new Element('定额人材机含量明细', attrs);
+          dexxb.children.push(dercjhlmx);
+        })
+      });
+      return rst;
+    }
+
+    /* 生成工程量清单表 */
+    function createGCLQD() {
+        // 设置工程量清单明细
+      function setupGCLQDMX(nodes) {
+        const rst = [];
+        nodes.forEach(node => {
+          const glcqdmx = new GongCLQDMX(node);
+          rst.push(glcqdmx);
+          if (!node.source.children.length && node.children.length) {
+            // 清单主材表
+            const qdzcb = createQDZCB(node);
+            if (qdzcb) {
+              glcqdmx.children.push(qdzcb);
+            }
+            // 定额
+            glcqdmx.children.push(...createDEXXB(node));
+          } else {
+            // 子清单
+            glcqdmx.children.push(...setupGCLQDMX(node.children));
+          }
+        });
+        return rst;
+      }
+
+      const gclqd = new Element('工程量清单表');
+      // 工程量清单明细为固定清单(第100章至700章清单)下所有清单
+      const fixedNode = getNodeByFlag(curTender.mainTree, fixedFlag.ONE_SEVEN_BILLS)
+      gclqd.children.push(...setupGCLQDMX(fixedNode.children));
+
+
+      return gclqd;
+    }
+
+    /* 生成计日工信息表 */
+    let jrgSeq = 1;
+    // 获取数据类型
+    const getJRGDataType = (node) => {
+      const flag = node.getFlag();
+      const parentFlag = node.parent ? node.parent.getFlag() : null;
+      if (flag === fixedFlag.DAYWORK_LABOR) {
+        return '0';
+      }
+      if (flag === fixedFlag.LABOUR_SERVICE) {
+        return '1';
+      }
+      if (flag === fixedFlag.MATERIAL) {
+        return '2';
+      }
+      if (flag === fixedFlag.CONSTRUCTION_MACHINE) {
+        return '3';
+      }
+      if (parentFlag === fixedFlag.LABOUR_SERVICE) {
+        return '4';
+      }
+      if (parentFlag === fixedFlag.MATERIAL) {
+        return '5';
+      }
+      if (parentFlag === fixedFlag.CONSTRUCTION_MACHINE) {
+        return '6';
+      }
+    }
+    function createJRGXXB() {
+      const jrgxxb = new Element('计日工信息表');
+      const fixedNode = getNodeByFlag(curTender.mainTree, fixedFlag.DAYWORK_LABOR);
+      function createJRG(node) {
+        // 计日工信息标题
+        const jrgxxbt = new Element('计日工信息标题', [
+          { name: '序号', value: jrgSeq++ },
+          { name: '名称', value: node.data.name },
+          { name: '数据类型', value: getJRGDataType(node) },
+          { name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL},
+        ]);
+        if (node === fixedNode) {
+          return jrgxxbt;
+        }
+        jrgxxbt.children = node.children.map(child => new Element('计日工信息明细', [
+            { name: '编号', value: child.data.code, minLen: 1 },
+            { name: '名称', value: child.data.name, minLen: 1 },
+            { name: '数据类型', value: getJRGDataType(child) },
+            { name: '单位', value: child.data.unit, minLen: 1 },
+            { name: '暂定数量', value: child.data.quantity, type: TYPE.DECIMAL },
+            { name: '单价', value: getFee(child.data.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL },
+            { name: '合价', value: getFee(child.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL },
+          ]));
+        return jrgxxbt;
+      }
+      jrgxxb.children = [fixedNode, ...fixedNode.children].map(node => createJRG(node));
+      return jrgxxb;
+    }
+
+    /* 生成造价汇总表 */
+    function createZJHZB() {
+      const zjhzb = new Element('造价汇总表');
+      // 提取需要显示的数据
+      const nodes = [];
+      curTender.mainTree.roots.forEach(node => {
+        nodes.push(node);
+        if (node.getFlag() === fixedFlag.ONE_SEVEN_BILLS) {
+          nodes.push(...node.children);
+        }
+      });
+      zjhzb.children = nodes.map(node => new ZJHZMX(node));
+      return zjhzb;
+    }
+
+    /* 生成人材机汇总 */
+    function createRCJHZ() {
+      const rcjhz = new Element('人材机汇总');
+      rcjhz.children = curTender.projectGLJ.datas.gljList.map(glj => new RCJHZMXB(glj));
+      return rcjhz;
+    }
+
+    /* 生成标段工程 */
+    function createGLBDGC(rawTender, seq){
+      // 标段属性
+      const tenderAttrs = [
+          { name: '序号', value: seq, minLen: 1 },
+          { name: '标段名称', value: rawTender.name, minLen: 1 },
+          { name: '金额', value: isBidInvitation ? 0 : projectData.summaryInfo[rawTender.ID].totalCost },
+          { name: '唯一标识-Guid', value: rawTender.GUID }
+      ];
+      const gongLBDGC = new Element('公路标段工程', tenderAttrs)
+      // 工程量清单表
+      const gclqd = createGCLQD();
+      // 计日工信息表
+      const jrgxxb = createJRGXXB();
+      // 造价汇总表
+      const zjhzb = createZJHZB();
+      // 人材机汇总
+      const rcjhz = createRCJHZ();
+      gongLBDGC.children = [gclqd, jrgxxb, zjhzb, rcjhz];
+
+
+      // 公路工程汇总明细属性
+      const hzAttrs = [
+        ...tenderAttrs,
+        { name: '备注', value: '' }
+      ];
+
+      return {
+        gongLBDGC,
+        hzAttrs,
+      }
+    }
+
+    /* 组装建设项目数据 */
+    function setupConstruction() {
+      const rootNode = new Element('浙江公路工程');
+      const gongCXX = new GongCXX();
+      const zhaoTBXX = new Element('招投标信息');
+      const gongLGCSJ = new Element('公路工程数据');
+      rootNode.children = [gongCXX, zhaoTBXX, gongLGCSJ];
+
+      if (isBidInvitation) {
+        zhaoTBXX.children.push(new ZhaoBiaoXX());
+      } else if (isControl) {
+        zhaoTBXX.children.push(new ZhaoBiaoKZJ());
+      } else {
+        zhaoTBXX.children.push(new TouBiaoXX());
+      }
+
+      const gongLGCHZ = new Element('公路工程汇总');
+      const gongLGCHZBT = new Element('公路工程汇总标题');
+      gongLGCHZ.children.push(gongLGCHZBT);
+
+      // 组装标段数据
+      projectData.children.forEach((tender, index) => {
+        billSeq = 1;
+        mainMaterialSeq = 1;
+        rationSeq = 1;
+        jrgSeq = 1;
+        hzSeq = 1;
+        debugger;
+        curTender = tenderDetailMap[tender.ID];
+        const {
+          gongLBDGC,
+          hzAttrs,
+        } = createGLBDGC(tender, index + 1);
+        gongLGCSJ.children.push(gongLBDGC);
+        const gongLGCHZMX = new Element('公路工程汇总明细', hzAttrs);
+        gongLGCHZBT.children.push(gongLGCHZMX);
+      });
+      gongLGCSJ.children.push(gongLGCHZ);
+
+
+      const suffix = INTERFACE_CONFIG[areaKey]['fileSuffix'][exportKind];
+      return [{
+        data: rootNode,
+        exportKind,
+        fileName: `${projectData.name}${suffix}`
+    }];
+    }
+
+    return setupConstruction(projectData);
+  
+  }
+
+  return {
+    entry,
+  };
+})();

+ 21 - 7
web/building_saas/standard_interface/import/base.js

@@ -371,7 +371,7 @@ const INTERFACE_EXPORT_BASE = (() => {
   }
 
   // 处理单位工程数据
-  function handleTenderData(tenders, templateData) {
+  function handleTenderData(tenders, templateData, rationValuationData, engineeringLib) {
     tenders.forEach((tender, index) => {
       tender.compilation = compilationData._id;
       tender.userID = userID;
@@ -380,9 +380,6 @@ const INTERFACE_EXPORT_BASE = (() => {
       tender.NextSiblingID = index === tenders.length - 1 ? -1 : templateData.projectBeginID + index + 2;
       tender.projType = projectType.tender;
       const featureTarget = _.cloneDeep(templateData.feature); // 必须拷贝出一份新数据,否则会被下一个单位工程覆盖
-      const rationValuationData = JSON.parse(rationValuation)[0];
-      const engineeringList = rationValuationData.engineering_list;
-      const engineeringLib = engineeringList.find(item => item.lib.visible);
       if (!engineeringLib) {
         throw '不存在可用工程专业。';
       }
@@ -392,6 +389,10 @@ const INTERFACE_EXPORT_BASE = (() => {
         { key: 'valuationType', value: '工程量清单' }, // 导入的时候以下项不一定有数据,但是需要自动生成
         { key: 'feeStandard', value: engineeringLib.lib.feeName },
       ];
+      const needEngineering = featureTarget && featureTarget.find(item => item.key === 'engineering');
+      if (needEngineering) {
+        featureSource.push({ key: 'engineering', value: engineeringLib.lib.name });
+      }
       tender.property = {
         rootProjectID: tender.ParentID,
         region: '全省',
@@ -444,8 +445,21 @@ const INTERFACE_EXPORT_BASE = (() => {
       throw '导入的文件中不存在有效的标段数据。';
     }
     const projectCount = 1 + importData.tenders.length;
-    const feeName = compilationData.name === '安徽养护(2018)' ? '安徽养护' : '公路工程';
-    const templateData = await ajaxPost('/pm/api/getImportTemplateData', { user_id: userID, valuationID, feeName, projectCount });
+    // const feeName = compilationData.name === '安徽养护(2018)' ? '安徽养护' : '公路工程';
+    // 一些接口需要根据导入文件,匹配工程专业库
+    const rationValuationData = rationValuation && JSON.parse(rationValuation)[0]; // 只有工程量清单才能导入接口
+    if (!rationValuationData) {
+      throw '无法获取工程量清单计价数据';
+    }
+    const engineeringList = (rationValuationData.engineering_list || []).filter(item => item.lib.visible);
+    let engineeringLib = engineeringList[0];
+    if (importData.engineeringName && importData.feeName) {
+      const matchLibs = engineeringList.filter(item => item.lib && item.lib.name === importData.engineeringName);
+      engineeringLib = matchLibs.find(item => item.lib.feeName === importData.feeName) || matchLibs[0] || engineeringList[0];
+    }
+    const engineeringID = engineeringLib.engineering_id || null;
+
+    const templateData = await ajaxPost('/pm/api/getImportTemplateData', { user_id: userID, valuationID, engineeringID, projectCount });
     if (!templateData) {
       throw '无法获取有效模板数据。';
     }
@@ -472,7 +486,7 @@ const INTERFACE_EXPORT_BASE = (() => {
     };
     delete importData.info;
     // 处理单位工程数据
-    handleTenderData(importData.tenders, templateData);
+    handleTenderData(importData.tenders, templateData, rationValuationData, engineeringLib);
     console.log(importData);
   }
 

+ 188 - 0
web/building_saas/standard_interface/import/zhejiang_ninghai.js

@@ -0,0 +1,188 @@
+// 浙江宁海导入接口
+// 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];
+
+    const natureConstructionMap = {
+      '1': '新建',
+      '2': '改扩建',
+      '3': '养护',
+      '4': '养护(年度经费)',
+    };
+    const roadGradeMap = {
+      '1': '高速公路',
+      '2': '一级公路',
+      '3': '二级公路',
+      '4': '三级公路',
+      '5': '四级公路',
+      '6': '桥梁工程',
+      '7': '隧道工程',
+      '8': '其他工程',
+    };
+    const taxModeMap = {
+      '1': '一般计税',
+      '2': '简易计税',
+    };
+
+    // 工程专业
+    let engineeringName = '小修保养、大中修';
+    // 费用标准
+    let feeName = '高速公路';
+
+    // 提取基本信息,xml中提取出来的基本信息,最终会与模板基本信息进行合并处理。(接口内不需要处理合并)
+    function setupInformation(projectSrc) {
+      const gcxx = getValue(projectSrc, ['工程信息']);
+      const ztbxx = getValue(projectSrc, ['招投标信息', '招标控制价']) || getValue(projectSrc, ['招投标信息', '投标信息']) || getValue(projectSrc, ['招投标信息', '招标信息']);
+      // key:基本信息模板中的key,作为合并时的匹配字段
+      const natureConstruction = natureConstructionMap[getValue(gcxx, ['_项目类型'])] || '';
+      if (natureConstruction === '养护(年度经费)') {
+        engineeringName = '小修保养年度经费';
+      }
+      const roadGrade = roadGradeMap[getValue(gcxx, ['_专业划分'])] || '';
+      feeName = roadGrade;
+      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: natureConstruction },
+        { key: 'roadGrade', value: roadGrade },
+        { key: 'roadDistance', value: getValue(gcxx, ['_道路里程-公里']) },
+        { key: 'designUnit', value: getValue(gcxx, ['_设计单位']) },
+        { key: 'taxMode', value: taxModeMap[getValue(gcxx, ['_计税方式'])] },
+        { key: 'tendereeName', value: getValue(ztbxx, ['_招标人']) },
+        { key: 'tenderAuthorizer', value: getValue(ztbxx, ['_招标法定代表人或其授权人']) },
+        { key: 'compileApprover', value: getValue(ztbxx, ['_编制人']) },
+        { key: 'compileCertNo', value: getValue(ztbxx, ['_编制人资格证号']) },
+        { key: 'compileDate', value: getValue(ztbxx, ['_编制日期']) },
+        { key: 'proxy', value: getValue(ztbxx, ['_招标代理机构']) },
+        { key: 'scopeofBidding', value: getValue(ztbxx, ['_招标范围']) },
+        { key: 'timeLimit', value: getValue(ztbxx, ['_总工期日历天']) },
+        { key: 'compileDate', value: getValue(ztbxx, ['_编制日期']) },
+        { key: 'preparationDescription', value: getValue(ztbxx, ['_编制说明']) },
+        { key: 'reviewApprover', value: getValue(ztbxx, ['_复核人']) },
+        { key: 'reviewCertNo', value: getValue(ztbxx, ['_复核人资格证号']) },
+        { key: 'reviewDate', value: getValue(ztbxx, ['_复核日期']) },
+        { key: 'examineApprover', value: getValue(ztbxx, ['_审核人']) },
+        { key: 'examineCertNo', value: getValue(ztbxx, ['_审核人资格证号']) },
+        { key: 'examineDate', value: getValue(ztbxx, ['_审核日期']) },
+        { key: 'bidderName', value: getValue(ztbxx, ['_投标人']) },
+        { key: 'bidderAuthorizer', value: getValue(ztbxx, ['_投标人法人或其授权人']) },
+        { key: 'bidderCertNo', value: getValue(ztbxx, ['_投标人资质证号']) },
+        { key: 'downwardFloatingRateOfBid', value: getValue(ztbxx, ['_投标下浮率']) },
+        { key: 'descriptionOfTenderOffer', value: getValue(ztbxx, ['_投标报价说明']) },
+        { key: 'qualityCommitment', value: getValue(ztbxx, ['_质量承诺']) },
+        { key: 'bidBond', value: getValue(ztbxx, ['_投标保证金']) },
+        { key: 'projectManagers', value: getValue(ztbxx, ['_项目经理或项目负责人']) },
+        { key: 'projectmanagersCertNo', value: getValue(ztbxx, ['_项目经理或项目负责人资格证号']) },
+      ];
+      return info;
+    }
+
+    // 提取清单数据
+    function setupBills(rootSrc, oneSevenSrc, dayWorkSrc) {
+      // 章次为空的造价汇总表数据,为大项费用数据
+      const roots = arrayValue(rootSrc, ['造价汇总明细'])
+        .filter(item => !getValue(item, ['_章次']))
+        .map(item => ({
+          name: getValue(item, ['_名称']),
+          remark: getValue(item, ['_备注']),
+          titleType: getValue(item, ['_类别'])
+        }));
+      let oneSevenBills;
+      let dayWorkBills;
+      roots.forEach(item => {
+        const simpleName = item.name ? item.name.replace(/\s/g, '') : '';
+        if (item.titleType === '1' || /100章至第700章|100章至700章/.test(simpleName)) {
+          oneSevenBills = item;
+        } else if (/计日工合计/.test(simpleName)) {
+          dayWorkBills = item;
+        }
+      });
+      // 第100-700章的数据
+      if (oneSevenBills) {
+        oneSevenBills.children = extractItemsRecur(oneSevenSrc, [['工程量清单明细']], (src) => ({
+          GUID: getValue(src, ['_GUID']),
+          sectionCode: getValue(src, ['_清单章节号']),
+          code: getValue(src, ['_子目号']),
+          name: getValue(src, ['_子目名称']),
+          unit: getValue(src, ['_单位']),
+          quantity: getValue(src, ['_数量']),
+          remark: getValue(src, ['_备注']),
+          appraisalBills: +getValue(src, ['_评审清单']),
+          specialProvisional: getValue(src, ['_数据类型']) === '21' ? '专业工程' : ''
+        }));
+      }
+      // 计日工数据
+      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, ['_标段名称']),
+        GUID: getValue(tenderSrc, ['_唯一标识-Guid']),
+        bills: setupBills(rootSrc, oneSevenSrc, dayWorkSrc)
+      };
+    }
+
+    // 从xml对象提取需要的数据
+    function setupProject(projectSrc) {
+      const tenders = arrayValue(projectSrc, ['公路工程数据', '公路标段工程'])
+        .map(tenderSrc => setupTender(tenderSrc));
+      return {
+        name: getValue(projectSrc, ['工程信息', '_项目名称']),
+        GUID: getValue(projectSrc, ['工程信息', '_GUID']),
+        info: setupInformation(projectSrc),
+        tenders,
+        engineeringName,
+        feeName,
+      };
+    }
+    return setupProject(getValue(xmlObj, ['浙江公路工程']));
+  }
+
+  return {
+    entry
+  };
+
+})();

+ 2 - 1
web/building_saas/standard_interface/index.js

@@ -42,7 +42,8 @@ const STD_INTERFACE = (() => {
     connectedAreas.forEach(connectedArea => {
       const areas = connectedArea.split('@');
       if ((COMPILATION_NAME === '安徽养护(2018)' && areas[0] !== '安徽') ||
-        (COMPILATION_NAME === '广东公路造价(2018)' && areas[0] !== '广东')) {
+        (COMPILATION_NAME === '广东公路造价(2018)' && areas[0] !== '广东') ||
+        (COMPILATION_NAME === '浙江养护(2005)' && areas[0] !== '浙江')) {
         return;
       }
       (parentMap[areas[0]] || (parentMap[areas[0]] = [])).push(areas[1]);