Просмотр исходного кода

Merge branch '1.0.0_online' of http://192.168.1.41:3000/SmartCost/ConstructionCost into 1.0.0_online

chenshilong 6 лет назад
Родитель
Сommit
8bd4fafe82
2 измененных файлов с 31 добавлено и 15 удалено
  1. 21 7
      modules/pm/facade/pm_facade.js
  2. 10 8
      test/unit/reports/test_summary.js

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

@@ -666,7 +666,9 @@ function getBuildingArea(projFeature){
 async function getSummaryInfoByTender(tenderID, summaryType) {
     const notDeleted = [{deleteInfo: null}, {'deleteInfo.deleted': false}];
     let tender = await projectModel.findOne({ID: tenderID, $or: notDeleted});
-    let parentName;
+    let parent,
+        parentName,
+        compilationIllustration;
     let summaryList = [];
     if(!tender){
         return null;
@@ -680,8 +682,8 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
         return null;
     }
     let summaryInfo = await getSummaryInfo([project.ID]);
-    if(summaryType === projectType.engineering){
-        parentName = engineering.name ? engineering.name : '';
+    if(summaryType === projectType.engineering){ // 汇总到单项工程级别
+        parent = engineering;
         let tenders = await projectModel.find({ParentID: engineering.ID, $or: notDeleted});
         for(let t of tenders){
             if(summaryInfo[t.ID]){
@@ -689,9 +691,8 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
                 summaryList.push(summaryInfo[t.ID]);
             }
         }
-    }
-    else {
-        parentName = project.name ? project.name : '';
+    } else { // 汇总到建设项目级别
+        parent = project;
         let engs = await projectModel.find({ParentID: project.ID, $or: notDeleted});
         for(let e of engs){
             if(summaryInfo[e.ID]){
@@ -700,7 +701,20 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
             }
         }
     }
-    return {parent: {name: parentName}, subList: summaryList};
+    // 项目名称
+    parentName = parent && parent.name
+                    ? parent.name
+                    : '';
+    // 编制说明
+    compilationIllustration = parent && parent.property && parent.property.compilationIllustration
+                                ? parent.property.compilationIllustration
+                                : '';
+    return {
+        parent: {
+            name: parentName,
+            compilationIllustration: compilationIllustration},
+        subList: summaryList
+    };
 }
 
 //获取单位工程的各标段费用信息(不进行汇总)

+ 10 - 8
test/unit/reports/test_summary.js

@@ -36,7 +36,8 @@ let demoPrjId = - 1;
 // let demoRptId = 261; //封3
 // let demoRptId = 232; //09
 // let demoRptId = 280; //11-1 暂列金
-let demoRptId = 551; //表05
+// let demoRptId = 551; //表05
+let demoRptId = 910; //表01
 // let demoRptId = 2260; //测试基本信息
 let pagesize = "A4";
 //288: 11-2表(新)
@@ -47,7 +48,8 @@ let userId_Leng = "5acac1e885bf55000bd055ba"; //小冷User Id2
 // demoPrjId = 720; //QA: DW3
 //demoPrjId = 1626; //QA:
 // demoPrjId = 2260; //QA:
-demoPrjId = 4552; //QA:
+// demoPrjId = 4552; //QA:
+demoPrjId = 6601; //prod:
 //*/
 let userId_Dft = userId_Leng;
 // let userId_Dft = "5a025c4c15074d134c2b9689";
@@ -70,15 +72,15 @@ fs.readFile(__dirname.slice(0, __dirname.length - 18) + '/public/web/date_util.j
 
 test('测试 - 汇总数据: ', function (t) {
     let s1 = pm_facade.getSummaryInfoByTender(demoPrjId, pm_facade.projectType.engineering);
-    let s2 = pm_facade.getSummaryInfoByTender(demoPrjId, pm_facade.projectType.project);
+    // let s2 = pm_facade.getSummaryInfoByTender(demoPrjId, pm_facade.projectType.project);
     s1.then(function (rst1) {
         console.log(rst1);
     });
-    s2.then(function (rst2) {
-        console.log(rst2);
-        t.pass('pass ok!');
-        t.end();
-    });
+    // s2.then(function (rst2) {
+    //     console.log(rst2);
+    //     t.pass('pass ok!');
+    //     t.end();
+    // });
 });
 
 test('close the connection', function (t) {