|
|
@@ -319,6 +319,238 @@ let gljUtil = {
|
|
|
return scMathUtil.roundToString(quantity * glj.quantity, gd);
|
|
|
}
|
|
|
},
|
|
|
+ getEngineerCostData:function(property,bills,fixedFlag,scMathUtil){
|
|
|
+ let priceIndex = {
|
|
|
+ name:"工程造价指标",
|
|
|
+ attrs:[],
|
|
|
+ children:[],
|
|
|
+ };
|
|
|
+ let fixMap = {};
|
|
|
+ let buildingArea = this.getBuildArea(property.engineerFeatures); //tender.property.projectFeature?getItemValueBykey(tender.property.projectFeature,"buildingArea"):1;//建筑面积
|
|
|
+
|
|
|
+ for(let b of bills){
|
|
|
+ if(b.flags && b.flags.length > 0){
|
|
|
+ let f = _.find(b.flags,{"fieldName":"fixed"});
|
|
|
+ if(f) fixMap[f.flag] = this.getTotalFee(b,scMathUtil,property.decimal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算其他组织措施费 = 施工组织措施项目下的子项,除了 安全文明施工费、建设工程竣工档案编制费以外的项
|
|
|
+ let CONSTRUCTION_ORGANIZATION = fixMap[fixedFlag.CONSTRUCTION_ORGANIZATION]?fixMap[fixedFlag.CONSTRUCTION_ORGANIZATION]:0;
|
|
|
+ let SAFETY_CONSTRUCTION = fixMap[fixedFlag.SAFETY_CONSTRUCTION]?fixMap[fixedFlag.SAFETY_CONSTRUCTION]:0;
|
|
|
+ let PROJECT_COMPLETE_ARCH_FEE = fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE]? fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE]:0;
|
|
|
+ let other_org_fee = CONSTRUCTION_ORGANIZATION - SAFETY_CONSTRUCTION - PROJECT_COMPLETE_ARCH_FEE;
|
|
|
+ other_org_fee = other_org_fee >0 ?other_org_fee:0;
|
|
|
+ let engineerCost = fixMap[fixedFlag.ENGINEERINGCOST]?fixMap[fixedFlag.ENGINEERINGCOST]:1;
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("分部分项工程费",fixMap[fixedFlag.SUB_ENGINERRING],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("技术措施费",fixMap[fixedFlag.CONSTRUCTION_TECH],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("安全文明施工费",fixMap[fixedFlag.SAFETY_CONSTRUCTION],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("建设工程竣工档案编制费",fixMap[fixedFlag.PROJECT_COMPLETE_ARCH_FEE],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("其他组织措施费",other_org_fee,engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("暂列金额",fixMap[fixedFlag.PROVISIONAL],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("专业工程暂估价",fixMap[fixedFlag.ENGINEERING_ESITIMATE],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("计日工",fixMap[fixedFlag.DAYWORK],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("总承包服务费",fixMap[fixedFlag.TURN_KEY_CONTRACT],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("索赔与现场签证",fixMap[fixedFlag.CLAIM_VISA],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("规费",fixMap[fixedFlag.CHARGE],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("税金",fixMap[fixedFlag.TAX],engineerCost,buildingArea,scMathUtil));
|
|
|
+ priceIndex.children.push(this.getEngineerFlag("工程造价",fixMap[fixedFlag.ENGINEERINGCOST],engineerCost,buildingArea,scMathUtil));
|
|
|
+ return priceIndex;
|
|
|
+ },
|
|
|
+ getBuildArea:function (features) {
|
|
|
+ if(features){
|
|
|
+ let areas = [];
|
|
|
+ for(let f of features){
|
|
|
+ if(f.index == true && f.value && f.value !=="" && this.IsNumber(f.value)) areas.push(f.value);
|
|
|
+ }
|
|
|
+ return areas.length==0?1:areas;
|
|
|
+ }
|
|
|
+ return 1
|
|
|
+ },
|
|
|
+ getEngineerFlag: function (name,totalCost,engineerCost,buildingArea,scMathUtil) {
|
|
|
+ totalCost = totalCost?totalCost:0;
|
|
|
+ let flag = {
|
|
|
+ name:name,
|
|
|
+ attrs:[
|
|
|
+ {name: "金额", value: scMathUtil.roundToString(totalCost,3)},
|
|
|
+ {name: "单方造价", value: scMathUtil.roundToString(this.calcUnitB(totalCost,buildingArea,scMathUtil),2)},
|
|
|
+ {name: "占造价比例", value: scMathUtil.roundToString(totalCost/engineerCost * 100,2)},
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ return flag;
|
|
|
+ },
|
|
|
+ getTotalFee:function (b,scMathUtil,decimal) {
|
|
|
+ let total = 0;
|
|
|
+ if(b.fees && b.fees.length > 0){
|
|
|
+ for(let f of b.fees){
|
|
|
+ if(f.fieldName == "common"){
|
|
|
+ total = scMathUtil.roundForObj(f.totalFee,decimal?decimal.bills.totalPrice:getDecimal("bills.totalPrice"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return total;
|
|
|
+ },
|
|
|
+ IsNumber : function(pstrVal){
|
|
|
+ let dblNo = Number.NaN;
|
|
|
+ dblNo = new Number(pstrVal);
|
|
|
+ if (isNaN(dblNo)) return false;
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ calcUnitB:function (total,building,scMathUtil,coe,decimal = 3) {
|
|
|
+ if(Array.isArray(building)){
|
|
|
+ for(let b of building){
|
|
|
+ total = scMathUtil.roundForObj(total/b,6);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ total = scMathUtil.roundForObj(total/building,6);
|
|
|
+ }
|
|
|
+ coe = gljUtil.isDef(coe)?coe:1;
|
|
|
+ return scMathUtil.roundForObj(total*coe,decimal);
|
|
|
+ },
|
|
|
+ getEconomicDatas:function(engineerFeatures,economics,billsList,fixedFlag,_,scMathUtil,decimal){
|
|
|
+ let datas = [];
|
|
|
+ let [bills,totalFee] = gljUtil.getIndexBills(billsList,fixedFlag,_,scMathUtil,decimal);
|
|
|
+ let billsGroup = _.groupBy(bills,'economicType');
|
|
|
+ if(!economics) return datas;
|
|
|
+ for(let e of economics){
|
|
|
+ let tem = {
|
|
|
+ name:e.name,
|
|
|
+ cost:0,
|
|
|
+ unitCost:0,
|
|
|
+ per:0
|
|
|
+ };
|
|
|
+ if(billsGroup[e.name]) setEconomics(billsGroup[e.name],totalFee,tem);
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+ function setEconomics(items,engineerCost,data) {
|
|
|
+ let cost = 0;
|
|
|
+ let priceDe = decimal?decimal.bills.totalPrice:getDecimal("bills.totalPrice");//getDecimal("bills.totalPrice");
|
|
|
+ for(let i of items){
|
|
|
+ i.totalFee = scMathUtil.roundForObj(i.totalFee,priceDe);
|
|
|
+ cost = scMathUtil.roundForObj(cost + i.totalFee,decimal?decimal.process:getDecimal("process"))//getDecimal("process");
|
|
|
+ }
|
|
|
+ data.cost = scMathUtil.roundForObj(cost,priceDe,_);
|
|
|
+ data.unitCost = gljUtil.calUnitWidthCoe(data.cost,true,engineerFeatures,_,scMathUtil);//noNeedCoe = true 这里不需要乘以系数
|
|
|
+ data.per = engineerCost?scMathUtil.roundForObj(data.cost/engineerCost * 100,2):0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return datas;
|
|
|
+ },
|
|
|
+ calUnitWidthCoe:function (total,noNeedCoe,engineerFeatures,_,scMathUtil) {
|
|
|
+ let areas = gljUtil.getBuildArea(engineerFeatures);
|
|
|
+ let f = _.find(engineerFeatures,{index:true});
|
|
|
+ return f && noNeedCoe!==true?gljUtil.calcUnitB(total,areas,scMathUtil,f.coe):gljUtil.calcUnitB(total,areas,scMathUtil);
|
|
|
+ },
|
|
|
+ getIndexBills:function (bills,fixedFlag,_,scMathUtil,decimal) {
|
|
|
+ let parentMap = {},datas = [],totalCost = 0;
|
|
|
+ let FBFX_b = null,teh_b = null,costNode=null;
|
|
|
+ for(let b of bills) {
|
|
|
+ parentMap[b.ParentID] ? parentMap[b.ParentID].push(b) : parentMap[b.ParentID] = [b];//有添加,无则生成
|
|
|
+ if(b.flags && b.flags.length > 0){
|
|
|
+ let f = _.find(b.flags,{"fieldName":"fixed"});
|
|
|
+ if(!f) continue;
|
|
|
+ if(f.flag == fixedFlag.SUB_ENGINERRING) FBFX_b = b;//过滤出分部分项工程;
|
|
|
+ if(f.flag == fixedFlag.CONSTRUCTION_TECH) teh_b = b;//过滤出技术措施项目;
|
|
|
+ if(f.flag == fixedFlag.ENGINEERINGCOST) costNode = b;//过滤出工程造价项目;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(FBFX_b) getChildren(FBFX_b,parentMap,datas);
|
|
|
+ if(teh_b) getChildren(teh_b,parentMap,datas);
|
|
|
+ if(costNode) totalCost = gljUtil.getTotalFee(costNode,scMathUtil,decimal);
|
|
|
+
|
|
|
+ for(let td of datas){
|
|
|
+ if(parentMap[td.ID]){
|
|
|
+ td.economicType = "";
|
|
|
+ td.quantityIndexType = "";
|
|
|
+ td.quantityIndexUnit = "";
|
|
|
+ td.quantityIndexCoe = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return [datas,totalCost];
|
|
|
+
|
|
|
+ function getChildren(d,map,arr) {
|
|
|
+ let tem = {
|
|
|
+ ID:d.ID,
|
|
|
+ ParentID:d.ParentID,
|
|
|
+ code:d.code,
|
|
|
+ name:d.name,
|
|
|
+ unit:d.unit,
|
|
|
+ quantity:d.quantity,
|
|
|
+ totalFee:gljUtil.getTotalFee(d,scMathUtil,decimal),
|
|
|
+ economicType:d.economicType,
|
|
|
+ quantityIndexType:d.quantityIndexType,
|
|
|
+ quantityIndexUnit:d.quantityIndexUnit,
|
|
|
+ quantityIndexCoe:d.quantityIndexCoe,
|
|
|
+ };
|
|
|
+ arr.push(tem);
|
|
|
+ if(map[d.ID]){
|
|
|
+ for(let s of map[d.ID]){
|
|
|
+ getChildren(s,map,arr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getMainMaterialDatas:function (engineerFeatures,materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil) {
|
|
|
+ let datas = [];
|
|
|
+ let materialGroup = _.groupBy(projectGLJData.gljList,'materialIndexType');
|
|
|
+ if(!materials) return datas;
|
|
|
+ for(let m of materials){
|
|
|
+ let tem = {
|
|
|
+ name:m.name,
|
|
|
+ unit:m.unit,
|
|
|
+ unitPrice:0,
|
|
|
+ quantity:0,
|
|
|
+ unitIndex:0
|
|
|
+ };
|
|
|
+ if(materialGroup[m.name]) setMainMaterial(materialGroup[m.name],tem);
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+
|
|
|
+ function setMainMaterial(gljs,data) {
|
|
|
+ let quantity = 0 ,unitPrice=0;
|
|
|
+ for(let g of gljs){
|
|
|
+ if(!g.quantity || g.quantity=="") continue;
|
|
|
+ let marketPrice = gljUtil.getMarketPrice(g,projectGLJData,calcOptions,decimalObj,false,_,scMathUtil); // gljOprObj.setGLJPrice(tem,g);
|
|
|
+ let materialIndexCoe = g.materialIndexCoe?scMathUtil.roundForObj(g.materialIndexCoe,decimalObj.process):0;
|
|
|
+ let t_quantity = scMathUtil.roundForObj(g.quantity * materialIndexCoe,decimalObj.process);
|
|
|
+ quantity = scMathUtil.roundForObj(t_quantity + quantity,decimalObj.process);
|
|
|
+ let temPrice = scMathUtil.roundForObj(g.quantity * marketPrice,decimalObj.process);
|
|
|
+ unitPrice = scMathUtil.roundForObj(temPrice + unitPrice,decimalObj.process);
|
|
|
+ }
|
|
|
+ data.quantity = scMathUtil.roundForObj(quantity,2);
|
|
|
+ if(data.quantity) data.unitPrice = scMathUtil.roundForObj(unitPrice/data.quantity,2);
|
|
|
+ data.unitIndex = gljUtil.calUnitWidthCoe(data.quantity,false,engineerFeatures,_,scMathUtil);
|
|
|
+ }
|
|
|
+
|
|
|
+ return datas;
|
|
|
+ },
|
|
|
+ getQuantityDatas:function (engineerFeatures,mainQuantities,billsList,fixedFlag,_,scMathUtil,decimal) {//主要工程量指标
|
|
|
+ let datas = [];
|
|
|
+ let [bills,totalFee] = gljUtil.getIndexBills(billsList,fixedFlag,_,scMathUtil,decimal);//bills,fixedFlag,_,scMathUtil
|
|
|
+ let billsGroup = _.groupBy(bills,'quantityIndexType');
|
|
|
+ if(!mainQuantities) return datas;
|
|
|
+ for(let m of mainQuantities){
|
|
|
+ let tem = {
|
|
|
+ name : m.name,
|
|
|
+ quantityIndexUnit:m.unit,
|
|
|
+ quantity:0
|
|
|
+ };
|
|
|
+ if(billsGroup[m.name]) setQuantities(billsGroup[m.name],tem);
|
|
|
+
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+
|
|
|
+ function setQuantities(items,data) {
|
|
|
+ let quantity = 0;
|
|
|
+ for (let i of items){
|
|
|
+ let coe = i.quantityIndexCoe && i.quantityIndexCoe!=""?parseFloat(i.quantityIndexCoe):0;
|
|
|
+ i.quantity = scMathUtil.roundForObj(parseFloat(i.quantity)*coe,decimal.process);
|
|
|
+ quantity = scMathUtil.roundForObj(quantity + i.quantity,decimal.process);
|
|
|
+ }
|
|
|
+ data.quantity = gljUtil.calUnitWidthCoe(quantity,false,engineerFeatures,_,scMathUtil);
|
|
|
+ }
|
|
|
+
|
|
|
+ return datas;
|
|
|
+ },
|
|
|
fixedFlag : {
|
|
|
// 分部分项工程
|
|
|
SUB_ENGINERRING: 1,
|