Преглед на файлове

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuCost

Conflicts:
	web/building_saas/standard_interface/export/base.js
zhangweicheng преди 5 години
родител
ревизия
726a53fb4b

+ 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 &&

+ 36 - 28
web/building_saas/standard_interface/export/anhui_maanshan.js

@@ -18,7 +18,10 @@ INTERFACE_EXPORT = (() => {
      */
     async function entry(areaKey, exportKind, projectData, tenderDetailMap) {
         const {
-            CONFIG: { TYPE },
+            CONFIG: { 
+                TYPE, 
+                WHITE_SPACE
+            },
             UTIL: {
                 getValueByKey,
                 getHan,
@@ -56,7 +59,7 @@ INTERFACE_EXPORT = (() => {
                 [CONTROL]: '招标控制',
             };
             const attrs = [
-                { name: 'Xmbh', value: getValueByKey(information, 'projNum') }, // 项目编号
+                { name: 'Xmbh', value: getValueByKey(information, 'projNum') , minLen: 1, whiteSpace: WHITE_SPACE.COLLAPSE }, // 项目编号,招标xsd中有规定minLen whiteSpace,这里投标招标统一处理
                 { name: 'Xmmc', value: projectName }, // 项目名称
                 { name: 'Bzlx', value: '清单' }, // 项目编制类型
                 { name: 'Jjyj', value: '【18清单】2018部颁清单计价依据' }, // 计价依据
@@ -153,7 +156,7 @@ INTERFACE_EXPORT = (() => {
         // 单项工程信息,因项目管理中无“单项工程”这一层,从单位工程的工程特征信息中拼凑出来
         function Dxgcxx(code, name) {
             const attrs = [
-                { name: 'Dxgcbh', value: code }, // 单项工程编号
+                { name: 'Dxgcbh', value: code, minLen: 1, whiteSpace: WHITE_SPACE.COLLAPSE }, // 单项工程编号
                 { name: 'Dxgcmc', value: name }, // 单项工程名称
             ];
             Element.call(this, 'Dxgcxx', attrs);
@@ -162,7 +165,7 @@ INTERFACE_EXPORT = (() => {
         // 单位工程信息
         function Dwgcxx(tenderName, feature) {
             const attrs = [
-                { name: 'Dwgcbh', value: getValueByKey(feature, '') }, // 单位工程编号
+                { name: 'Dwgcbh', value: getValueByKey(feature, 'unitProjNo'), minLen: 1, whiteSpace: WHITE_SPACE.COLLAPSE }, // 单位工程编号
                 { name: 'Dwgcmc', value: tenderName }, // 单位工程名称
             ];
             Element.call(this, 'Dwgcxx', attrs);
@@ -186,10 +189,10 @@ INTERFACE_EXPORT = (() => {
                 '雨季施工增加费': 'YJF',
                 '夜间施工增加费': 'YEF',
                 '工地转移费': 'ZYF',
-                '高原施工增加费': 'GYF',
-                '风沙地区增加费': 'FSF',
-                '沿海地区增加费': 'YHF',
-                '行车干扰增加费': 'XCF',
+                '高原地区施工增加费': 'GYF',
+                '风沙地区施工增加费': 'FSF',
+                '沿海地区施工增加费': 'YHF',
+                '行车干扰施工增加费': 'XCF',
                 '施工辅助费': 'SFF',
                 '养老保险费': 'YLF',
                 '失业保险费': 'SYF',
@@ -211,23 +214,26 @@ INTERFACE_EXPORT = (() => {
                 '运输': 2,
                 '路面': 4,
                 '隧道': 11,
-                '构造物I': 5,
-                '构造物I(不计冬)': 16,
-                '构造物II': 6,
-                '构造物III(桥梁)': 9,
-                '构造物III(除桥以外不计雨)': 8,
+                '构造物': 5,
+                '构造物(不计冬)': 16,
+                '构造物': 6,
+                '构造物(桥梁)': 9,
+                '构造物Ⅲ(除桥以外不计雨夜)': 8,
                 '技术复杂大桥': 10,
                 '钢材及钢结构(桥梁)': 12,
                 '钢材及钢结构(除桥以外不计夜)': 13,
                 '费率为0': 17,
                 '路面(不计雨)': 4,
-                '构造物I(不计雨)': 16,
-                '构造物III(除桥以外)': 8,
+                '构造物(不计雨)': 16,
+                '构造物(除桥以外)': 8,
                 '钢材及钢结构(除桥以外)': 13,
                 '设备': 15,
                 '量价': 14,
             };
             const rate = isEmptyVal(item.rate) ? '100' : item.rate; // 为空时输出=100,为0时输出=0
+            /* if (!FeeRateTypeMap[rootItem.name]) {
+                debugger;
+            } */
             const attrs = [
                 { name: 'Bm', value: FeeRateCodeMap[item.name] }, // 编码
                 { name: 'Name', value: item.name }, // 名称
@@ -302,10 +308,10 @@ INTERFACE_EXPORT = (() => {
                 { name: 'Dw', value: node.data.unit }, // 单位
                 { name: 'Sl', value: node.data.quantity, type: TYPE.DECIMAL }, // 工程量
                 { name: 'Sl2', value: '0', type: TYPE.DECIMAL }, // 工程量2
-                { name: 'Rgf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'labour.tenderTotalFee'), type: TYPE.DECIMAL }, // 人工费
-                { name: 'Clf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'material.tenderTotalFee'), type: TYPE.DECIMAL }, // 材料费
-                { name: 'Jxf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'machine.tenderTotalFee'), type: TYPE.DECIMAL }, // 机械费
-                { name: 'Sbf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'equipment.tenderTotalFee'), type: TYPE.DECIMAL }, // 设备费
+                { name: 'Rgf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'marketLabour.tenderTotalFee'), type: TYPE.DECIMAL }, // 人工费
+                { name: 'Clf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'marketMaterial.tenderTotalFee'), type: TYPE.DECIMAL }, // 材料费
+                { name: 'Jxf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'marketMachine.tenderTotalFee'), type: TYPE.DECIMAL }, // 机械费
+                { name: 'Sbf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'marketEquipment.tenderTotalFee'), type: TYPE.DECIMAL }, // 设备费
                 { name: 'Csf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'measure.tenderTotalFee'), type: TYPE.DECIMAL }, // 措施费
                 { name: 'Glf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'manage.tenderTotalFee'), type: TYPE.DECIMAL }, // 企业管理费
                 { name: 'Gf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'force.tenderTotalFee'), type: TYPE.DECIMAL }, // 规费
@@ -346,10 +352,10 @@ INTERFACE_EXPORT = (() => {
                 { name: 'Sl', value: ration.tenderQuantity }, // 工程量
                 { name: 'Dj', value: getFee(ration.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL }, // 单价
                 { name: 'Hj', value: getFee(ration.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL }, // 合价
-                { name: 'Rgf', value: getFee(ration.fees, 'labour.tenderTotalFee'), type: TYPE.DECIMAL }, // 人工费
-                { name: 'Clf', value: getFee(ration.fees, 'material.tenderTotalFee'), type: TYPE.DECIMAL }, // 材料费
-                { name: 'Jxf', value: getFee(ration.fees, 'machine.tenderTotalFee'), type: TYPE.DECIMAL }, // 机械费
-                { name: 'Sbf', value: getFee(ration.fees, 'equipment.tenderTotalFee'), type: TYPE.DECIMAL }, // 设备费
+                { name: 'Rgf', value: getFee(ration.fees, 'marketLabour.tenderTotalFee'), type: TYPE.DECIMAL }, // 人工费
+                { name: 'Clf', value: getFee(ration.fees, 'marketMaterial.tenderTotalFee'), type: TYPE.DECIMAL }, // 材料费
+                { name: 'Jxf', value: getFee(ration.fees, 'marketMachine.tenderTotalFee'), type: TYPE.DECIMAL }, // 机械费
+                { name: 'Sbf', value: getFee(ration.fees, 'marketEquipment.tenderTotalFee'), type: TYPE.DECIMAL }, // 设备费
                 { name: 'Csf', value: getFee(ration.fees, 'measure.tenderTotalFee'), type: TYPE.DECIMAL }, // 措施费
                 { name: 'Glf', value: getFee(ration.fees, 'manage.tenderTotalFee'), type: TYPE.DECIMAL }, // 企业管理费
                 { name: 'Gf', value: getFee(ration.fees, 'force.tenderTotalFee'), type: TYPE.DECIMAL }, // 规费
@@ -424,7 +430,7 @@ INTERFACE_EXPORT = (() => {
                 { name: 'Dj', value: isBidInvitation ? '0' : getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL }, // 单价
                 { name: 'Hj', value: isBidInvitation ? '0' : getFee(node.data.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL }, // 合价
             ];
-            Element.call(this, 'JrgBJrgMx', attrs);
+            Element.call(this, 'JrgMx', attrs);
         }
 
         // 暂估材料表、评标材料表
@@ -463,8 +469,8 @@ INTERFACE_EXPORT = (() => {
             }
             const attrs = [
                 { name: 'RcjId', value: projectGLJIDToRcjID[glj.id] }, // 资源ID
-                { name: 'Bm', value: glj.code }, // 编码
-                { name: 'Mc', value: glj.name }, // 名称
+                { name: 'RcjBm', value: glj.code }, // 编码
+                { name: 'Name', value: glj.name }, // 名称
                 { name: 'Ggxh', value: glj.specs }, // 规格型号
                 { name: 'Dw', value: glj.unit }, // 单位
                 { name: 'Dj', value: glj.priceInfo.tenderPrice, type: TYPE.DECIMAL }, // 预算价,调后
@@ -474,7 +480,7 @@ INTERFACE_EXPORT = (() => {
                 { name: 'Gycs', value: '' }, // 厂商
                 { name: 'Rcjlb', value: rootType, type: TYPE.INT }, // 人材机类型 1=人工;2=材料;3=机械
                 { name: 'Jgbz', value: 'false', type: TYPE.BOOL }, // 供材方
-                { name: 'Zyclbj', value: !!glj.is_main_material, type: TYPE.BOOL }, // 主要材料
+                { name: 'Zyclbz', value: !!glj.is_main_material, type: TYPE.BOOL }, // 主要材料
                 { name: 'Zgjbz', value: !!glj.is_evaluate, type: TYPE.BOOL }, // 是否暂估
                 { name: 'Zcbz', value: 'false', type: TYPE.BOOL }, // 主材标记
             ];
@@ -655,7 +661,9 @@ INTERFACE_EXPORT = (() => {
             const rationEles = rationNodes.map(node => {
                 const rationEle = new QdxdezjMx(node.data);
                 // 定额人材机
-                const rationGLJList = curDetail.ration_glj.datas.filter(glj => glj.rationID === node.data.ID);
+                let rationGLJList = curDetail.ration_glj.datas.filter(glj => glj.rationID === node.data.ID);
+                // 定额人材机排序
+                rationGLJList = gljUtil.sortRationGLJ(rationGLJList);
                 const rationGLJRoot = new Qdxdercjhl();
                 const rationGLJEles = rationGLJList.map(glj => new QdxdercjhlMx(projectGLJIDToRcjID[glj.projectGLJID], glj.tenderQuantity));
                 rationGLJRoot.children.push(...rationGLJEles);

+ 2 - 2
web/building_saas/standard_interface/export/base.js

@@ -772,12 +772,12 @@ const INTERFACE_EXPORT_BASE = (() => {
 
   // 对getData返回的数据进行一些通用预处理,方便各接口直接取值、处理
   function tenderDetailPretreatment(tenderDetail) {
-    const projectGLJList = tenderDetail.projectGLJ.datas.gljList;
     const bidEvaluationList = tenderDetail.bid_evaluation_list.datas;
     const evaluateList = tenderDetail.evaluate_list.datas;
     const decimalInfo = tenderDetail.projectInfo.property.decimal;
     // 项目人材机汇总排序
-    gljUtil.sortRationGLJ(projectGLJList);
+        tenderDetail.projectGLJ.datas.gljList = gljUtil.sortRationGLJ(tenderDetail.projectGLJ.datas.gljList);
+        const projectGLJList = tenderDetail.projectGLJ.datas.gljList;
     // 计算人材机总消耗量,否则projectGLJ.datas.gljList里的数据不会有消耗量数据
     gljUtil.calcProjectGLJQuantity(tenderDetail.projectGLJ.datas, tenderDetail.ration_glj.datas, tenderDetail.Ration.datas, tenderDetail.Bills.datas, tenderDetail.property.decimal.glj.quantity, _, scMathUtil);
     projectGLJList.forEach(glj => {

+ 1 - 1
web/building_saas/standard_interface/export/view.js

@@ -49,7 +49,7 @@ const EXPORT_VIEW = (() => {
                     pr.start('导出数据接口', '正在导出文件,请稍候……');
                     for (const checkedData of checkedDatas) {
                         const boqType = parseInt($(checkedData).val());
-                        const requestForSummaryInfo = INTERFACE_EXPORT.requestForSummaryInfo || {};
+                        const requestForSummaryInfo = INTERFACE_EXPORT.requestForSummaryInfo || null;
                         const projectID = projectObj.project.ID();
                         const exportData = await _base.extractExportData(INTERFACE_EXPORT.entry, requestForSummaryInfo, boqType, areaKey, projectID, userID);
                         _exportCache.push(...exportData);