浏览代码

add gljUtil

zhangweicheng 7 年之前
父节点
当前提交
5f66a682bd

+ 4 - 3
modules/all_models/bills.js

@@ -42,9 +42,8 @@ let billsSchema = new Schema({
     isTender_Labour: Boolean,
     isTender_Labour: Boolean,
     isTender_Material: Boolean,
     isTender_Material: Boolean,
     isTender_Machine: Boolean,
     isTender_Machine: Boolean,
-    tenderTargetPrice: String, // Decimal
-    tenderTargetUnitPrice: String, // Decimal
-    tenderTargetUnitPrice: String, // Decimal
+    targetUnitFee:String,//目标单价
+    targetTotalFee:String,//目标合价
     //工作内容//zhong 2017-8-31
     //工作内容//zhong 2017-8-31
     jobContentText: String, //清单工作内容列显示文本, 减少第一次拉数据时的循环次数
     jobContentText: String, //清单工作内容列显示文本, 减少第一次拉数据时的循环次数
     jobContent: [subSchema.jobContentSchema],
     jobContent: [subSchema.jobContentSchema],
@@ -57,6 +56,8 @@ let billsSchema = new Schema({
     flags: [subSchema.flagsSchema],
     flags: [subSchema.flagsSchema],
     //消耗量调整系数字段
     //消耗量调整系数字段
     quantityCoe:subSchema.quantityCoeSchema,
     quantityCoe:subSchema.quantityCoeSchema,
+    //子目工程量调整系数
+    rationQuantityCoe:String,
     // 不调价
     // 不调价
     is_adjust_price: {type: Number,default: 0},
     is_adjust_price: {type: Number,default: 0},
     installationKey:String,//用来记录安装增加费的关联字段
     installationKey:String,//用来记录安装增加费的关联字段

+ 5 - 0
modules/all_models/ration.js

@@ -38,8 +38,13 @@ let rationSchema = new Schema({
     fees: [subSchema.feesSchema],
     fees: [subSchema.feesSchema],
     //消耗量调整系数字段
     //消耗量调整系数字段
     quantityCoe:subSchema.quantityCoeSchema,
     quantityCoe:subSchema.quantityCoeSchema,
+    //子目工程量调整系数
+    rationQuantityCoe:String,
+    tenderQuantity:String,//调整后工程量
     // 不调价
     // 不调价
     is_adjust_price: {type: Number,default: 0},
     is_adjust_price: {type: Number,default: 0},
+    targetUnitFee:String,//目标单价
+    targetTotalFee:String,//目标合价
     deleteInfo: deleteSchema,
     deleteInfo: deleteSchema,
     type: Number,                               // 1 定额、2 量价、3 工料机定额
     type: Number,                               // 1 定额、2 量价、3 工料机定额
     subType: Number,                            // 子类型:1人工、201材料、301机械、4主材、5设备
     subType: Number,                            // 子类型:1人工、201材料、301机械、4主材、5设备

+ 1 - 3
modules/all_schemas/bills_sub_schemas.js

@@ -10,9 +10,7 @@ var feesSchema = new Schema({
     unitFee: String, // Decimal. 单价
     unitFee: String, // Decimal. 单价
     totalFee: String, // Decimal. 合价
     totalFee: String, // Decimal. 合价
     tenderUnitFee: String, // Decimal. 调价后单价
     tenderUnitFee: String, // Decimal. 调价后单价
-    tenderTotalFee: String, // Decimal. 调价后合价
-    targetUnitFee:String,//目标单价
-    targetTotalFee:String//目标合价
+    tenderTotalFee: String // Decimal. 调价后合价
 });
 });
 
 
 // 标记字段
 // 标记字段

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

@@ -17,10 +17,11 @@ const displaySetting = {
     billsAutoHeight:true,
     billsAutoHeight:true,
     rationAutoHeight:false,
     rationAutoHeight:false,
     disPlayMainMaterial:true
     disPlayMainMaterial:true
-}
+};
 
 
 const tenderSetting = {
 const tenderSetting = {
-    gljPriceTenderCoe:1 //工料机单价调整系数
+    gljPriceTenderCoe:1, //工料机单价调整系数
+    calcPriceOption:'coeBase'//根据调整系数计算报价
 };
 };
 
 
 const calcOptions={
 const calcOptions={

+ 18 - 0
public/gljUtil.js

@@ -0,0 +1,18 @@
+/**
+ * Created by zhang on 2018/6/7.
+ */
+import fs from 'fs';
+let _= require('lodash');
+const scMathUtil = require('./scMathUtil').getUtil();
+
+let gljNodeUtil = null;
+let data = fs.readFileSync(__dirname + '/web/gljUtil.js', 'utf8', 'r');
+eval(data + ' ; gljNodeUtil = gljUtil; ');
+
+module.exports = {
+    calcProjectGLJQuantity :calcProjectGLJQuantity
+};
+
+function calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal) {
+    gljNodeUtil.calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal,_,scMathUtil);
+}

+ 150 - 0
public/web/gljUtil.js

@@ -0,0 +1,150 @@
+/**
+ * Created by zhang on 2018/6/7.
+ */
+
+let gljUtil = {
+    calcProjectGLJQuantity:function (projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal,_,scMathUtil) {
+        let project_gljs = projectGLJDatas.gljList;
+        let mixRatioMap = projectGLJDatas.mixRatioMap;
+        let rations = rationDatas;
+        let rationMap = _.indexBy(rations,'ID');
+        let quantityMap={},changeArray=[];
+        let rationGljGroup = _.groupBy(rationGLJDatas,'projectGLJID');
+        let [billIDs,tech_billIDS] = this.getSubdivisionAndTechBillsLeavesID(billsDatas);//分别取分部分项和技术措施项目的所有叶子清单ID
+        for(let pglj of project_gljs ){
+            let pg_index = this.getIndex(pglj,gljKeyArray);
+            pglj.subdivisionQuantity = 0;
+            pglj.techQuantity = 0;
+            pglj.quantity = 0;
+            let gljGroup = rationGljGroup[pglj.id]?rationGljGroup[pglj.id]:[];//定额工料机没有,有可能是定额类型的工料机
+            let result = this.getQuantityPerGLJ(gljGroup,rations,rationMap,pglj,billIDs,tech_billIDS,q_decimal,_,scMathUtil);
+            pglj.subdivisionQuantity = result.subdivisionQuantity;
+            pglj.techQuantity = result.techQuantity;
+            pglj.quantity = result.quantity;
+            quantityMap[pg_index] = pglj;
+        }
+        //计算做为组成物的消耗量
+        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);
+                }
+            }
+        }
+    },
+    getQuantityPerGLJ : function (ration_glj_list,rations,rationMap,pglj,billIDs,tech_billIDS,q_decimal,_,scMathUtil) {
+        let result={};
+        let quantity_sum=0;//工料机汇总消耗量
+        let sum = 0;//分部分项总消耗量
+        let tech_sum = 0;//技术措施总消耗量
+        for(let rg of ration_glj_list){
+            let tem_ration = rationMap[rg.rationID];
+            let r_quantity = tem_ration?scMathUtil.roundForObj(tem_ration.quantity,q_decimal):0;
+            let glj_quantity = scMathUtil.roundForObj(rg.quantity, q_decimal);
+            if(!r_quantity){
+                continue;
+            }
+            let total = scMathUtil.roundForObj(glj_quantity*r_quantity, q_decimal);
+            quantity_sum = scMathUtil.roundForObj(quantity_sum+total,q_decimal);
+            if(_.includes(billIDs,rg.billsItemID)){//计算分部分项
+                sum = scMathUtil.roundForObj(sum+total,q_decimal);
+            }
+            if(_.includes(tech_billIDS,rg.billsItemID)){//计算技术措施项目消耗量
+                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;
+                quantity_sum = scMathUtil.roundForObj(quantity_sum+r_quantity,q_decimal);
+                if(_.includes(billIDs,ra.billsItemID)){//计算分部分项
+                    sum = scMathUtil.roundForObj(sum+r_quantity,q_decimal);
+                }
+                if(_.includes(tech_billIDS,ra.billsItemID)){//计算技术措施项目消耗量
+                    tech_sum = scMathUtil.roundForObj(tech_sum+r_quantity,q_decimal);
+                }
+            }
+
+        }
+        result.subdivisionQuantity = sum;
+        result.techQuantity = tech_sum;
+        result.quantity = quantity_sum;
+        return result;
+    },
+    getSubdivisionAndTechBillsLeavesID:function (billsDatas) {//分别取分部分项和技术措施项目的所有叶子清单ID
+       /* if(projectObj){//存在,说明在前端调用
+            return [projectObj.project.Bills.getSubdivisionProjectLeavesID(),projectObj.project.Bills.getTechLeavesID()];
+        }*/
+        let parentMap ={};
+        let subdivisionBillID  = null,techBillID = null,sIDs = [],tIDS = [];
+        for(let b of billsDatas){
+            if(parentMap[b.ParentID]){
+                parentMap[b.ParentID].push(b);
+            }else {
+                parentMap[b.ParentID]= [b];
+            }
+            if(this.isFlag(b)&&b.flagsIndex.fixed.flag==this.fixedFlag.SUB_ENGINERRING) {
+                subdivisionBillID = b.ID;
+            }
+            if(this.isFlag(b)&&b.flagsIndex.fixed.flag==this.fixedFlag.CONSTRUCTION_TECH){
+                techBillID = b.ID;
+            }
+        }
+
+        getLeaveIDs(subdivisionBillID,parentMap,sIDs);
+        getLeaveIDs(techBillID,parentMap,tIDS);
+        return [sIDs,tIDS];
+
+        function getLeaveIDs(ID,parentM,leaveIDs) {
+            if(parentM[ID] && parentM[ID].length > 0){
+                let children  =  parentM[ID];
+                for(let c of children){
+                    if(parentM[c.ID]){
+                        getLeaveIDs(c.ID,parentM,leaveIDs);
+                    }else {
+                        leaveIDs.push(c.ID);
+                    }
+                }
+            }
+
+        }
+
+
+
+    },
+    isFlag : function (v) {
+        return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed) && this.isDef(v.flagsIndex.fixed.flag);
+    }
+    ,
+    isDef:function (v) {
+        return v !== undefined && v !== null;
+    },
+    getIndex(obj, pops){
+        let t_index = '';
+        let k_arr = [];
+        for (let p of pops) {
+            let tmpK = (obj[p] == undefined || obj[p] == null || obj[p] == '') ? 'null' : obj[p];
+            k_arr.push(tmpK);
+        }
+        t_index = k_arr.join("|-|");
+        return t_index;
+    },
+    fixedFlag : {
+        // 分部分项工程
+        SUB_ENGINERRING: 1,
+        // 措施项目
+        MEASURE: 2,
+        // 施工技术措施项目
+        CONSTRUCTION_TECH: 3
+    }
+}

