Browse Source

汇总算法调整

chenshilong 4 years ago
parent
commit
7df88b1db1

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

@@ -9,7 +9,7 @@
 </head>
 </head>
 
 
 <body>
 <body>
-    <div class="toolsbar px-1" style="height:30px;width:100%;line-height:30px;font-size:15px;">费用汇总</div>
+    <div class="toolsbar px-1" style="height:30px;width:100%;line-height:30px;font-size:15px;" id="lblGatherFee">费用汇总</div>
     <div class="container-fluid">
     <div class="container-fluid">
         <div class="row">
         <div class="row">
             <div class="col-lg-2 p-0">
             <div class="col-lg-2 p-0">

+ 46 - 40
web/building_saas/main/js/models/calc_program.js

@@ -140,6 +140,9 @@ let calcTools = {
             treeNode.data.gljList = projectObj.project.ration_glj.getGljArrByBill(treeNode, needOneBill);
             treeNode.data.gljList = projectObj.project.ration_glj.getGljArrByBill(treeNode, needOneBill);
         };
         };
     },
     },
+    getGLJListByProgramID: function (programID) {
+        return null;
+    },
     getLeafBills: function (treeNode){
     getLeafBills: function (treeNode){
         let leafBills = [];
         let leafBills = [];
 
 
@@ -1081,18 +1084,16 @@ let calcTools = {
     else if (tender == tenderTypes.ttReverseRation)
     else if (tender == tenderTypes.ttReverseRation)
         return node.data.rationQuantityCoe;
         return node.data.rationQuantityCoe;
     },
     },
-    getUsedTemplateIDs: function(){
-        let IDsArr = [];
-        let rations = projectObj.project.Ration.datas;  
+    getUsedTemplates: function(){
+        let arr = [];
+        let rations = projectObj.project.Ration.datas;
         for (const r of rations) {
         for (const r of rations) {
-            let ID = r.programID;
-            if (!IDsArr.includes(ID))
-              IDsArr.push(ID);
+            let tpl = projectObj.project.calcProgram.compiledTemplates[r.programID];
+            if (!arr.includes(tpl))
+              arr.push(tpl);
         };
         };
-        return IDsArr;  
+        return arr;
     }
     }
-
-
 };
 };
 
 
 let rationCalcBases = {
 let rationCalcBases = {
@@ -1509,14 +1510,14 @@ let analyzer = {
         else return false;
         else return false;
     },
     },
     templateIsUsed: function (ID, tree = projectObj.project.mainTree){
     templateIsUsed: function (ID, tree = projectObj.project.mainTree){
-        
+
         let nodes = tree.items;
         let nodes = tree.items;
         for (let node of nodes){
         for (let node of nodes){
               if (node.data && node.data.programID && node.data.programID == ID) {
               if (node.data && node.data.programID && node.data.programID == ID) {
                   return true;
                   return true;
               }
               }
         };
         };
-        
+
         return false;
         return false;
     },
     },
     fieldNameIsUsed: function(template, fieldName){
     fieldNameIsUsed: function(template, fieldName){
@@ -2758,22 +2759,17 @@ class CalcProgram {
 
 
     };
     };
 
 
-    gatherRationFees(programID){
+    gatherFee(template){
         // $.bootstrapLoading.start();
         // $.bootstrapLoading.start();
         // setTimeout(()=>{
         // setTimeout(()=>{
             // 先把符合的定额筛选出来,以提高速度。
             // 先把符合的定额筛选出来,以提高速度。
-            let rations = []; 
+            let rations = [];
+            let rst = 0;
             for (const r of projectObj.project.Ration.datas) {
             for (const r of projectObj.project.Ration.datas) {
-                if (r.programID == programID) rations.push(r);
-            };    
+                if (r.programID == template.ID) rations.push(r);
+            };
 
 
-            let gatherObj = {};
-            gatherObj.programID = programID;
-            gatherObj.name = projectObj.project.calcProgram.compiledTemplates[programID].name;
             for (let ft of cpFeeTypes) {
             for (let ft of cpFeeTypes) {
-                let ftObj = {};
-                ftObj.name = ft.name;
-    
                 let sum_uf = 0, sum_tuf = 0, sum_tf = 0, sum_ttf = 0;
                 let sum_uf = 0, sum_tuf = 0, sum_tf = 0, sum_ttf = 0;
                 for (const r of rations) {
                 for (const r of rations) {
                     let uf = 0, tuf = 0, tf = 0, ttf = 0;
                     let uf = 0, tuf = 0, tf = 0, ttf = 0;
@@ -2788,30 +2784,40 @@ class CalcProgram {
                     sum_tf = (sum_tf + tf).toDecimal(decimalObj.process);
                     sum_tf = (sum_tf + tf).toDecimal(decimalObj.process);
                     sum_ttf = (sum_ttf + ttf).toDecimal(decimalObj.process);
                     sum_ttf = (sum_ttf + ttf).toDecimal(decimalObj.process);
                 };
                 };
-
-                ftObj.totalFee = sum_tf.toDecimal(decimalObj.bills.totalPrice);
-                ftObj.tenderTotalFee = sum_ttf.toDecimal(decimalObj.bills.totalPrice);
-                ftObj.unitFee = sum_uf.toDecimal(decimalObj.bills.unitPrice);
-                ftObj.tenderUnitFee = sum_tuf.toDecimal(decimalObj.bills.unitPrice);
-
-                gatherObj[ft.type] = ftObj;
+                for (let i = 0; i < template.calcItems.length; i++) {
+                    let ci = template.calcItems[i];
+                    if (ci.fieldName == ft.type){
+                      ci.totalFee = sum_tf.toDecimal(decimalObj.bills.totalPrice);
+                      ci.tenderTotalFee = sum_ttf.toDecimal(decimalObj.bills.totalPrice);
+                      ci.unitFee = sum_uf.toDecimal(decimalObj.bills.unitPrice);
+                      ci.tenderUnitFee = sum_tuf.toDecimal(decimalObj.bills.unitPrice);
+                      if (ft.type =='common') {
+                        template.totalFee = ci.totalFee;
+                        rst = ci.totalFee;
+                      }
+                      break;
+                    }
+                };
             };
             };
-            return gatherObj;
+            return rst;
         // });
         // });
-        // $.bootstrapLoading.end();    
+        // $.bootstrapLoading.end();
     };
     };
 
 
-    //报表用:汇总所有。projectObj.project.calcProgram.gatherAllRationFees();
-    gatherAllRationFees(){
-        let IDsArr = calcTools.getUsedTemplateIDs();
-        let rstObj = {};
-        for (const ID of IDsArr) {
-            let obj = this.gatherRationFees(ID);
-            rstObj[ID] = obj;
+    //报表用取费类别汇总。调用:let obj = projectObj.project.calcProgram.getGatherFeeData();
+    getGatherFeeData(){
+        let rst = {};
+        let tpls = calcTools.getUsedTemplates();
+
+        let temp = 0;
+        for (const t of tpls) {
+            temp = temp + this.gatherFee(t);
         }
         }
-        console.log(rstObj);
-        return rstObj;
-    }
+        rst.calcPrograms = tpls;
+        rst.totalFee = temp.toDecimal(decimalObj.bills.totalPrice);
+        console.log(rst);
+        return rst;
+    };
 };
 };
 
 
 // export default analyzer;
 // export default analyzer;

+ 5 - 11
web/building_saas/main/js/views/gather_fees_view.js

@@ -7,7 +7,8 @@ let gatherFeesView = {
     mainSetting: {
     mainSetting: {
         header:[
         header:[
             // {headerName:"ID",headerWidth:80,dataCode:"ID", hAlign: "center"},
             // {headerName:"ID",headerWidth:80,dataCode:"ID", hAlign: "center"},
-            {headerName:"名称",headerWidth:300,dataCode:"name", dataType: "String"}
+            {headerName:"费用类别",headerWidth:250,dataCode:"name", dataType: "String"},
+            {headerName:"金额",headerWidth:100,dataCode:"totalFee", dataType: "String",hAlign: "right"}
         ],
         ],
         view:{
         view:{
             comboBox:[],
             comboBox:[],
@@ -49,12 +50,9 @@ let gatherFeesView = {
 
 
     buildSheet: function (){
     buildSheet: function (){
         let me = this;
         let me = this;
-        let tpls = projectObj.project.calcProgram.datas.templates;
-        let IDs = calcTools.getUsedTemplateIDs();
-        for (const t of tpls) {
-            if (IDs.includes(t.ID)) 
-                me.datas.push(t);
-        }
+        let obj = projectObj.project.calcProgram.getGatherFeeData();
+        me.datas = obj.calcPrograms;
+        $('#lblGatherFee').text(`费用汇总 ${obj.totalFee}`);
 
 
         if (me.mainSpread) {
         if (me.mainSpread) {
             me.mainSpread.destroy();
             me.mainSpread.destroy();
@@ -128,10 +126,6 @@ let gatherFeesView = {
         me.detailSpread.suspendPaint();
         me.detailSpread.suspendPaint();
         var dData = me.datas[row].calcItems;
         var dData = me.datas[row].calcItems;
         me.detailSheet.setRowCount(dData.length, GC.Spread.Sheets.SheetArea.viewport);
         me.detailSheet.setRowCount(dData.length, GC.Spread.Sheets.SheetArea.viewport);
-        let gatherObj = projectObj.project.calcProgram.gatherRationFees(me.datas[row].ID);
-        for (const d of dData) {
-           d['totalFee'] = gatherObj[d.fieldName] ? gatherObj[d.fieldName].totalFee : 0;
-        }
         sheetCommonObj.showData(me.detailSheet, me.detailSetting, dData);
         sheetCommonObj.showData(me.detailSheet, me.detailSetting, dData);
         me.getfeeRateColor(dData);
         me.getfeeRateColor(dData);
         customRowHeader(me.detailSheet, dData.length);
         customRowHeader(me.detailSheet, dData.length);