|
@@ -141,7 +141,9 @@ let calcTools = {
|
|
|
};
|
|
|
},
|
|
|
getGLJListByProgramID: function (programID) {
|
|
|
- return null;
|
|
|
+ let rations = calcTools.getRationsByProgramID(programID);
|
|
|
+ let gljList = projectObj.project.ration_glj.getGljArrByRations(rations);
|
|
|
+ return gljList;
|
|
|
},
|
|
|
getLeafBills: function (treeNode){
|
|
|
let leafBills = [];
|
|
@@ -846,30 +848,30 @@ let calcTools = {
|
|
|
};
|
|
|
return coe;
|
|
|
},
|
|
|
- tenderCoe_GLJQty: function (treeNode, glj){
|
|
|
+ tenderCoe_GLJQty: function (rationData, glj){
|
|
|
let coe = 1;
|
|
|
- if (!treeNode.data.quantityCoe) return coe;
|
|
|
+ if (!rationData.quantityCoe) return coe;
|
|
|
if (!calcTools.isTenderProjectGLJ(glj)) return coe;
|
|
|
|
|
|
if (gljType.LABOUR == glj.type){
|
|
|
- if (treeNode.data.quantityCoe.labour)
|
|
|
- coe = treeNode.data.quantityCoe.labour;
|
|
|
+ if (rationData.quantityCoe.labour)
|
|
|
+ coe = rationData.quantityCoe.labour;
|
|
|
}
|
|
|
else if (baseMaterialTypes.indexOf(glj.type)){
|
|
|
- if (treeNode.data.quantityCoe.material)
|
|
|
- coe = treeNode.data.quantityCoe.material;
|
|
|
+ if (rationData.quantityCoe.material)
|
|
|
+ coe = rationData.quantityCoe.material;
|
|
|
}
|
|
|
else if (baseMachineTypes.indexOf(glj.type)){
|
|
|
- if (treeNode.data.quantityCoe.machine)
|
|
|
- coe = treeNode.data.quantityCoe.machine;
|
|
|
+ if (rationData.quantityCoe.machine)
|
|
|
+ coe = rationData.quantityCoe.machine;
|
|
|
}
|
|
|
else if (gljType.MAIN_MATERIAL == glj.type){
|
|
|
- if (treeNode.data.quantityCoe.main)
|
|
|
- coe = treeNode.data.quantityCoe.main;
|
|
|
+ if (rationData.quantityCoe.main)
|
|
|
+ coe = rationData.quantityCoe.main;
|
|
|
}
|
|
|
else if (gljType.EQUIPMENT == glj.type){
|
|
|
- if (treeNode.data.quantityCoe.equipment)
|
|
|
- coe = treeNode.data.quantityCoe.equipment;
|
|
|
+ if (rationData.quantityCoe.equipment)
|
|
|
+ coe = rationData.quantityCoe.equipment;
|
|
|
};
|
|
|
|
|
|
if (coe == '0') coe = 1; // 这里加个保护
|
|
@@ -1093,6 +1095,14 @@ let calcTools = {
|
|
|
arr.push(tpl);
|
|
|
};
|
|
|
return arr;
|
|
|
+ },
|
|
|
+ getRationsByProgramID: function(programID){
|
|
|
+ let rations = [];
|
|
|
+ for (const r of projectObj.project.Ration.datas) {
|
|
|
+ if (r.programID == programID)
|
|
|
+ rations.push(r);
|
|
|
+ };
|
|
|
+ return rations;
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -1808,7 +1818,7 @@ class CalcProgram {
|
|
|
me.innerCalcBillCustom(treeNode)
|
|
|
// 定额:计算程序
|
|
|
else
|
|
|
- me.innerCalcRation(treeNode, tenderType);
|
|
|
+ me.innerCalcRation2(treeNode, tenderType);
|
|
|
|
|
|
if (!calcTools.isTotalCostBill(treeNode)) // 已在上面的分支中计算过
|
|
|
calcTools.estimateFee(treeNode);
|
|
@@ -1982,6 +1992,51 @@ class CalcProgram {
|
|
|
treeNode.data.calcTemplate = {"calcItems": []};
|
|
|
};
|
|
|
|
|
|
+ innerCalcRation2(treeNode){
|
|
|
+ let me = this;
|
|
|
+ calcTools.getGLJList(treeNode, true);
|
|
|
+
|
|
|
+ let nQ = calcTools.uiNodeQty(treeNode);
|
|
|
+
|
|
|
+ if (treeNode.calcType == treeNodeCalcType.ctRationCalcProgram) {
|
|
|
+ // 量价、工料机类型的定额要求"市场合价"
|
|
|
+ if (calcTools.isVP_or_GLJR(treeNode)){
|
|
|
+ let u = treeNode.data.marketUnitFee ? treeNode.data.marketUnitFee : 0;
|
|
|
+ let t = (u * nQ).toDecimal(decimalObj.ration.totalPrice);
|
|
|
+ if (treeNode.data.marketTotalFee != t){
|
|
|
+ treeNode.data.marketTotalFee = t;
|
|
|
+ treeNode.changed = true;
|
|
|
+ } ;
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ calcTools.initFees(treeNode);
|
|
|
+ // 只有人、材、机、主、设。
|
|
|
+ let fieldNames = ['labour', 'material', 'machine', 'mainMaterial', 'equipment', 'common'];
|
|
|
+ let funcNames = ['定额人工费','定额材料费','定额施工机具使用费','市场价主材费','市场价设备费'];
|
|
|
+ debugger;
|
|
|
+ for (let i = 0; i < 6; i++) {
|
|
|
+ let obj = {};
|
|
|
+ obj.fieldName = fieldNames[i];
|
|
|
+ if (obj.fieldName != 'common'){
|
|
|
+ obj.unitFee = (rationCalcBases[funcNames[i]](treeNode)).toDecimal(decimalObj.decimal('unitPrice', treeNode));
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ let sum = 0;
|
|
|
+ for (let i = 0; i < fieldNames.length - 1; i++) {
|
|
|
+ let u = treeNode.data.feesIndex[fieldNames[i]]? treeNode.data.feesIndex[fieldNames[i]].unitFee : 0;
|
|
|
+ sum = sum + u;
|
|
|
+ }
|
|
|
+ obj.unitFee = sum.toDecimal(decimalObj.decimal('unitPrice', treeNode))
|
|
|
+ }
|
|
|
+ obj.totalFee = (obj.unitFee * nQ).toDecimal(decimalObj.decimal('totalPrice', treeNode));
|
|
|
+ obj.tenderUnitFee = obj.unitFee;
|
|
|
+ obj.tenderTotalFee = obj.totalFee;
|
|
|
+ calcTools.checkFeeField(treeNode, obj);
|
|
|
+ };
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
// 定额部分抽取出来,供分摊定额公用。
|
|
|
innerCalcRation(treeNode, tenderType = tenderTypes.ttCalc){
|
|
|
let me = this;
|
|
@@ -2759,66 +2814,91 @@ class CalcProgram {
|
|
|
|
|
|
};
|
|
|
|
|
|
+ // 算法1:直接累计同取费多定额的各个费
|
|
|
gatherFee(template){
|
|
|
- // $.bootstrapLoading.start();
|
|
|
- // setTimeout(()=>{
|
|
|
- // 先把符合的定额筛选出来,以提高速度。
|
|
|
- let rations = [];
|
|
|
- let rst = 0;
|
|
|
- for (const r of projectObj.project.Ration.datas) {
|
|
|
- if (r.programID == template.ID) rations.push(r);
|
|
|
- };
|
|
|
-
|
|
|
- for (let ft of cpFeeTypes) {
|
|
|
- let sum_uf = 0, sum_tuf = 0, sum_tf = 0, sum_ttf = 0;
|
|
|
- for (const r of rations) {
|
|
|
- let uf = 0, tuf = 0, tf = 0, ttf = 0;
|
|
|
- if (r.feesIndex && r.feesIndex[ft.type]) {
|
|
|
- uf = parseFloatPlus(r.feesIndex[ft.type].unitFee).toDecimal(decimalObj.bills.unitPrice);
|
|
|
- tuf = parseFloatPlus(r.feesIndex[ft.type].tenderUnitFee).toDecimal(decimalObj.bills.unitPrice);
|
|
|
- tf = parseFloatPlus(r.feesIndex[ft.type].totalFee).toDecimal(decimalObj.bills.totalPrice);
|
|
|
- ttf = parseFloatPlus(r.feesIndex[ft.type].tenderTotalFee).toDecimal(decimalObj.bills.totalPrice);
|
|
|
- };
|
|
|
- sum_uf = (sum_uf + uf).toDecimal(decimalObj.process);
|
|
|
- sum_tuf = (sum_tuf + tuf).toDecimal(decimalObj.process);
|
|
|
- sum_tf = (sum_tf + tf).toDecimal(decimalObj.process);
|
|
|
- sum_ttf = (sum_ttf + ttf).toDecimal(decimalObj.process);
|
|
|
- };
|
|
|
- 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;
|
|
|
- }
|
|
|
+ let rations = calcTools.getRationsByProgramID(template.ID);
|
|
|
+ let rst = 0;
|
|
|
+ for (let ft of cpFeeTypes) {
|
|
|
+ let sum_uf = 0, sum_tuf = 0, sum_tf = 0, sum_ttf = 0;
|
|
|
+ for (const r of rations) {
|
|
|
+ let uf = 0, tuf = 0, tf = 0, ttf = 0;
|
|
|
+ if (r.feesIndex && r.feesIndex[ft.type]) {
|
|
|
+ uf = parseFloatPlus(r.feesIndex[ft.type].unitFee).toDecimal(decimalObj.bills.unitPrice);
|
|
|
+ tuf = parseFloatPlus(r.feesIndex[ft.type].tenderUnitFee).toDecimal(decimalObj.bills.unitPrice);
|
|
|
+ tf = parseFloatPlus(r.feesIndex[ft.type].totalFee).toDecimal(decimalObj.bills.totalPrice);
|
|
|
+ ttf = parseFloatPlus(r.feesIndex[ft.type].tenderTotalFee).toDecimal(decimalObj.bills.totalPrice);
|
|
|
};
|
|
|
+ sum_uf = (sum_uf + uf).toDecimal(decimalObj.process);
|
|
|
+ sum_tuf = (sum_tuf + tuf).toDecimal(decimalObj.process);
|
|
|
+ sum_tf = (sum_tf + tf).toDecimal(decimalObj.process);
|
|
|
+ sum_ttf = (sum_ttf + ttf).toDecimal(decimalObj.process);
|
|
|
};
|
|
|
- return rst;
|
|
|
- // });
|
|
|
- // $.bootstrapLoading.end();
|
|
|
+ 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 rst;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 算法2:先汇总同取费多定额下的工料机,虚拟成一个大定额对象,走计算程序。
|
|
|
+ gatherFee2(template){
|
|
|
+ let data = {gljList: null};
|
|
|
+ let obj = {data: data};
|
|
|
+ obj.data.gljList = calcTools.getGLJListByProgramID(template.ID);
|
|
|
+
|
|
|
+ let $CE = executeObj;
|
|
|
+ $CE.treeNode = obj;
|
|
|
+ $CE.template = template;
|
|
|
+
|
|
|
+ let rst = 0;
|
|
|
+ for (let idx of template.compiledSeq) {
|
|
|
+ let calcItem = template.calcItems[idx];
|
|
|
+ $CE.tempCalcItem = calcItem;
|
|
|
+ let feeRate = 100; // 100%
|
|
|
+ if (calcItem.feeRate != undefined)
|
|
|
+ feeRate = parseFloat(calcItem.feeRate).toDecimal(decimalObj.feeRate);
|
|
|
+
|
|
|
+ calcItem.unitFee = (eval(calcItem.compiledExpr) * feeRate * 0.01).toDecimal(2);
|
|
|
+ // calcItem.totalFee = (calcItem.unitFee * nQ).toDecimal(2);
|
|
|
+ calcItem.totalFee = (calcItem.unitFee * 1).toDecimal(2);
|
|
|
+
|
|
|
+ if (calcItem.fieldName =='common') {
|
|
|
+ template.totalFee = calcItem.totalFee;
|
|
|
+ rst = calcItem.totalFee;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return rst;
|
|
|
};
|
|
|
|
|
|
//报表用取费类别汇总。调用:let obj = projectObj.project.calcProgram.getGatherFeeData();
|
|
|
getGatherFeeData(){
|
|
|
+ // $.bootstrapLoading.start();
|
|
|
+ // setTimeout(()=>{
|
|
|
let rst = {};
|
|
|
let tpls = calcTools.getUsedTemplates();
|
|
|
|
|
|
let temp = 0;
|
|
|
for (const t of tpls) {
|
|
|
- temp = temp + this.gatherFee(t);
|
|
|
+ temp = temp + this.gatherFee2(t);
|
|
|
}
|
|
|
rst.calcPrograms = tpls;
|
|
|
rst.totalFee = temp.toDecimal(decimalObj.bills.totalPrice);
|
|
|
projectObj.project.mainTree.items[0].data.totalFee = rst.totalFee;
|
|
|
console.log(rst);
|
|
|
return rst;
|
|
|
+ // });
|
|
|
+ // $.bootstrapLoading.end();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-// export default analyzer;
|