瀏覽代碼

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

zhongzewei 7 年之前
父節點
當前提交
bcc0c25e42

+ 1 - 1
modules/all_models/tpl_tree_node.js

@@ -30,7 +30,7 @@ let TplNodeSchema = new Schema({
 let RptTplTreeSchema = new Schema({
     compilationId: String,  //编办的ObjectId
     engineerId: Number,     //工程专业Id(参考 /modules/common/const/engineering.js)
-    userId: Number,         //userId,如果是标准模板,则为-100
+    userId: String,        //用户名的object_id串
     properties: [],         //这是一个预留的属性,假定未来还会有不同的划分细节(如:招标/投标/清单 ... etc)
     name: String,           //显示名称
     released: Boolean,      //是否已发布

+ 2 - 0
modules/fee_rates/facade/fee_rates_facade.js

@@ -189,6 +189,8 @@ async function getFeeRateData(projectID) {
     }
     try {
         //
+      /*  let getProjectGLJ = +new Date();
+        console.log("取项目工料机数据-----"+(getProjectGLJ - getenderData));*/
         let project =  await projectsModel.findOne({ID:projectID});
         if (project&&project.property&&project.property.feeFile){
             let feeRateData = await feeRateFileModel.findOne({'ID':project.property.feeFile.id,deleteInfo:null});

+ 4 - 4
modules/glj/controllers/glj_controller.js

@@ -52,7 +52,10 @@ class GLJController extends BaseController {
      * @param callback
      */
     getData(projectID, callback){
+        let start = +new Date();
         getGLJListByProjectID(projectID).then(function(result){
+            let end = +new Date();
+            console.log("项目工料机模块取数据总时间-----"+(end - start));
             callback(result.err,consts.projectConst.PROJECTGLJ,result.data);
         })
     }
@@ -618,7 +621,6 @@ async function getGLJListByProjectID(projectId){
         if (unitPriceFileId <= 0) {
             throw '没有对应的单价文件';
         }
-        let getUnitPriceIDTime = +new Date();
         // 获取使用该单价文件的项目数据
         let tenderData = await ProjectModel.getTenderByUnitPriceFileId(unitPriceFileId);
         let usedTenderList = [];
@@ -630,12 +632,10 @@ async function getGLJListByProjectID(projectId){
                 usedUnitPriceInfo.id = tmp.property.unitPriceFile.id;
             }
         }
-
+        responseData.data.gljList = gljList;
         // 先获取对应标段的项目工料机数据
         let gljListModel = new GLJListModel();
         let [gljList, mixRatioConnectData,mixRationMap] = await gljListModel.getListByProjectId(projectId, unitPriceFileId);
-        let getProjectGLJ = +new Date();
-        console.log("取项目工料机数据-----"+(getProjectGLJ - getUnitPriceIDTime));
         responseData.data.gljList = gljList;
         responseData.data.mixRatioConnectData = mixRatioConnectData;
         responseData.data.mixRatioMap = mixRationMap;

+ 14 - 45
modules/glj/models/glj_list_model.js

@@ -78,19 +78,16 @@ class GLJListModel extends BaseModel {
      */
     async getListByProjectId(projectId, unitPriceFileId) {
         let gljData = null;
-        let decimal =await decimal_facade.getProjectDecimal(projectId);
-        let quantity_decimal = decimal&&decimal.glj.quantity?decimal.glj.quantity:6;//取消耗量保留小数据位,默认6位
+        /*let decimal =await decimal_facade.getProjectDecimal(projectId);
+        let quantity_decimal = decimal&&decimal.glj.quantity?decimal.glj.quantity:6;//取消耗量保留小数据位,默认6位*/
         let mixRatioConnectData = {};
         let mixRationMap={};
         let keyMap={};
         try {
-            let startTime = +new Date();
             // 首先获取对应标段下所有的项目工料机数据
             let condition = {project_id: projectId};
             let fields = {_id: 0};
             gljData = await this.db.find(condition, fields);
-            let getgljDataTime = +new Date();
-            console.log("取工料机列表时间-----"+(getgljDataTime - startTime));
             // 没有数据则直接返回空
             if (gljData.length <= 0) {
                 throw '无数据';
@@ -99,8 +96,6 @@ class GLJListModel extends BaseModel {
             // 获取标段设置的单价文件数据
             let unitPriceModel = new UnitPriceModel();
             let unitPriceList = await unitPriceModel.getDataByFileId(unitPriceFileId);
-            let getUnitPriceListTime = +new Date();
-            console.log("获取标段设置的单价文件数据时间-----"+(getUnitPriceListTime - getgljDataTime));
             // 整理获取工料机ID list
             let gljIdList = [];
             for(let tmp of gljData) {
@@ -113,12 +108,9 @@ class GLJListModel extends BaseModel {
                 projectID: projectId
                // projectGLJIDList: gljIdList 这里是取所有项目工料机,所以也是取所有定额工料机,不需要根据项目工料机ID再过滤
             };
-            let quantityData = await RationGLJFacade.getQuantityByProjectGLJ(condition);
-            let getQuantity = +new Date();
-            console.log("取第一次消耗量时间-----"+(getQuantity - getUnitPriceListTime));
-            let rationTypeQuantity = await RationGLJFacade.getRationTypeGLJQuantity(projectId);
-            let getrationTypeQuantity = +new Date();
-            console.log("取第二次消耗量时间-----"+(getrationTypeQuantity - getQuantity));
+            //为了提高性成计算消耗量功能改成了在前端计算
+           /* let quantityData = [];//await RationGLJFacade.getQuantityByProjectGLJ(condition); 为了提高性成计算消耗量功能改成了在前端计算
+            let rationTypeQuantity = [];//await RationGLJFacade.getRationTypeGLJQuantity(projectId);
             let quantityList = {};
             // 整理数据 得到总定额消耗量
             for (let tmp of quantityData) {
@@ -141,14 +133,14 @@ class GLJListModel extends BaseModel {
                 }else {
                     quantityList[rq_key] = scMathUtil.roundTo(quantityList[rq_key]+rq_quantity,-quantity_decimal);
                 }
-            }
+            }*/
             // 整理获取有组成物的项目工料机的数据
             let connect_keys = [];
             for(let tmp of gljData) {
                 // 有组成物的类型才查找
                 let key = keyMap[tmp.id];
-                if (quantityList[key]!=undefined&&(tmp.type === GLJTypeConst.CONCRETE || tmp.type === GLJTypeConst.MORTAR ||
-                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE|| tmp.type === GLJTypeConst.MAIN_MATERIAL)){
+                if (tmp.type === GLJTypeConst.CONCRETE || tmp.type === GLJTypeConst.MORTAR ||
+                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE|| tmp.type === GLJTypeConst.MAIN_MATERIAL){
                     connect_keys.push(key);
                 }
             }
@@ -159,23 +151,18 @@ class GLJListModel extends BaseModel {
                 let mixRatioModel = new MixRatioModel();
                 condition = {connect_key: {"$in": connect_keys}, unit_price_file_id: unitPriceFileId};
                 let mixRatioList = await mixRatioModel.findDataByCondition(condition, null, false);
-                let getMixRatio = +new Date();
-                console.log("取组成物数据时间-----"+(getMixRatio - getQuantity));
-
                 for (let tmp of mixRatioList) {
                    let t_index = tmp.connect_key;
-                   let consumption=parseFloat(tmp.consumption);
                    let m_index = this.getIndex(tmp,['code','name','specs','unit','type']);
-                   let r_quantity = quantityList[t_index]?quantityList[t_index]:0;
+                   /*
+                    let consumption=parseFloat(tmp.consumption);
+                    let r_quantity = quantityList[t_index]?quantityList[t_index]:0;
                    if(quantityList[m_index]!==undefined){
                        quantityList[m_index]=quantityList[m_index]+r_quantity*consumption;
                    }else {
                        quantityList[m_index] = r_quantity*consumption;
                    }
-                    quantityList[m_index] = scMathUtil.roundTo(quantityList[m_index],-quantity_decimal);
-                /*    totalComposition[t_index] = totalComposition[t_index] === undefined ? consumption :
-                        totalComposition[t_index] + consumption;
-                    totalComposition[t_index] = scMathUtil.roundTo(totalComposition[t_index], -quantity_decimal);*/
+                    quantityList[m_index] = scMathUtil.roundTo(quantityList[m_index],-quantity_decimal);*/
                     if (mixRatioData[t_index] !== undefined) {
                         mixRatioData[t_index].push(tmp);
                     } else {
@@ -194,7 +181,7 @@ class GLJListModel extends BaseModel {
                 }
             }
             // 组合单价数据
-            gljData = this.combineData(gljData, unitPriceList, quantityList, mixRatioData, totalComposition);
+            gljData = this.combineData(gljData, unitPriceList, {}, mixRatioData, totalComposition);
             // 排序
             gljData.sort(function (a, b) {
                 a.unit_price = a.unit_price === null ? 0 : a.unit_price;
@@ -247,11 +234,7 @@ class GLJListModel extends BaseModel {
             }
             let gljId = glj.glj_id + '';
             let projectGljId = glj.id + '';
-            // 消耗量赋值
-         /*   glj.quantity = quantityList[projectGljId] !== undefined ? quantityList[projectGljId] : 0;
-            glj.quantity = totalComposition[g_index] !== undefined ? totalComposition[g_index] : glj.quantity;
-            glj.quantity = compositionConsumption[g_index] !== undefined ?  glj.quantity + compositionConsumption[g_index] : glj.quantity;
-            glj.quantity = scMathUtil.roundTo(parseFloat(glj.quantity), -3);*/
+
             glj.quantity = quantityList[g_index]?quantityList[g_index]:0;
             // 组成物数据
             gljList[index].ratio_data = mixRatioData[g_index] !== undefined ? mixRatioData[g_index] : [];
@@ -265,20 +248,6 @@ class GLJListModel extends BaseModel {
         let glj_basePrice = scMathUtil.roundTo(parseFloat(glj.unit_price.base_price), -2);
         glj.unit_price.base_price = glj_basePrice;
         glj.unit_price.market_price = scMathUtil.roundTo(parseFloat(glj.unit_price.market_price), -2);
-        // 计算调整基价
-     /*   switch (glj.unit_price.type + '') {
-            // 人工: 调整基价=基价单价*调整系数
-            case GLJTypeConst.LABOUR:
-                glj.adjust_price = scMathUtil.roundTo(parseFloat(glj.adjustment * glj_basePrice), -2);
-                break;
-            // 机械类型的算法
-            case GLJTypeConst.MACHINE:
-                console.log('机械');
-                break;
-            // 材料、主材、设备
-            default:
-                glj.adjust_price = glj.unit_price.base_price;
-        }*/
     }
 
     /**

+ 18 - 3
modules/main/controllers/project_controller.js

@@ -74,8 +74,8 @@ module.exports = {
         }
         res.json(result);
     },
-    updateNodes:function (req,res) {
-        var data = JSON.parse(req.body.data);
+    updateNodes:async function (req,res) {
+    /*    var data = JSON.parse(req.body.data);
         project_facade.updateNodes(data, function (err, message, result) {
             if (err) {
                 logger.err(err);
@@ -83,7 +83,22 @@ module.exports = {
             } else {
                 callback(req, res, err, message, result);
             }
-        });
+        });*/
+        let result={
+            error:0
+        }
+        try {
+            let data = req.body.data;
+            data = JSON.parse(data);
+            let resultData= await project_facade.updateNodes(data);
+            result.data=resultData;
+        }catch (err){
+            logger.err(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        res.json(result);
+
     },
     calcInstallationFee:async function(req,res){
         let result={

+ 38 - 2
modules/main/facade/project_facade.js

@@ -119,8 +119,44 @@ function generateTasks(data,userID) {
     return tasks;
 }
 
+async function updateNodes(datas){
+    let nodeGroups = _.groupBy(datas,'type');
+    let rationTasks = [];
+    let billTasks = [];
+    for(let type in nodeGroups){
+        for(let node of nodeGroups[type]){
+            if(type == projectConsts.BILLS){
+                billTasks.push(getTask(node));
+            }else if(type == projectConsts.RATION){
+                rationTasks.push(getTask(node));
+            }
+        }
+    }
+
+    if(rationTasks.length>0){
+         await ration_model.model.bulkWrite(rationTasks);
+    }
+    if(billTasks.length>0){
+         await  bill_model.model.bulkWrite(billTasks);
+    }
 
-function updateNodes(datas,callback) {
+    function getTask(node) {
+        let task={
+            updateOne:{
+                filter:{
+                    projectID: node.data.projectID,
+                    ID: node.data.ID,
+                    deleteInfo: null
+                },
+                update :node.data
+            }
+        };
+       return task;
+    }
+}
+
+
+/*function updateNodes(datas,callback) {
     let tasks = [];
     for(let node of datas){
         tasks.push(updateOne(node))
@@ -145,7 +181,7 @@ function updateNodes(datas,callback) {
             }
         }
     }
-}
+}*/
 
 //data = {feeRateID:111111,projectID:1245}; type = feeRate
 async function markUpdateProject(data,type) {

+ 4 - 1
modules/main/facade/ration_facade.js

@@ -40,7 +40,7 @@ async function addNewRation(data) {
     }
     let newRation =await insertNewRation(data.newData,stdRation,data.calQuantity);
     let addRationGLJTime = +new Date();
-    console.log("插入新定额时间-------------------------------"+(addRationGLJTime - startTime));
+    console.log("插入新定额时间-------------------------------"+(addRationGLJTime - stdRationTime));
     if(stdRation){
         return await addRationSubList(stdRation,newRation,data.needInstall);
     }else {
@@ -90,8 +90,11 @@ async function insertNewRation(newData,std,calQuantity) {//插入新的定额
     }
     let addRationGLJTime = +new Date();
     console.log("计算消耗量时间-------------------------------"+(addRationGLJTime - startTime));
+    console.log(newData);
     let newRation = await ration_model.model.create(newData);
     return newRation;
+    /*ration_model.model.create(newData);
+    return newData;*/
 }
 
 async function replaceRations(userID,data) {

+ 3 - 1
modules/main/models/project.js

@@ -97,7 +97,7 @@ Project.prototype.save = function(datas, callback){
 Project.prototype.getData = function(projectID, callback){
     var functions = [];
     var itemName;
-
+    let firstTime = +new Date();
     for (itemName in moduleMap){
         functions.push((function(itemName){
             return function (cb) {
@@ -113,6 +113,8 @@ Project.prototype.getData = function(projectID, callback){
 
     asyncTool.parallel(functions, function(err, results) {
         if (!err){
+            let lastTime = +new Date();
+            console.log('最后加载时间---------------'+(lastTime - firstTime));
             callback(null, '', results)
         }
         else{

+ 3 - 2
modules/pm/models/project_model.js

@@ -595,8 +595,9 @@ ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function (unitPriceFile
         return result;
     }
 
-    let condition = {projType: 'Tender', "property.unitPriceFile.id": unitPriceFileId};
-    result = await Projects.find(condition);
+    //let condition = {projType: 'Tender', "property.unitPriceFile.id": unitPriceFileId};
+    let condition = {"property.unitPriceFile.id": unitPriceFileId,deleteInfo:null};
+    result = await Projects.find(condition,['name','property']);
 
     return result;
 };

+ 2 - 0
modules/ration_glj/facade/ration_glj_facade.js

@@ -107,6 +107,8 @@ function combineQuantity(results, rations) {
         resultList.push(tmp);
     }
     return resultList;
+
+    return resultList;
 }
 
 

+ 1 - 1
modules/reports/controllers/rpt_tpl_controller.js

@@ -27,7 +27,7 @@ let callback = function(req, res, err, message, data){
 
 let mExport = {
     getDftTemplates(req, res) {
-        let filter = {"userId": -100, "$or": [{"isDeleted": null}, {"isDeleted": false} ]};
+        let filter = {"userId": "-100", "$or": [{"isDeleted": null}, {"isDeleted": false} ]};
         TreeNodeModel.find(filter, '-_id', function(err, data){
             if (err) {
                 callback(req,res, true,"", null);

+ 1 - 1
public/web/tree_sheet/tree_sheet_helper.js

@@ -160,7 +160,7 @@ var TREE_SHEET_HELPER = {
                 if(colSetting.data.autoHeight == true){
                     colSetting.setAutoHeight(cell,node);
                 }
-                if(sheet.name()=='mainSheet'&&gljOprObj.isInstallationNode(node)){//如果是通过安装增加费自动生成的,都是只读类型
+                if(colSetting.editChecking&&colSetting.editChecking(node)){
                     cell.locked(true);
                 }else if (colSetting.readOnly) {
                     if (Object.prototype.toString.apply(colSetting.readOnly) === "[object Function]") {

+ 3 - 3
web/building_saas/css/main.css

@@ -367,9 +367,9 @@ div.resize{
     width: 100%;
     cursor: s-resize;
 }
-.zlfb-check{
-    margin-left: 0;
-}
+/*.zlfb-check{
+    margin-left: 20px;
+}*/
 legend.legend{
     display:block;
     width:auto;

+ 10 - 1
web/building_saas/main/js/models/bills.js

@@ -349,11 +349,14 @@ var Bills = {
             return node.downLevel();
         };
 
-        bills.prototype.updateField = function (node, field, newValue) {
+        bills.prototype.updateField = function (node, field, newValue,toBX) {//当toBX为true时类型改为补项
             calcFees.setFee(node.data, field, newValue);
             let updateData = [];
             let data = {'ID': node.getID(), 'projectID': this.project.ID()};
             data[field] = newValue;
+            if(toBX == true){
+                data.type = billType.BX
+            }
             updateData.push({'updateType': 'ut_update', 'updateData': tools.formatBillsUpdateData(data)});
             this.project.pushNow('updateBills', this.getSourceType(), updateData);
         };
@@ -505,6 +508,12 @@ var Bills = {
                 return false;
             }
         };
+        bills.prototype.isBX = function (node) {//判读是否属于补项
+            if(node && node.sourceType == ModuleNames.bills&&node.data.type==billType.BX){
+                return  true;
+            }
+            return false;
+        };
         bills.prototype.isTechMeasure = function (node) {//判读是否属于技术措施项目部分
             let techMeasureCheck = function (checkNode) {
                 if(isFlag(checkNode.data)&&checkNode.data.flagsIndex.fixed.flag==fixedFlag.CONSTRUCTION_TECH){

+ 4 - 7
web/building_saas/main/js/models/calc_program.js

@@ -1135,7 +1135,10 @@ class CalcProgram {
             return;
         };
         $.bootstrapLoading.start();
+        let startTime = +new Date();
         me.project.updateNodes(dataArr, function (data) {
+            let endShowTime = +new Date();
+            console.log(`保存所需时间——${endShowTime - startTime}`);
             if(callback){
                 callback(data);
             };
@@ -1403,9 +1406,7 @@ class CalcProgram {
     calculate(treeNode, calcParents = true, calcFormulas = true){
         let me = this;
         let changedNodes = [];
-
         me.innerCalc(treeNode, changedNodes);
-
         if (treeNode.changed) {
             // 计算父结点
             if (calcParents){
@@ -1415,7 +1416,6 @@ class CalcProgram {
                     curNode = curNode.parent;
                 };
             };
-
             // 父结点算完,再计算所有的公式结点(必须先算完父结点,再算公式结点)
             if (calcFormulas) {
                 me.calcFormulaNodes(changedNodes);
@@ -1434,7 +1434,6 @@ class CalcProgram {
     calcAllNodes(calcType = calcAllType.catAll){
         let me = this;
         let changedNodes = [];
-
         function calcNodes(nodes) {
             for (let node of nodes) {
                 if (node.children.length > 0) {
@@ -1446,9 +1445,7 @@ class CalcProgram {
                 };
             }
         };
-
         calcNodes(me.project.mainTree.roots);
-
         me.calcFormulaNodes(changedNodes);
         return changedNodes;
     };
@@ -1507,7 +1504,7 @@ class CalcProgram {
             let curChangeds = me.calculate(node);
             mergeArr(allChangedNodes, curChangeds);
         };
-
+        let endShowTime = +new Date();
         me.saveNodes(allChangedNodes, callback);
     };
 

+ 3 - 2
web/building_saas/main/js/models/installation_fee.js

@@ -213,6 +213,7 @@ var installation_fee = {
             let billSerialMap = {};
             let FBMap = {};//保存分部下对应的补项
             let usedBXMap = {};//有使用到的补项
+            let startTime =  +new Date();
             if(engineering!=engineeringType.BUILD_IN){//如果不是安装工程,则不用计算
                 if(callback) callback(false);
                 return;
@@ -295,7 +296,6 @@ var installation_fee = {
                 $.bootstrapLoading.start();
                 CommonAjax.post("/project/calcInstallationFee",updateData,function (data) {
                     //提交后台成功后所做的操作,删除要先删除定额,再删除清单,添加要先添加清单再添加定额
-                    console.log(data);
                     project.ration_glj.addDatasToList(data.add);//添加插入的定额
                     for(let ur of data.update){
                         let glj = project.ration_glj.getDataByID(ur.ID);
@@ -309,6 +309,8 @@ var installation_fee = {
                         addNewNodes(updateData);
                     });
                     setTreeSelection(selectedNode);
+                    let endTime =  +new Date();
+                    console.log(`计算安装增加费时间——${endTime - startTime}`);
                     projectObj.project.projectGLJ.loadData(function () {
                         cbTools.refreshFormulaNodes();
                         if(callback){
@@ -345,7 +347,6 @@ var installation_fee = {
                     newAddNode.push(newNode);
                     project.Ration.datas.push(nr);
                 }
-                console.log("add nodes");
                 TREE_SHEET_HELPER.refreshTreeNodeData(controller.setting, controller.sheet, newAddNode, false);
             }
 

+ 47 - 47
web/building_saas/main/js/models/project_glj.js

@@ -260,6 +260,9 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,cb
     let pgljID = from=="rg"?recode.projectGLJID:recode.id;//和定额工料机统一接口,项目工料机ID取值不一样
     let glj = _.find(projectGljs, {'id': pgljID});
     if (glj) {
+        if(glj.unit_price[updateField] == newval){
+            return;
+        }
         let data = {id: glj.unit_price.id, field: updateField, newval: newval,project_id:glj.project_id};
         let callback = function (data) {
             if (updateField == 'base_price') {
@@ -657,59 +660,75 @@ ProjectGLJ.prototype.getShortNameByID = function (ID) {
 ProjectGLJ.prototype.calcQuantity  = function (){
     let project_gljs = this.datas.gljList;
     let mixRatioConnectData = this.datas.mixRatioConnectData;
-    let mixRatioSubdivisionMap = {};
-    let mixRatioTechMap={};
+    let mixRatioMap = this.datas.mixRatioMap;
+    let rations = projectObj.project.Ration.datas;
+    let rationMap = _.indexBy(rations,'ID');
+    let quantityMap={};
+    let rationGljGroup = _.groupBy(projectObj.project.ration_glj.datas,'projectGLJID')
+    let q_decimal = getDecimal("glj.quantity");
     for(let pglj of project_gljs ){
-        if(pglj.quantity !== 0 && pglj.quantity !== '0'){
-            let result = this.getQuantityPerGLJ(pglj,mixRatioSubdivisionMap,mixRatioTechMap);
+        let pg_index = gljOprObj.getIndex(pglj,gljKeyArray);
+        pglj.subdivisionQuantity = 0;
+        pglj.techQuantity = 0;
+        pglj.quantity = 0;
+        if(rationGljGroup[pglj.id]){
+            let result = this.getQuantityPerGLJ(rationGljGroup[pglj.id],rations,rationMap,pglj,quantityMap);
             pglj.subdivisionQuantity = result.subdivisionQuantity;
             pglj.techQuantity = result.techQuantity;
+            pglj.quantity = result.quantity;
         }
+        quantityMap[pg_index] = pglj;
     }
     //计算做为组成物的消耗量
-    for(let pg of project_gljs ){
-        if(pg.quantity !== 0 && pg.quantity !== '0'){
-            let pg_index = gljOprObj.getIndex(pg,gljKeyArray);
-            if(mixRatioConnectData[pg_index]){
-                if(mixRatioSubdivisionMap[pg_index]){
-                    pg.subdivisionQuantity = scMathUtil.roundForObj(mixRatioSubdivisionMap[pg_index]+pg.subdivisionQuantity,getDecimal("glj.quantity"));
-                }
-                if(mixRatioTechMap[pg_index]){
-                    pg.techQuantity = scMathUtil.roundForObj(mixRatioTechMap[pg_index]+pg.techQuantity,getDecimal("glj.quantity"));
-                }
+    for(let pkey in mixRatioMap){
+        let mixRatioList = mixRatioMap[pkey];
+        for(let m of mixRatioList){
+            let m_index = gljOprObj.getIndex(m,gljKeyArray);
+            let m_glj = quantityMap[m_index];
+            let p_glj = quantityMap[pkey];
+            if(m_glj&&p_glj){
+                let quantity = scMathUtil.roundForObj(p_glj.quantity*parseFloat(m.consumption),q_decimal);
+                let techQuantity = scMathUtil.roundForObj(p_glj.techQuantity*parseFloat(m.consumption),q_decimal);
+                let subdivisionQuantity = scMathUtil.roundForObj(p_glj.subdivisionQuantity*parseFloat(m.consumption),q_decimal);
+                m_glj.quantity =  scMathUtil.roundForObj(m_glj.quantity+quantity,q_decimal);
+                m_glj.techQuantity =  scMathUtil.roundForObj(m_glj.techQuantity+techQuantity,q_decimal);
+                m_glj.subdivisionQuantity =  scMathUtil.roundForObj(m_glj.subdivisionQuantity+subdivisionQuantity,q_decimal);
             }
         }
     }
 
 }
 
-ProjectGLJ.prototype.getQuantityPerGLJ = function (pglj,mixRatioSubdivisionMap,mixRatioTechMap) {
+ProjectGLJ.prototype.getQuantityPerGLJ = function (ration_glj_list,rations,rationMap,pglj) {
     let billIDs =   projectObj.project.Bills.getSubdivisionProjectLeavesID();//取分部分项上的所有叶子清单ID
-    let tech_billIDS =  projectObj.project.Bills.getTechLeavesID();//取所有技术措施项目叶子清单ID
-    let ration_glj_list = projectObj.project.ration_glj.datas;
+    let tech_billIDS =  projectObj.project.Bills.getTechLeavesID();//取所有技术措施项目叶子清单IDs
     let mixRatioMap = this.datas.mixRatioMap;
-    let rations = projectObj.project.Ration.datas;
     let q_decimal = getDecimal("glj.quantity");
     let result={};
-    let sum = 0;
-    let tech_sum = 0;
+    let quantitySum=0;//工料机汇总消耗量
+    let sum = 0;//分部分项总消耗量
+    let tech_sum = 0;//技术措施总消耗量
     for(let rg of ration_glj_list){
-        if(rg.projectGLJID==pglj.id){
+            let tem_ration = rationMap[rg.rationID];
+            let r_quantity = scMathUtil.roundForObj(tem_ration.quantity,q_decimal);
+            let glj_quantity = scMathUtil.roundForObj(rg.quantity, q_decimal);
+            if(!r_quantity){
+                continue;
+            }
+            let total = scMathUtil.roundForObj(glj_quantity*r_quantity, q_decimal);
+            quantitySum = scMathUtil.roundForObj(quantitySum+total,q_decimal);
             if(_.includes(billIDs,rg.billsItemID)){//计算分部分项
-               let total = calcQuantity(rg,mixRatioSubdivisionMap);
-               sum = scMathUtil.roundForObj(sum+total,q_decimal);
+                sum = scMathUtil.roundForObj(sum+total,q_decimal);
             }
             if(_.includes(tech_billIDS,rg.billsItemID)){//计算技术措施项目消耗量
-                let tech_total = calcQuantity(rg,mixRatioTechMap);
-                tech_sum = scMathUtil.roundForObj(tech_sum+tech_total,q_decimal);
+                tech_sum = scMathUtil.roundForObj(tech_sum+total,q_decimal);
             }
-        }
-
     }
     for(let ra of rations){//计算定额类型工料机的消耗量
         if(ra.type == rationType.gljRation&&ra.projectGLJID===pglj.id){
             let r_quantity = scMathUtil.roundForObj(ra.quantity,q_decimal);
             r_quantity = r_quantity?r_quantity:0;
+            quantitySum== scMathUtil.roundForObj(quantitySum+r_quantity,q_decimal);
             if(_.includes(billIDs,ra.billsItemID)){//计算分部分项
                 sum = scMathUtil.roundForObj(sum+r_quantity,q_decimal);
             }
@@ -721,25 +740,6 @@ ProjectGLJ.prototype.getQuantityPerGLJ = function (pglj,mixRatioSubdivisionMap,m
     }
     result.subdivisionQuantity = sum;
     result.techQuantity = tech_sum;
+    result.quantity = quantitySum;
     return result;
-
-    function calcQuantity(rg,quantityMap) { //计算工料机在所属定额下的总消耗量
-        let tem_ration = _.find(rations,{"ID":rg.rationID});
-        let total = parseFloat(gljOprObj.getTotalQuantity(rg,tem_ration));
-        let r_index = gljOprObj.getIndex(rg,gljKeyArray);
-        if(mixRatioMap.hasOwnProperty(r_index)){
-            let mixRatioList = mixRatioMap[r_index];
-            for(let m of mixRatioList){
-                let m_index = gljOprObj.getIndex(m,gljKeyArray);
-                let m_quantity = scMathUtil.roundForObj(total*m.consumption,q_decimal);
-                if(quantityMap[m_index]){
-                    quantityMap[m_index] = scMathUtil.roundForObj(quantityMap[m_index]+m_quantity,q_decimal);
-                }else {
-                    quantityMap[m_index] = m_quantity;
-                }
-            }
-        }
-        return total;
-    }
-
 } 

+ 4 - 2
web/building_saas/main/js/models/quantity_detail.js

@@ -571,7 +571,7 @@ var quantity_detail = {
             console.log(value);
             let needUpdateChildren = [];//需更新的子定额
             let gljNodes=[];//当定额工程量改变时需刷新的子工料机
-            if(node.children.length>0){//如果有子项
+            if(node.children.length>0){//如果有子项
                 for(let rationNode of node.children){
                     let EXPString = rationNode.data.quantityEXP+"";
                     if(EXPString.indexOf("QDL")!=-1){
@@ -614,7 +614,9 @@ var quantity_detail = {
                     if(project.Bills.isFBFX(node)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
                         project.installation_fee.calcInstallationFee(function (isChange) {
                             if(isChange){
-                                project.calcProgram.calcAllNodesAndSave();
+                                project.calcProgram.calcAllNodesAndSave(calcAllType.catAll,function () {
+                                    project.projectGLJ.loadData();
+                                });
                             }
                         });
                     }else {

+ 14 - 4
web/building_saas/main/js/models/ration.js

@@ -471,7 +471,6 @@ var Ration = {
                 $.bootstrapLoading.start();
                 CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,calQuantity:calQuantity,brUpdate:brUpdate,needInstall:needInstall},function (data) {
                     //更新缓存
-                    console.log(data);
                     me.datas.push(data.ration);
                     project.ration_glj.addDatasToList(data.ration_gljs);
                     project.ration_coe.addDatasToList(data.ration_coes);
@@ -487,7 +486,19 @@ var Ration = {
                     project.projectGLJ.loadData(function () {
                         project.ration_glj.addToMainTree(data.ration_gljs);
                         projectObj.mainController.refreshTreeNode([newNode], false);
-                        project.calcProgram.calcAndSave(newNode,function () {
+                        if(project.Bills.isFBFX(newNode)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
+                            let changeNodes = project.calcProgram.calculate(newNode);//先计算不保存,如果计算安装增加费后不用自动计算,则单独调用保存的方法
+                            project.installation_fee.calcInstallationFee(function (isChange) {
+                                if(isChange){
+                                   project.calcProgram.calcAllNodesAndSave();
+                                }else {
+                                    project.calcProgram.saveNodes(changeNodes);
+                                }
+                            });
+                        }else {
+                            project.calcProgram.calcAndSave(newNode);
+                        }
+                     /*   project.calcProgram.calcAndSave(newNode,function () {
                             if(project.Bills.isFBFX(newNode)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
                                 project.installation_fee.calcInstallationFee(function (isChange) {
                                     if(isChange){
@@ -495,10 +506,9 @@ var Ration = {
                                     }
                                 });
                             }
-                        });
+                        });*/
                         $.bootstrapLoading.end();
                     });
-                    console.log(data);
                 })
             }
 

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

@@ -375,7 +375,7 @@ var gljOprObj = {
         }
     },
     isInstallationNode:function(node){
-        if((node.sourceType == ModuleNames.ration&&node.data.type == rationType.install)||(node.sourceType == ModuleNames.bills&&node.data.type==billType.BX)){//是定额安装费类型或者补项
+        if(node.sourceType == ModuleNames.ration&&node.data.type == rationType.install){//是定额安装费类型时只读,原先是补项的时候也是控制只读的||(node.sourceType == ModuleNames.bills&&node.data.type==billType.BX)){//是定额安装费类型或者补项
             return true;
         }
         return false

+ 6 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -269,6 +269,12 @@ let MainTreeCol = {
                 return new GC.Spread.Sheets.CellTypes.CheckBox();
         }
     },
+    editChecking:function(node){
+        if(gljOprObj.isInstallationNode(node)){//如果是通过安装增加费自动生成的,都是只读类型
+            return true;
+        }
+        return false;
+    },
     setAutoHeight:function (cell,node) {//设置自动行高
         let displaySetting = projectObj.project.property.displaySetting;
         let billsAutoH = displaySetting && displaySetting.billsAutoHeight?displaySetting.billsAutoHeight:false;

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

@@ -385,6 +385,7 @@ projectGljObject={
         let value = info.newValue;
         if (!me.checkData(col,me.projectGljSetting,value)) {
             alert('输入的数据类型不对,请重新输入!');
+            me.refreshProjectGljRow(row);
             return ;
         }
         let callback=function (impactList) {

+ 34 - 14
web/building_saas/main/js/views/project_view.js

@@ -248,19 +248,21 @@ var projectObj = {
         return rst;
     },
     updateBillsCode: function (node, value) {
-        let project = projectObj.project;
+        let project = projectObj.project,me = this;
         let stdMatchCode, formatCode, matchs;
         let searchStdBillsAndUpdate = function (stdCode, formatCode) {
             let orgCode = node.data.code?node.data.code.substr(0, 9):"";
             if (stdCode === orgCode || projectInfoObj.projectInfo.engineeringInfo.bill_lib.length === 0) {
-                project.Bills.updateField(node.source, 'code', formatCode, true);
-                projectObj.mainController.refreshTreeNode([node], false);
+                normalUpdate(node,value);
             } else if (projectInfoObj.projectInfo.engineeringInfo.bill_lib.length > 0) {
                 let libId = projectInfoObj.projectInfo.engineeringInfo.bill_lib[0].id;
                 CommonAjax.post('/stdBillsEditor/getStdBillsByCode', {userId: userID, billsLibId: libId, code: stdCode}, function (data) {
                     if (data) {
                         //data.itemCharacter = pageCCOprObj.safeItemCharater(data.itemCharacter);
                         node.data.name = data.name;
+                        if(node.data.type == billType.BX){//从清单库中找到标准清单的话,要把补项改成分项
+                            node.data.type = billType.FX;
+                        }
                         pageCCOprObj.setItemContentNode(node, data.jobContent, data.itemCharacter, node.data.name);
                         if (/\//.test(data.unit)) {
                             let existB = projectObj.project.Bills.sameStdCodeBillsData(data.code);
@@ -282,13 +284,12 @@ var projectObj = {
                             projectObj.mainController.refreshTreeNode([node], false);
                         }
                     } else {
-                        project.Bills.updateField(node.source, 'code', formatCode, true);
-                        projectObj.mainController.refreshTreeNode([node], false);
+                        normalUpdate(node,value);
                     }
                 });
             }
         }
-        if(node.data.type==billType.FX||(node.data.type==billType.BILL&&node.source.children.length==0)){//是分项或者叶子清单的情况下才需要查找替换
+        if(node.data.type==billType.FX||node.data.type==billType.BX||(node.data.type==billType.BILL&&node.source.children.length==0)){//是分项、补项或者叶子清单的情况下才需要查找替换
             if (value&&value.length === 9 && /^[\d]+$/.test(value)) {
                 stdMatchCode = value;
                 formatCode = project.Bills.newFormatCode(stdMatchCode);
@@ -299,16 +300,31 @@ var projectObj = {
                 matchs = project.Bills.sameStdCode(stdMatchCode, node.data.code);
                 if (matchs.indexOf(value) === -1) {
                     searchStdBillsAndUpdate(stdMatchCode, value);
-                } else if (confirm('已存在该编码的清单,是否继续?')) {
-                    formatCode = project.Bills.newFormatCode(stdMatchCode, node.data.code);
-                    searchStdBillsAndUpdate(stdMatchCode, formatCode);
                     return;
+                } else {
+                   if (confirm('已存在该编码的清单,是否继续?')) {
+                       // formatCode = project.Bills.newFormatCode(stdMatchCode, node.data.code);
+                        searchStdBillsAndUpdate(stdMatchCode, value);
+                        return;
+                    }else {
+                       this.mainController.refreshTreeNode([node], false);
+                       return;
+                   }
                 }
             }
         }
-        project.Bills.updateField(node.source, 'code', value, true);
-        this.mainController.refreshTreeNode([node], false);
+        normalUpdate(node,value);
+
 
+        function normalUpdate(billnode,codeValue) {//在标准库中没有找到清单时改分项为补项再更新
+            let toBX = false;
+            if(billnode.data.type == billType.FX){
+                billnode.data.type = billType.BX;
+                 toBX = true;
+            }
+            project.Bills.updateField(billnode.source, 'code', codeValue, toBX);
+            me.mainController.refreshTreeNode([billnode], false);
+        }
     },
     updateRationCode: function (node, value) {
         if(!isDef(node.data.code) && (!isDef(value) || value.toString().trim() == '')){
@@ -555,6 +571,8 @@ var projectObj = {
             console.log(`get data时间——${mTime - startTime}`);
             if (!err) {
                 that.project.projectGLJ.calcQuantity();//计算分部分项和技术措施项目消耗量;
+                let quantityTime = +new Date();
+                console.log(`计算quantity时间——${quantityTime - mTime}`);
                 that.project.property = projectInfoObj.projectInfo.property;
                 //that.project.calcProgram.compileAllTemps();
                 that.project.calcBase.init(that.project);
@@ -584,6 +602,7 @@ var projectObj = {
                         col.data.formatter = '@';
                     }
                     col.setAutoHeight = MainTreeCol.getEvent("setAutoHeight");
+                    col.editChecking = MainTreeCol.getEvent("editChecking");
                     // 根据配置设置自动行高,在这里先做个标记,然后对每个单元格单独配置
                     if (col.data.field === 'name' || col.data.field === 'itemCharacterText' ||
                         col.data.field === 'jobContentText' || col.data.field === 'adjustState') {
@@ -623,12 +642,13 @@ var projectObj = {
                 that.mainSpread.bind(GC.Spread.Sheets.Events.ClipboardChanged, that.msClipboardChanged);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, that.onButtonClick);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, that.onCellDoubleClick);
-                let loadOtherStartTime = +new Date();
+                //let loadOtherStartTime = +new Date();
                 that.loadMainSpreadContextMenu();
                 that.loadFocusLocation();
-                let endTime = +new Date();
-                console.log(`其它时间——${endTime - loadOtherStartTime}`);
+
                 socketObject.connect();//连接socket服务器
+                let endTime = +new Date();
+                console.log(`其它时间——${endTime - endShowTime}`);
                 console.log("加载完成-----"+endTime);
                 console.log(`时间——${endTime - startTime}`);
                 that.project.projectMarkChecking();//是否需要重新进行造价计算