浏览代码

fix: 项目汇总接口,建设项目的金额取建设项目总概算的金额而非工程费用金额

vian 4 年之前
父节点
当前提交
f8e1ab7973
共有 2 个文件被更改,包括 12 次插入5 次删除
  1. 11 4
      modules/main/facade/bill_facade.js
  2. 1 1
      web/building_saas/pm/js/pm_newMain.js

+ 11 - 4
modules/main/facade/bill_facade.js

@@ -20,7 +20,7 @@ let bill_Model = require('../models/bills').model;
 let billsLibDao = require("../../bills_lib/models/bills_lib_interfaces");
 const pmFacade = require('../../pm/facade/pm_facade');
 const { getSortedTreeData, getEngineeringFeeType } = require('../../../public/common_util');
-const { billType, constructionFeeNodeID, constructionEquipmentFeeNodeID, BudgetArea, fixedFlag } = require('../../../public/common_constants');
+const { billType, constructionFeeNodeID, constructionEquipmentFeeNodeID, BudgetArea, fixedFlag, BudgetType } = require('../../../public/common_constants');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const uuidV1 = require('uuid/v1');
 const equipmentFacade = require('../../equipment_purchase/facade/equipment_purchase_facade');
@@ -149,10 +149,12 @@ module.exports={
     // 获取概算汇总初始化数据
     initialBudgetSummary: async function (constructionID) {
         const treeData = await this.getBudgetSummary(constructionID);
-        const construction = await projectModel.findOne({ ID: constructionID }, { 'property.costGrowthRate': 1, 'property.growthPeriod': 1 }).lean();
+        const construction = await projectModel.findOne({ ID: constructionID }, { 'property.costGrowthRate': 1, 'property.growthPeriod': 1, 'property.budgetType': 1 }).lean();
         const costGrowthRate = construction && construction.property && construction.property.costGrowthRate || 0;
         const growthPeriod = construction && construction.property && construction.property.growthPeriod || 0;
+        const budgetType = construction && construction.property && construction.property.budgetType || BudgetType.BUILDING;
         return {
+            budgetType,
             treeData,
             costGrowthRate,
             growthPeriod,
@@ -164,13 +166,18 @@ module.exports={
         const task = [];
         for (const constructionID of constructionIDs) {
             task.push(this.getBudgetSummary(constructionID, true));
-            
         }
         const summaryResult = await Promise.all(task);
         summaryResult.forEach(items => {
+            const constructionBudget = items.find(item => item.flags && item.flags[0] && item.flags[0].flag === fixedFlag.CONSTRUCTION_BUDGET);
             items.forEach(item => {
                 if (item.orgProjectID) {
                     map[item.orgProjectID] = item;
+                    if (item.projType === 'Project' && constructionBudget) {
+                        // 建设项目的总价需要取建设项目总概算
+                        map[item.orgProjectID].totalFee = constructionBudget.totalFee;
+                        map[item.orgProjectID].fees = constructionBudget.fees;
+                    }
                 }
             });
         });
@@ -223,7 +230,7 @@ module.exports={
     },
     // 获取工程费用数据,作为概算汇总数据的拼接树数据
     getConstructionFeeData: async function (constructionID, nextID) {
-        const projects = await pmFacade.getPosterityProjects([constructionID], true, { _id: 0, ID: 1, ParentID: 1, NextSiblingID: 1, name: 1, projType: 1, 'property.engineeringName': 1});
+        const projects = await pmFacade.getPosterityProjects([constructionID], true, { _id: 0, ID: 1, ParentID: 1, NextSiblingID: 1, name: 1, projType: 1, chapterCode: 1, sectionCode: 1, 'property.engineeringName': 1});
         const construction = projects.find(p => p.ID === constructionID);
         const items = getSortedTreeData(construction.ParentID, projects);
         // 转换为uuid

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

@@ -3047,7 +3047,7 @@ function initProjects(callback, expandCallback) {
             sheet.frozenColumnCount(2);
             sheet.name('projectSheet');
             sheetCommonObj.spreadDefaultStyle(projTreeObj.workBook);
-            projTreeObj.sumEngineeringCost();
+            //projTreeObj.sumEngineeringCost();
             if (expandCallback) {
                 expandCallback();
             } else {