|
@@ -19,6 +19,7 @@ module.exports={
|
|
|
moveProject:moveProject,
|
|
|
copyProject:copyProject,
|
|
|
copyExample: copyExample,
|
|
|
+ setupSummaryFields: setupSummaryFields,
|
|
|
getSummaryInfo: getSummaryInfo,
|
|
|
getSummaryInfoByTender: getSummaryInfoByTender,
|
|
|
getIndexReportData: getIndexReportData,
|
|
@@ -1052,6 +1053,32 @@ const defaultSummaryField = {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+// 项目管理界面需要显示的汇总字段
|
|
|
+function setupSummaryFields(summaryInfo, projects, fields = null) {
|
|
|
+ if (!fields) {
|
|
|
+ fields = [
|
|
|
+ 'engineeringCost',
|
|
|
+ 'subEngineering',
|
|
|
+ 'measure',
|
|
|
+ 'safetyConstruction',
|
|
|
+ 'other',
|
|
|
+ 'charge',
|
|
|
+ 'tax',
|
|
|
+ 'rate',
|
|
|
+ 'buildingArea',
|
|
|
+ 'perCost'
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ for(const proj of projects){
|
|
|
+ const summaryProj = summaryInfo[proj.ID];
|
|
|
+ if(summaryProj){
|
|
|
+ for (const field of fields) {
|
|
|
+ proj[field] = summaryProj[field];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
async function getSummaryInfo(projectIDs, summaryField = defaultSummaryField){
|
|
|
function initFees(target, summaryField) {
|
|
|
for (const flag in summaryField) {
|
|
@@ -1351,9 +1378,15 @@ async function getUpChainIDs(projectID) {
|
|
|
return rst;
|
|
|
}
|
|
|
|
|
|
-//获取projectIDs文件下所有子项目(不包括projectIDs本身)
|
|
|
-async function getPosterityProjects(projectIDs) {
|
|
|
+//获取projectIDs文件下所有子项目(默认不包括projectIDs本身)
|
|
|
+async function getPosterityProjects(projectIDs, includeSelf = false) {
|
|
|
let rst = [];
|
|
|
+ if (includeSelf) {
|
|
|
+ const projects = await projectModel.find({ID: {$in: projectIDs}, $or: notDeleted}, '-_id').lean();
|
|
|
+ if (projects) {
|
|
|
+ rst.push(...projects);
|
|
|
+ }
|
|
|
+ }
|
|
|
async function getProjects(parentIDs) {
|
|
|
if (parentIDs.length > 0) {
|
|
|
let newIDs = [];
|
|
@@ -2084,6 +2117,7 @@ async function doDownLoadAndImport(privateDownloadUrl,info) {
|
|
|
try {
|
|
|
let data = fs.readFileSync(stream.path,'utf-8');
|
|
|
let result = await importProjects(data,{session:info.session},info.updateData);
|
|
|
+ doc.projectID = result.constructionProjectID;
|
|
|
if(result.error == 1){
|
|
|
doc.errorMsg = result.msg;
|
|
|
doc.status = "error";
|
|
@@ -2106,6 +2140,13 @@ async function importProcessChecking(data){
|
|
|
if(log.status == "finish"){
|
|
|
result.status = "complete";
|
|
|
await importLogsModel.remove({key:data.key});
|
|
|
+ // 获取导入的项目数据
|
|
|
+ if (log.projectID) {
|
|
|
+ const projects = await getPosterityProjects([log.projectID], true);
|
|
|
+ const summaryInfo = await getSummaryInfo([log.projectID]);
|
|
|
+ setupSummaryFields(summaryInfo, projects);
|
|
|
+ result.data = projects;
|
|
|
+ }
|
|
|
}else if(log.status == "start"){
|
|
|
result.status = "processing";
|
|
|
}else if(log.status == "error"){
|
|
@@ -2200,7 +2241,8 @@ async function importProjects(data,req,updateData) {
|
|
|
result.error = 1;
|
|
|
result.msg = `您创建的项目个数超限,请联系我们的客服人员,或者导出建设项目保存到本地备份,删除云上数据。`;
|
|
|
}
|
|
|
- let [projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap] = await handleMainProjectDatas(mainData,updateData,req.session.sessionUser.id);
|
|
|
+ let [constructionProjectID,projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap] = await handleMainProjectDatas(mainData,updateData,req.session.sessionUser.id);
|
|
|
+ result.constructionProjectID = constructionProjectID;
|
|
|
if(datas.length > 1 ){
|
|
|
for(let i = 1;i<datas.length;i++){
|
|
|
await handleEachProject(datas[i],projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap)
|
|
@@ -2328,11 +2370,15 @@ async function handleMainProjectDatas(mainData,updateData,userID) {
|
|
|
let projectIDMap = {},feeRateFileIDMap={},unitPriceFileIDMap={},labourCoeFileIDMap={},calcProgramFileIDMap={};
|
|
|
let tasks = [];
|
|
|
projectIDMap[-1] = -1;//最后一个项目的nextID为-1的情况
|
|
|
+ let constructionProjectID;
|
|
|
//生成新的projectID
|
|
|
for(let p of mainData.projects){
|
|
|
let newProjectID = await getCounterID("projects");
|
|
|
projectIDMap[p.ID] = newProjectID;
|
|
|
- if(p.projType == "Project") mainProjectID = newProjectID;
|
|
|
+ if(p.projType == "Project") {
|
|
|
+ mainProjectID = newProjectID;
|
|
|
+ constructionProjectID = newProjectID;
|
|
|
+ }
|
|
|
if(p.projType == "Tender"){
|
|
|
if(p.property.calcProgramFile) calcProgramFileIDMap[p.property.calcProgramFile.ID] = uuidV1();//新的计算程序文件ID
|
|
|
if(p.property.labourCoeFile) labourCoeFileIDMap[p.property.labourCoeFile.ID] = uuidV1();//新的人工调整系数文件ID
|
|
@@ -2381,7 +2427,7 @@ async function handleMainProjectDatas(mainData,updateData,userID) {
|
|
|
await importUnitPriceFiles(mainData,projectIDMap,unitPriceFileIDMap,userID);
|
|
|
|
|
|
|
|
|
- return [projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap]
|
|
|
+ return [constructionProjectID,projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap]
|
|
|
}
|
|
|
|
|
|
|