Browse Source

feat: 重庆导入接口,支持导入无单项工程结构数据

vian 4 years ago
parent
commit
aaa7cc5094
2 changed files with 21 additions and 2 deletions
  1. 1 0
      modules/all_models/projects.js
  2. 20 2
      web/over_write/js/chongqing_2018_import.js

+ 1 - 0
modules/all_models/projects.js

@@ -14,6 +14,7 @@ const shareSchema = new Schema({
     shareDate: String,
 }, {versionKey: false, _id: false});
 const ProjectSchema = new Schema({
+    "isTwoLevel": { type: Boolean, default: false },
     "ID": {type: Number, index: true},
     "ParentID": Number,
     "NextSiblingID": Number,

+ 20 - 2
web/over_write/js/chongqing_2018_import.js

@@ -113,6 +113,9 @@ const importXML = (() => {
             count += eng.tenders.length;
         });
         obj.projectCount = count;
+        if (source.isTwoLevel) {
+            obj.isTwoLevel = true;
+        }
         return obj;
     }
     //基本信息相关
@@ -165,6 +168,20 @@ const importXML = (() => {
     }
     //单项工程
     function loadEng(source) {
+        const engs = arrayValue(source, ['标段', '单项工程']);
+        // 支持导入无单项工程数据,如果只有没有单项工程,自动生成一个单项工程数据
+        if (!engs.length) {
+            countData.projectCount++;
+            const eng = {
+                code: '1',
+                name: '单项工程',
+                projType: 'Engineering',
+                tenders: loadTender(source, ['标段', '单位工程']),
+            }
+            // 标记为两层结构,导出需要用到(虽然自动生成了三层,但是导出的时候需要只导出两层)
+            source.isTwoLevel = true;
+            return [eng];
+        }
         return arrayValue(source, ['标段', '单项工程']).map(src => {
             countData.projectCount++;
             return {
@@ -176,8 +193,8 @@ const importXML = (() => {
         });
     }
     //单位工程
-    function loadTender(engSrc) {
-        return arrayValue(engSrc, ['单位工程']).map(src => {
+    function loadTender(engSrc, path = ['单位工程']) {
+        return arrayValue(engSrc, path).map(src => {
             countData.projectCount++;
             countData.unitPriceFileCount++;
             return {
@@ -1621,6 +1638,7 @@ const importXML = (() => {
         xmlObj.ID = IDPlaceholder.project++;
         //获取到的转换后的最终上传数据
         let postConstructData = {
+            isTwoLevel: !!xmlObj.isTwoLevel,
             ID: xmlObj.ID,
             ParentID: xmlObj.ParentID,
             NextSiblingID: xmlObj.NextSiblingID,