|
|
@@ -28,7 +28,9 @@ module.exports={
|
|
|
getProjectFeature: getProjectFeature,
|
|
|
getProjectByGranularity: getProjectByGranularity,
|
|
|
importProject: importProject,
|
|
|
- getProjectPlaceholder: getProjectPlaceholder
|
|
|
+ getProjectPlaceholder: getProjectPlaceholder,
|
|
|
+ exportProject:exportProject,
|
|
|
+ importProjects:importProjects//建筑这里重名了,这比养护加多了个s
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -92,6 +94,8 @@ let calcProgramFacade = require('../../main/facade/calc_program_facade');
|
|
|
let mainColLibModel = mongoose.model('std_main_col_lib');
|
|
|
import EngineeringLibModel from "../../users/models/engineering_lib_model";
|
|
|
let installationFacade = require('../../main/facade/installation_facade');
|
|
|
+let cipher = require('../../../public/cipher');
|
|
|
+
|
|
|
|
|
|
//拷贝例题项目
|
|
|
//@param {String}userID {Array}projIDs拷贝的例题项目ID(建设项目、文件夹)@return {Boolean}
|
|
|
@@ -1522,4 +1526,83 @@ async function setupStdData(tenderData) {
|
|
|
ratio.type = stdGLJ.gljType;
|
|
|
}
|
|
|
});
|
|
|
+}
|
|
|
+
|
|
|
+async function exportProject(userID,data){//导出建设项目
|
|
|
+ if(data.type == 'main'){
|
|
|
+ return await exportMainData(userID,data.projectID);
|
|
|
+ }else {
|
|
|
+ return await exportTenderData(data);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function exportMainData(userID,projectID) {
|
|
|
+ let result = {userID:userID,projects:[],type:'Project'};//type 备用属性,表示导出的类型,目前导出的都是整个建设项目
|
|
|
+ let tenderIDs = [];
|
|
|
+ let project = await projectModel.findOne({ID:projectID});
|
|
|
+ if(!project) throw new Error("没有找到该建设项目:"+projectID);
|
|
|
+ result['compilationID'] = project.compilation;
|
|
|
+ result.projects.push(project);
|
|
|
+ let subProjects = await projectModel.find({"$or": [{'ParentID':projectID}, {"property.rootProjectID": projectID}]});
|
|
|
+ for(let s of subProjects){
|
|
|
+ if(!s.deleteInfo || !s.deleteInfo.deleted){
|
|
|
+ result.projects.push(s);
|
|
|
+ if(s.projType =="Tender") tenderIDs.push(s.ID);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let files = {unitFiles:await exportUnitFiles(projectID),feeRateFiles:await exportFeeRateFiles(projectID)};
|
|
|
+ result.files = files;
|
|
|
+ result = cipher.aesEncrypt(JSON.stringify(result));
|
|
|
+ result +="|----|" +JSON.stringify(tenderIDs);
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+async function exportUnitFiles(rootProjectID){
|
|
|
+ let unitFiles = [];
|
|
|
+ let files = await unitPriceFileModel.find({root_project_id:rootProjectID});
|
|
|
+ for(let f of files){
|
|
|
+ if(f.deleteInfo && f.deleteInfo.deleted == true) continue;
|
|
|
+ let tem = {unitFile:f};
|
|
|
+ tem.unitPrices = await unitPriceModel.find({unit_price_file_id:f.id});
|
|
|
+ tem.mixRatios = await mixRatioModel.find({unit_price_file_id:f.id});
|
|
|
+ unitFiles.push(tem);
|
|
|
+ }
|
|
|
+ return unitFiles;
|
|
|
+}
|
|
|
+
|
|
|
+async function exportFeeRateFiles(rootProjectID) {
|
|
|
+ let feeRateFiles = [];
|
|
|
+ let files = await feeRateFileModel.find({rootProjectID:rootProjectID});
|
|
|
+ for(let f of files){
|
|
|
+ if(f.deleteInfo && f.deleteInfo.deleted == true) continue;
|
|
|
+ let tem = {feeRateFile:f};
|
|
|
+ tem.feeRate = await feeRateModel.findOne({ID:f.feeRateID});
|
|
|
+ feeRateFiles.push(tem);
|
|
|
+ }
|
|
|
+ return feeRateFiles;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+async function exportTenderData(data){
|
|
|
+ let result = {};
|
|
|
+ let projectSetting = await projectSettingModel.findOne({"projectID": data.projectID}, '-_id');
|
|
|
+ if(projectSetting) result['projSetting'] = projectSetting;
|
|
|
+ result.bills = await billsModel.find({"projectID": data.projectID});
|
|
|
+ result.rations = await rationModel.find({'$or': [{projectID: data.projectID, deleteInfo: null}, {projectID: data.projectID, 'deleteInfo.deleted': {$in: [null, false]}}]});
|
|
|
+ result.projectGLJs = await gljListModel.find({'project_id':data.projectID});
|
|
|
+ result.installationFees = await installationFeeModel.find({projectID:data.projectID});
|
|
|
+ result.rationGLJs = await rationGLJModel.find({projectID:data.projectID});
|
|
|
+ result.rationCoes = await rationCoeModel.find({projectID:data.projectID});
|
|
|
+ result.quantityDetails = await quantityDetailModel.find({projectID:data.projectID});
|
|
|
+ result.rationInstallations = await rationInstallationModel.find({projectID:data.projectID});
|
|
|
+ result.rationTemplates = await rationTemplateModel.find({projectID:data.projectID});
|
|
|
+ result.calcProgramsFile = await calcProgramsModel.findOne({projectID:data.projectID});
|
|
|
+ result.labourCoes = await labourCoesModel.findOne({projectID:data.projectID});
|
|
|
+
|
|
|
+ return cipher.aesEncrypt(JSON.stringify(result));
|
|
|
+}
|
|
|
+
|
|
|
+async function importProjects(data,req,fields) {
|
|
|
+
|
|
|
}
|