Explorar el Código

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

# Conflicts:
#	web/over_write/js/chongqing_2018.js
zhongzewei hace 6 años
padre
commit
73f37e55d0

+ 1 - 1
config/config.js

@@ -11,7 +11,7 @@ module.exports = {
             auth: {
                 "authdb": "admin"
             },
-            connectTimeoutMS: 50000,
+            connectTimeoutMS: 100000,
             useMongoClient: true
         }
     },

+ 2 - 2
config/db/db_manager.js

@@ -50,11 +50,11 @@ module.exports = {
         var config = require("../config.js");
         var dbURL = 'mongodb://' + config[env].server + ":" + config[env].port + '/scConstruct';
         if(config[env].dbURL){
-            mg.connect(config[env].dbURL,{connectTimeoutMS: 20000,useMongoClient: true});
+            mg.connect(config[env].dbURL,{connectTimeoutMS: 100000,useMongoClient: true});
         } else if(config[env].options){
             mg.connect(dbURL,config[env].options);
         }else {
-            mg.connect(dbURL,{connectTimeoutMS: 20000,useMongoClient: true});//useMongoClient': true*! //报 DeprecationWarning: `open()` is deprecated in mongoose这个错
+            mg.connect(dbURL,{connectTimeoutMS: 100000,useMongoClient: true});//useMongoClient': true*! //报 DeprecationWarning: `open()` is deprecated in mongoose这个错
         }
         var db = mg.connection;
         db.on("error",function (err) {

+ 27 - 21
logs/online_logs.js

@@ -10,28 +10,34 @@ import moment from "moment";
 let logs_model = mongoose.model("online_logs");
 
 async function saveOnlineTime(req) {
-    let interval_time = 10 * 60 *1000;
-    let start = req.session.online_start_time;
+    let online_times = 0;
     let end = + new Date();
-    if(start === undefined) return req.session.online_start_time ==end;
-    let online_times =  end - start;
-    //1秒内只记一次就好
-    if(online_times < 500) return;//如果间隔太短,则忽略
-    if(online_times > interval_time ){//如果间隔超过有效时长,则不累加这次时长,从头开始算
-        req.session.online_start_time = end;
-        return
-    }
-    if(!req.session.sessionUser||!req.session.sessionCompilation) return;
-    let dataString = moment(end).format('YYYY-MM-DD');
-    let condition = {userID:req.session.sessionUser.id,compilationID:req.session.sessionCompilation._id,dateString:dataString};
-    let record = await logs_model.findOne(condition);
-    if(record){ //如果找到,则累加
-        await logs_model.update(condition,{$inc:{'online_times' : online_times }});
-    }else {//如果没找到,则新增一条记录
-        condition["online_times"] = online_times;
-        let today = moment(dataString).toDate();
-        condition["dateTime"] = +today;
-        await logs_model.create(condition);
+    try {
+        let interval_time = 10 * 60 *1000;
+        let start = req.session.online_start_time;
+        if(start === undefined) return req.session.online_start_time ==end;
+        let online_times =  end - start;
+        //1秒内只记一次就好
+        if(online_times < 500) return;//如果间隔太短,则忽略
+        if(online_times > interval_time ){//如果间隔超过有效时长,则不累加这次时长,从头开始算
+            req.session.online_start_time = end;
+            return
+        }
+        if(!req.session.sessionUser||!req.session.sessionCompilation) return;
+        let dataString = moment(end).format('YYYY-MM-DD');
+        let condition = {userID:req.session.sessionUser.id,compilationID:req.session.sessionCompilation._id,dateString:dataString};
+        let record = await logs_model.findOne(condition);
+        if(record){ //如果找到,则累加
+            await logs_model.update(condition,{$inc:{'online_times' : online_times }});
+        }else {//如果没找到,则新增一条记录
+            condition["online_times"] = online_times;
+            let today = moment(dataString).toDate();
+            condition["dateTime"] = +today;
+            await logs_model.create(condition);
+        }
+    }catch (e){
+        console.log("统计登录时间错误,online_times值:"+online_times);
+        console.log(e);
     }
     req.session.online_start_time = end;
 }

+ 2 - 1
modules/all_models/engineering_lib.js

@@ -77,7 +77,8 @@ let modelSchema = {
     //取费专业
     engineering:Number,
     //是否计算安装增加费
-    isInstall:{type: Boolean, default: false}
+    isInstall:{type: Boolean, default: false},
+    seq:Number//序列号
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
 

+ 40 - 16
modules/complementary_ration_lib/models/searchModel.js

@@ -16,27 +16,30 @@ class SearchDao{
     async getRationItem(userId, compilationId, rationRepIds, code, ID, callback){
         let ration = null;
         try{
+            let firstLib = rationRepIds.shift();//优先取第一个
+            if(rationRepIds.includes(firstLib)) {//去掉重复的库ID
+                rationRepIds.splice(rationRepIds.indexOf(firstLib), 1);
+            }
             if(rationRepIds.includes(compleRationLib)) {
                 rationRepIds.splice(rationRepIds.indexOf(compleRationLib), 1);
             }
-            let stdQuery = {rationRepId: {$in: rationRepIds}, code: code, $or: [{isDeleted: null}, {isDeleted: false}]};
-            if(ID){
-                stdQuery = {ID: ID, $or: [{isDeleted: null}, {isDeleted: false}]};
-            }
-            let stdRation = await stdRationModel.findOne(stdQuery);
-            if(isDef(stdRation)){
-                ration = stdRation._doc;
-                ration.type = 'std';
-            } else{
-                let compleQuery = {userId: userId, compilationId: compilationId, code: code, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]};
+            if(firstLib == compleRationLib){//说明选中的是补充定额库
+                ration = await this.getCompleRation(userId,compilationId,code,ID);
+            }else {
+                firstLib = parseInt(firstLib);
+                let firstQuery = {rationRepId: firstLib, code: code, $or: [{isDeleted: null}, {isDeleted: false}]};
                 if(ID){
-                    compleQuery.ID = ID;
+                    firstQuery = {ID: ID, $or: [{isDeleted: null}, {isDeleted: false}]};
                 }
-                let compleRation = await compleRationModel.findOne(compleQuery);
-                if(isDef(compleRation)){
-                    ration = compleRation._doc;
-                    ration.type = 'complementary';
+                ration = await this.getStdRation(firstQuery);
+            }
+            if(ration == null){//选中的定额库或者默认的定额库中没有找到定额,才走常规的流程查找其它定额库
+                let stdQuery = {rationRepId: {$in: rationRepIds}, code: code, $or: [{isDeleted: null}, {isDeleted: false}]};
+                if(ID){
+                    stdQuery = {ID: ID, $or: [{isDeleted: null}, {isDeleted: false}]};
                 }
+                ration = await this.getStdRation(stdQuery);
+                if(ration == null) ration = await this.getCompleRation(userId,compilationId,code,ID);
             }
             if(isDef(ration)){
                 if (ration.type === 'std') {
@@ -62,7 +65,28 @@ class SearchDao{
         }
         return ration;
     }
-
+    async getCompleRation(userId,compilationId,code,ID){
+        let ration = null;
+        let compleQuery = {userId: userId, compilationId: compilationId, code: code, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]};
+        if(ID){
+            compleQuery.ID = ID;
+        }
+        let compleRation = await compleRationModel.findOne(compleQuery);
+        if(isDef(compleRation)){
+            ration = compleRation._doc;
+            ration.type = 'complementary';
+        }
+        return ration
+    }
+    async getStdRation(query){
+        let ration = null;
+        let stdRation = await stdRationModel.findOne(query);
+        if(isDef(stdRation)){
+            ration = stdRation._doc;
+            ration.type = 'std';
+        }
+        return ration;
+    }
     //@param {Object}skip({std: Number, comple: Number})
     async findRation(userId, compilationId, rationRepId, keyword, skip, callback){
         //每次限制结果数

+ 2 - 0
modules/users/models/engineering_lib_model.js

@@ -7,6 +7,7 @@
  */
 import mongoose from "mongoose";
 import BaseModel from "../../common/base/base_model";
+let _ = require('lodash');
 
 class EngineeringLibModel extends BaseModel {
     /**
@@ -44,6 +45,7 @@ class EngineeringLibModel extends BaseModel {
         // 查找对应的id数据
         let condition = {visible:true,valuationID: {"$in": valuationIDs}};
         let engineeringLibList = await this.findDataByCondition(condition,null,false);
+        engineeringLibList = _.sortBy(engineeringLibList,'seq');
         engineeringLibList = JSON.parse(JSON.stringify(engineeringLibList));
         // 组合计价规则id对应专业工程标准库数据
         let engineeringLib = {};

+ 1 - 0
web/building_saas/main/html/main.html

@@ -1199,6 +1199,7 @@
                 </div>
                 <div class="modal-footer">
                     <a href="javascript:void(0);" id="glj_selected_conf" class="btn btn-primary">确定</a>
+                    <a href="javascript:void(0);" id="replace_next_btn" class="btn btn-primary">下一步</a>
                     <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
                 </div>
             </div>

+ 5 - 3
web/building_saas/main/js/models/ration.js

@@ -395,9 +395,11 @@ var Ration = {
             let mainTree = project.mainTree;
             let nodeInfo =[];
             let refershNodes = [];
-            if(libIDs == null){
-                return;
-            }
+            if(libIDs == null) return;
+
+            //设置定额库的优先级,默认先取选中的定额库,如果没有再取default定额库
+            let selectedLib = sessionStorage.getItem("stdRationLib");
+            selectedLib&&selectedLib!='undefined'?libIDs.unshift(selectedLib):libIDs.unshift(defaultLibID);
             for(let r of recodes){
                 let needInstall = false;
                 if(projectObj.project.isInstall()) {//如果是安装工程,要看需不需要生成安装增加费

+ 1 - 1
web/building_saas/main/js/views/project_view.js

@@ -641,7 +641,7 @@ var projectObj = {
                 libID = rationLibObj.compleRationLibId;
             }
             if(!rationLibObj.tree){
-                sessionStorage.setItem('stdRationLib', libID);
+                if(isDef(libID)) sessionStorage.setItem('stdRationLib', libID);
                 rationLibObj.doAfterGetRationTree = function () {
                     this.locateAtRation(libID, code);
                     this.doAfterGetRationTree = null;

+ 1 - 0
web/building_saas/main/js/views/std_ration_lib.js

@@ -343,6 +343,7 @@ var rationLibObj = {
         me.loadSectionRations(sectionNode && sectionNode.children.length === 0 ? sectionNode.data.ID : null);
     },
     locateAtRation: function(libID, code){
+        if(!isDef(libID)) return;
         let me = rationLibObj;
         if ($('#rationSearchResult').is(':visible')) {
             $('#rationSearchResult a').click();

+ 68 - 36
web/over_write/js/chongqing_2018.js

@@ -81,6 +81,9 @@ function overwriteRationCalcBases (taxType){
         rationCalcBases['市场价主材费'] = function (node, isTender) {
             return calcTools.rationBaseFee(node, [gljType.MAIN_MATERIAL], priceTypes.ptMarketPrice, isTender);
         };
+        rationCalcBases['市场价设备费'] = function (node, isTender) {
+            return calcTools.rationBaseFee(node, [gljType.EQUIPMENT], priceTypes.ptMarketPrice, isTender);
+        };
         rationCalcBases['人工工日'] = function (node, isTender) {
             return calcTools.labourDays(node, isTender);
         };
@@ -168,45 +171,74 @@ function overwriteRationCalcBases (taxType){
         rationCalcBases['暂估材料费'] = function (node, isTender) {
             return calcTools.estimateFee(node, true, isTender);
         };
-        // rationCalcBases['分包定额施工机具费'] = function (node, isTender) {
-        //     if (node.data.isSubcontract)
-        //         return calcTools.rationBaseFee(node, [gljType.GENERAL_MACHINE, gljType.INSTRUMENT, gljType.OTHER_MACHINE_USED], priceTypes.ptBasePrice, isTender)
-        //     else
-        //         return 0;
-        // };
+        rationCalcBases['分包定额基价人工费'] = function (node, isTender) {
+            if (node.data.isSubcontract)
+                return calcTools.rationBaseFee(node, [gljType.LABOUR], priceTypes.ptBasePrice, isTender)
+            else
+                return 0;
+        };
+        rationCalcBases['分包定额基价材料费'] = function (node, isTender) {
+            if (node.data.isSubcontract)
+                return calcTools.rationBaseFee(node, baseMaterialTypes, priceTypes.ptBasePrice, isTender)
+            else
+                return 0;
+        };
+        rationCalcBases['分包定额基价机械费'] = function (node, isTender) {
+            if (node.data.isSubcontract)
+                return calcTools.rationBaseFee(node, baseMachineTypes, priceTypes.ptBasePrice, isTender)
+            else
+                return 0;
+        };
+        rationCalcBases['分包主材费'] = function (node, isTender) {
+            if (node.data.isSubcontract)
+                return calcTools.rationBaseFee(node, [gljType.MAIN_MATERIAL], priceTypes.ptMarketPrice, isTender)
+            else
+                return 0;
+        };
+        rationCalcBases['分包设备费'] = function (node, isTender) {
+            if (node.data.isSubcontract)
+                return calcTools.rationBaseFee(node, [gljType.EQUIPMENT], priceTypes.ptMarketPrice, isTender)
+            else
+                return 0;
+        };
+        rationCalcBases['分包人工工日'] = function (node, isTender) {
+            if (node.data.isSubcontract)
+                return calcTools.labourDays(node, isTender)
+            else
+                return 0;
+        };
     };
 };
 //code为标准接口所需,值是字典规定的
-var cpFeeTypes2018 = [
-    {type: 'rationUnitPrice', name: '定额综合单价', code: '1800'},
-    {type: 'labour', name: '人工费', code: '101'},
-    {type: 'material', name: '材料费', code: '201'},
-    {type: 'machine', name: '施工机具使用费', code: '301'},
-    {type: 'mainMaterial', name: '主材费', code: '501'},
-    {type: 'manage', name: '企业管理费', code: '600'},
-    {type: 'profit', name: '利润', code: '700'},
-    {type: 'risk', name: '一般风险费', code: '1000'},
-    {type: 'labourDiff', name: '人工价差', code: '104'},
-    {type: 'materialDiff', name: '材料价差', code: '203'},
-    {type: 'machineDiff', name: '施工机具使用价差', code: '304'},
-    {type: 'otherRisk', name: '其他风险费', code: '1800'},
-    {type: 'unratedMaterial', name: '未计价材料费', code: '1800'},
-    {type: 'organizeMeasures', name: '组织措施费', code: '1200'},
-    {type: 'safeCivilization', name: '安全文明施工费', code: '1204'},
-    {type: 'document', name: '建设工程竣工档案编制费', code: '10041'},
-    {type: 'acceptance', name: '住宅工程质量分户验收费', code: '1206'},
-    {type: 'forceFee', name: '规费', code: '800'},
-    {type: 'tax', name: '税金', code: '900'},
-    {type: 'VAT', name: '增值税', code: '1800'},
-    {type: 'surtax', name: '附加税', code: '1800'},
-    {type: 'environmentTax', name: '环境保护税', code: '1800'},
-    {type: 'common', name: '工程造价', code: '1'}
-];
-
-if(typeof cpFeeTypes !== 'undefined'){
-    cpFeeTypes.splice(0, cpFeeTypes.length);
-    for (let e of cpFeeTypes2018) cpFeeTypes.push(e);
-}
+(function overwriteFeeTypes() {
+    if (typeof cpFeeTypes == 'undefined') return;
+    cpFeeTypes = [
+        {type: 'rationUnitPrice', name: '定额综合单价', code: '1800'},
+        {type: 'labour', name: '人工费', code: '101'},
+        {type: 'material', name: '材料费', code: '201'},
+        {type: 'machine', name: '施工机具使用费', code: '301'},
+        {type: 'mainMaterial', name: '主材费', code: '501'},
+        {type: 'equipment', name: '设备费', code: '502'},
+        {type: 'manage', name: '企业管理费', code: '600'},
+        {type: 'profit', name: '利润', code: '700'},
+        {type: 'risk', name: '一般风险费', code: '1000'},
+        {type: 'labourDiff', name: '人工价差', code: '104'},
+        {type: 'materialDiff', name: '材料价差', code: '203'},
+        {type: 'machineDiff', name: '施工机具使用价差', code: '304'},
+        {type: 'otherRisk', name: '其他风险费', code: '1800'},
+        {type: 'unratedMaterial', name: '未计价材料费', code: '1800'},
+        {type: 'organizeMeasures', name: '组织措施费', code: '1200'},
+        {type: 'safeCivilization', name: '安全文明施工费', code: '1204'},
+        {type: 'document', name: '建设工程竣工档案编制费', code: '10041'},
+        {type: 'acceptance', name: '住宅工程质量分户验收费', code: '1206'},
+        {type: 'forceFee', name: '规费', code: '800'},
+        {type: 'tax', name: '税金', code: '900'},
+        {type: 'VAT', name: '增值税', code: '1800'},
+        {type: 'surtax', name: '附加税', code: '1800'},
+        {type: 'environmentTax', name: '环境保护税', code: '1800'},
+        {type: 'common', name: '工程造价', code: '1'}
+    ];
+})();