|  | @@ -38,7 +38,8 @@ const projectType = {
 | 
	
		
			
				|  |  |  module.exports={
 | 
	
		
			
				|  |  |      moveProject:moveProject,
 | 
	
		
			
				|  |  |      copyProject:copyProject,
 | 
	
		
			
				|  |  | -    getSummaryInfo: getSummaryInfo
 | 
	
		
			
				|  |  | +    getSummaryInfo: getSummaryInfo,
 | 
	
		
			
				|  |  | +    getConstructionProject: getConstructionProject
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  async function copyProject(userID, compilationID,data) {
 | 
	
	
		
			
				|  | @@ -512,10 +513,27 @@ async function getSummaryInfo(projectIDs){
 | 
	
		
			
				|  |  |      flagFieldMapping[billsFlags.OTHER] = 'other';
 | 
	
		
			
				|  |  |      flagFieldMapping[billsFlags.CHARGE] = 'charge';
 | 
	
		
			
				|  |  |      flagFieldMapping[billsFlags.TAX] = 'tax';
 | 
	
		
			
				|  |  | -    for(let projectID of projectIDs){
 | 
	
		
			
				|  |  | +   /* for(let projectID of projectIDs){
 | 
	
		
			
				|  |  |          IDMapping[projectID] = {engineeringCost: 0, subEngineering: 0, measure: 0, safetyConstruction: 0, other: 0, charge: 0, tax: 0, rate: 0, buildingArea: '', perCost: ''};
 | 
	
		
			
				|  |  | +    }*/
 | 
	
		
			
				|  |  | +    let projects = await projectModel.find({ID: {$in : projectIDs}, projType: projectType.project, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]});
 | 
	
		
			
				|  |  | +    //设置建设项目的总建筑面积
 | 
	
		
			
				|  |  | +    for(let project of projects){
 | 
	
		
			
				|  |  | +        let grossArea = '';
 | 
	
		
			
				|  |  | +        if(project.property && project.property.basicInformation){
 | 
	
		
			
				|  |  | +            for(let basicInfo of project.property.basicInformation){
 | 
	
		
			
				|  |  | +                if(basicInfo.key === 'basicInfo'){
 | 
	
		
			
				|  |  | +                    for(let k of basicInfo.items){
 | 
	
		
			
				|  |  | +                        if(k.key === 'grossArea'){
 | 
	
		
			
				|  |  | +                            grossArea = k.value;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        IDMapping[project.ID] = {engineeringCost: 0, subEngineering: 0, measure: 0, safetyConstruction: 0, other: 0, charge: 0, tax: 0, rate: 0, buildingArea: grossArea, perCost: ''};
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    //let projects = await projectModel.find({ID: {$in : projectIDs}, projType: projectType.project, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      //单项工程
 | 
	
		
			
				|  |  |      let engineerings = await projectModel.find({ParentID: {$in : projectIDs}, projType: projectType.engineering, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]});
 | 
	
		
			
				|  |  |      //单位工程
 | 
	
	
		
			
				|  | @@ -574,10 +592,41 @@ async function getSummaryInfo(projectIDs){
 | 
	
		
			
				|  |  |              let projInfo = IDMapping[eng.ParentID];
 | 
	
		
			
				|  |  |              engInfo.rate = !isDef(projInfo) || projInfo.engineeringCost == 0 ? 0 : scMathUtil.roundTo(engInfo.engineeringCost * 100 / projInfo.engineeringCost, rateDecimal);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        for(let projectID of projectIDs){
 | 
	
		
			
				|  |  | -            IDMapping[projectID].rate = 100;
 | 
	
		
			
				|  |  | +        //建设项目占造价比例及单方造价
 | 
	
		
			
				|  |  | +        for(let project of projects){
 | 
	
		
			
				|  |  | +            let projectInfo = IDMapping[project.ID];
 | 
	
		
			
				|  |  | +            projectInfo.rate = 100;
 | 
	
		
			
				|  |  | +            projectInfo.perCost = projectInfo.buildingArea.toString().trim() === '' || projectInfo.buildingArea == 0 ?
 | 
	
		
			
				|  |  | +                                  projectInfo.buildingArea.toString().trim() : scMathUtil.roundTo(projectInfo.engineeringCost / projectInfo.buildingArea, perCostDecimal);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      console.log(IDMapping);
 | 
	
		
			
				|  |  |      return IDMapping;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//根据项目ID获取所属建设项目
 | 
	
		
			
				|  |  | +//@param {Number}projectID @return {Object}
 | 
	
		
			
				|  |  | +async function getConstructionProject(projectID){
 | 
	
		
			
				|  |  | +    const notDeleted = [{deleteInfo: null}, {'deleteInfo.deleted': false}];
 | 
	
		
			
				|  |  | +    function returnProject(project){
 | 
	
		
			
				|  |  | +        if(!project || project.projType === projectType.folder){
 | 
	
		
			
				|  |  | +            return null;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(project.projType === projectType.project){
 | 
	
		
			
				|  |  | +            return project;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    let project = await projectModel.findOne({ID: projectID, $or: notDeleted});
 | 
	
		
			
				|  |  | +    let returnV = returnProject(project);
 | 
	
		
			
				|  |  | +    if(returnV !== undefined){
 | 
	
		
			
				|  |  | +        return returnV;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    let parent = await projectModel.findOne({ID: project.ParentID, $or: notDeleted});
 | 
	
		
			
				|  |  | +    returnV = returnProject(parent);
 | 
	
		
			
				|  |  | +    if(returnV !== undefined){
 | 
	
		
			
				|  |  | +        return returnV;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    let grandParent = await projectModel.findOne({ID: parent.ParentID, $or: notDeleted});
 | 
	
		
			
				|  |  | +    returnV = returnProject(grandParent);
 | 
	
		
			
				|  |  | +    return returnV !== undefined ? returnV : null;
 | 
	
		
			
				|  |  |  }
 |