+ 9 - 3
public/web/sheet/sheet_common.js

@@ -461,7 +461,7 @@ var sheetCommonObj = {
         }
         }
         return pasteText.join('\n');
         return pasteText.join('\n');
     },
     },
-    transferToTreeSetting:function(setting,treeSetting){
+    transferToTreeSetting:function(setting,treeSetting,treeCol){
         for(let h of setting.header){
         for(let h of setting.header){
             treeSetting.cols.push(getSettingCol(h))
             treeSetting.cols.push(getSettingCol(h))
         }
         }
@@ -500,12 +500,18 @@ var sheetCommonObj = {
                 let decimal = getDecimal(header.decimalField);
                 let decimal = getDecimal(header.decimalField);
                 col.formatter = getFormatter(decimal);
                 col.formatter = getFormatter(decimal);
             }
             }
-            col.readOnly = function (node) {
+            if(header.getText && treeCol){
+                col.data.getText = treeCol.getEvent(header.getText);
+            }
+
+
+
+            /*col.readOnly = function (node) {
                 if(node.data.ParentID == -1 || node.data.id == 'GJ'){//三材类别项不能编辑)
                 if(node.data.ParentID == -1 || node.data.id == 'GJ'){//三材类别项不能编辑)
                     return true;
                     return true;
                 }
                 }
                 return false;
                 return false;
-            };
+            };*/
             return col;
             return col;
         }
         }
         function getCellType(header) {
         function getCellType(header) {

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

@@ -83,6 +83,7 @@ var TREE_SHEET_HELPER = {
 
 
         sheet.options.protectionOptions = option;
         sheet.options.protectionOptions = option;
         sheet.options.isProtected = true;
         sheet.options.isProtected = true;
+        sheet.options.allowCellOverflow = false;
     },
     },
     massOperationSheet: function (sheet, Operation) {
     massOperationSheet: function (sheet, Operation) {
         sheet.suspendPaint();
         sheet.suspendPaint();

+ 2 - 1
web/building_saas/js/global.js

@@ -123,4 +123,5 @@ function getFeeIndex(fees) {
         }
         }
     }
     }
     return feesIndex;
     return feesIndex;
-}
+}
+