|
@@ -19,7 +19,7 @@ let ration_template_Model = mongoose.model('ration_template');
|
|
let bill_Model = require('../models/bills').model;
|
|
let bill_Model = require('../models/bills').model;
|
|
let billsLibDao = require("../../bills_lib/models/bills_lib_interfaces");
|
|
let billsLibDao = require("../../bills_lib/models/bills_lib_interfaces");
|
|
const pmFacade = require('../../pm/facade/pm_facade');
|
|
const pmFacade = require('../../pm/facade/pm_facade');
|
|
-const { getSortedTreeData, getEngineeringFeeType } = require('../../../public/common_util');
|
|
|
|
|
|
+const { getSortedTreeData, getSortedSeqTreeData, getEngineeringFeeType } = require('../../../public/common_util');
|
|
const { billType, constructionFeeNodeID, constructionEquipmentFeeNodeID, BudgetArea, fixedFlag, BudgetType } = require('../../../public/common_constants');
|
|
const { billType, constructionFeeNodeID, constructionEquipmentFeeNodeID, BudgetArea, fixedFlag, BudgetType } = require('../../../public/common_constants');
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
const uuidV1 = require('uuid/v1');
|
|
const uuidV1 = require('uuid/v1');
|
|
@@ -183,20 +183,58 @@ module.exports={
|
|
});
|
|
});
|
|
return map;
|
|
return map;
|
|
},
|
|
},
|
|
- // 获取概算汇总单项工程级别数据(拍好序的,报表接口用)
|
|
|
|
|
|
+ // 获取单位工程分部数据(按树结构排好序的)
|
|
|
|
+ getFBData: async function (unitID) {
|
|
|
|
+ const bills = await bill_Model.find({ projectID: unitID }).lean();
|
|
|
|
+ const sortedData = getSortedTreeData('-1', bills);
|
|
|
|
+ return sortedData.filter(item => item.type === billType.FB);
|
|
|
|
+ },
|
|
|
|
+ // 获取概算汇总单项工程级别数据(排好序的,报表接口用)
|
|
getSinglesBudgetSummary: async function (constructionID) {
|
|
getSinglesBudgetSummary: async function (constructionID) {
|
|
const items = await this.getBudgetSummary(constructionID, true);
|
|
const items = await this.getBudgetSummary(constructionID, true);
|
|
// 去除建设项目层级
|
|
// 去除建设项目层级
|
|
items.shift();
|
|
items.shift();
|
|
- items.forEach(item => {
|
|
|
|
|
|
+ const [budgetTotalItem] = items.splice(items.length - 1, 1);
|
|
|
|
+ const budgetTotalFeeItem = budgetTotalItem.fees && budgetTotalItem.fees.find(f => f.fieldName === 'common');
|
|
|
|
+ const budgetTotalFee = budgetTotalFeeItem ? +budgetTotalFeeItem.totalFee : 0;
|
|
|
|
+ const rst = [];
|
|
|
|
+ for (const project of items) {
|
|
|
|
+ rst.push(project);
|
|
// 方便报表取值处理
|
|
// 方便报表取值处理
|
|
- if (item.projType === 'Engineering') {
|
|
|
|
- item.engineeringName = item.name || '';
|
|
|
|
- } else if (item.projType === 'Tender') {
|
|
|
|
- item.tenderName = item.name || '';
|
|
|
|
|
|
+ if (project.projType === 'Engineering') {
|
|
|
|
+ project.engineeringName = project.name || '';
|
|
|
|
+ } else if (project.projType === 'Tender') {
|
|
|
|
+ project.tenderName = project.name || '';
|
|
|
|
+ // 追加分部和设备购置数据
|
|
|
|
+ const feeType = getEngineeringFeeType(project.property && project.property.engineeringName || '');
|
|
|
|
+ const fbs = await this.getFBData(project.orgProjectID);
|
|
|
|
+ const equipments = await equipmentFacade.getSortedEquipmentData(project.orgProjectID);
|
|
|
|
+ const detailData = [...fbs, ...equipments].map(item => {
|
|
|
|
+ let totalFee = 0;
|
|
|
|
+ if (item.feeType === 'equipment') {
|
|
|
|
+ totalFee = item.totalPrice || 0;
|
|
|
|
+ } else {
|
|
|
|
+ const totalFeeItem = item.fees && item.fees.find(f => f.fieldName === 'common');
|
|
|
|
+ totalFee = totalFeeItem ? +totalFeeItem.totalFee : 0;
|
|
|
|
+ }
|
|
|
|
+ // 计算占总投资比例
|
|
|
|
+ const rate = (budgetTotalFee ? scMathUtil.roundForObj(totalFee / budgetTotalFee, 4) : 0) * 100;
|
|
|
|
+ return {
|
|
|
|
+ code: item.code || '',
|
|
|
|
+ name: item.name || '',
|
|
|
|
+ buildingFee: item.feeType !== 'equipment' && feeType === 'building' ? totalFee : 0,
|
|
|
|
+ installationFee: item.feeType !== 'equipment' && feeType === 'installation' ? totalFee : 0,
|
|
|
|
+ equipmentFee: item.feeType === 'equipment' ? totalFee : 0,
|
|
|
|
+ otherFee: 0,
|
|
|
|
+ totalFee,
|
|
|
|
+ rate,
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ rst.push(...detailData);
|
|
|
|
+
|
|
}
|
|
}
|
|
- });
|
|
|
|
- return items;
|
|
|
|
|
|
+ }
|
|
|
|
+ return rst;
|
|
},
|
|
},
|
|
|
|
|
|
// 获取概算汇总数据(拍好序的)
|
|
// 获取概算汇总数据(拍好序的)
|