Просмотр исходного кода

fix:新建建设项目,基本信息没有读取到后台配置

vian 5 лет назад
Родитель
Сommit
8757c09235

+ 25 - 0
modules/all_models/basic_info_lib.js

@@ -0,0 +1,25 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2019/3/5
+ * @version
+ */
+//建设项目基本信息库
+const mongoose = require('mongoose');
+const Schema = mongoose.Schema;
+const oprSchema = require('../all_schemas/opr_schema');
+const basicInfoLib = new Schema({
+    ID: {type: String, index: true},
+    name: String,
+    creator: String,
+    createDate: Number,
+    recentOpr: [oprSchema],
+    info: {
+        type: Schema.Types.Mixed,
+        default: []
+    }
+});
+mongoose.model('std_basic_info_lib', basicInfoLib, 'std_basic_info_lib');

+ 49 - 5
modules/pm/facade/pm_facade.js

@@ -9,6 +9,7 @@
     };
 //先导出后require可以解决循环引用问题
 module.exports={
+    getBasicInfo,
     getProjectByGranularity,
     prepareShareList,
     getShareList,
@@ -106,11 +107,14 @@ const {
     fixedFlag,
     SharePermissionChangeType,
     GRANULARITY,
+    BOQType
 } = require('../../../public/common_constants');
 const notDeleted = [{deleteInfo: null}, {'deleteInfo.deleted': false}];
 let cipher = require('../../../public/cipher');
 let index = require("../../system_setting/model/index");
 const compilationModel = mongoose.model('compilation');
+const engineeringModel = mongoose.model('engineering_lib');
+const basicInfoModel = mongoose.model('std_basic_info_lib');
 let qiniu = require("qiniu");
 let fs = require("fs");
 let path = require("path");
@@ -1099,15 +1103,19 @@ function isDef(v){
 }
 
 function getTotalFee(bills, feeName) {
-    if(!isDef(bills)){
+    if (!isDef(bills)) {
         return 0;
     }
-    if(!isDef(bills.fees) || bills.fees.length <= 0){
+    if (!isDef(bills.fees) || bills.fees.length <= 0) {
         return 0;
     }
-    for(let fee of bills.fees){
-        if(isDef(fee.fieldName) && fee.fieldName === feeName){
-            return isDef(fee.totalFee) ? fee.totalFee : 0;
+    for (let fee of bills.fees) {
+        if (isDef(fee.fieldName) && fee.fieldName === feeName) {
+            return isDef(fee.tenderTotalFee)
+                ? fee.tenderTotalFee
+                : isDef(fee.totalFee)
+                    ? fee.totalFee
+                    : 0;
         }
     }
     return 0;
@@ -2256,3 +2264,39 @@ async function getProjectByGranularity(tenderID, granularity, requestForSummaryI
     constructionProject.softInfo = `${company};${versionName};${version};${userID}`;
     return constructionProject;
 }
+
+//获取费用定额绑定的基本信息库数据
+async function getBasicInfo(compilationID, fileKind = null) {
+    const compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(compilationID)});
+    if (!compilation) {
+        return null;
+    }
+    const billValuation = compilation.bill_valuation.find(function (data) {
+        return data.enable;
+    });
+    if (!billValuation) {
+        return null;
+    }
+    const engineerings = await engineeringModel.find({valuationID: billValuation.id}).lean();
+    const engineering = engineerings.find(function (data) {
+        return data.info_lib && data.info_lib.length > 0;
+    });
+    if (!engineering || !engineering.info_lib || !engineering.info_lib[0]) {
+        return null;
+    }
+    const infoLib = await basicInfoModel.findOne({ID: engineering.info_lib[0].id});
+    //提取文件类型中需要的数据 (投标项目可能不需要招标的一些信息)
+    if (fileKind && infoLib && infoLib.info && infoLib.info.length) {
+        const strMap = {
+            [BOQType.BID_SUBMISSION]: '投标',
+            [BOQType.BID_INVITATION]: '招标',
+        };
+        const needfulData = infoLib.info.filter(data => !data.fileKind || data.fileKind === strMap[fileKind]);
+        needfulData.forEach(nData => {
+            let needfulSub = nData.items.filter(sData => !sData.fileKind || sData.fileKind === strMap[fileKind]);
+            nData.items = needfulSub;
+        });
+        infoLib.info = needfulData;
+    }
+    return infoLib;
+}

+ 7 - 1
modules/pm/models/project_model.js

@@ -146,7 +146,13 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                 data.updateData['fileVer'] = await index.getVersion();
                 if(data.updateData.projType === projectType.project){
                     //设置建设项目基本信息,多个单位工程共用
-                    data.updateData.property.basicInformation = basicInformation;
+                    const fileKind = data.updateData.property.boqType;
+                    if (fileKind) {
+                        const infoLib = await pmFacade.getBasicInfo(compilationId, fileKind);
+                        data.updateData.property.basicInformation = infoLib && infoLib.info || basicInformation;
+                    } else {
+                        data.updateData.property.basicInformation = [];
+                    }
                 }
                 // 如果没有选中单价文件则新增单价文件
                 if (data.updateData.projType === projectType.tender && data.updateData.property !== null &&