|
@@ -8,6 +8,8 @@ let consts = require('../../../modules/main/models/project_consts');
|
|
|
|
|
|
let fsUtil = require("../../../public/fsUtil");
|
|
|
let stringUtil = require("../../../public/stringUtil");
|
|
|
+let scMathUtil = require("../../../public/scMathUtil");
|
|
|
+let _ = require("lodash");
|
|
|
|
|
|
let treeUtil = require('../../../public/treeUtil');
|
|
|
let projectConst = consts.projectConst;
|
|
@@ -220,6 +222,12 @@ class Rpt_Data_Extractor {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (rst.indexOf(projectConst.RATION) >= 0 &&
|
|
|
+ rst.indexOf(projectConst.RATION_GLJ) >= 0 && rst.indexOf(projectConst.RATION_COE) < 0) {
|
|
|
+ rst.push(projectConst.RATION_COE);
|
|
|
+ //备注:在此情况下,根据业务特点,有可能需要额外计算project工料机的基价单价及市场单价,需要用到一些额外信息处理。
|
|
|
+ // 这里也不精细控制,直接多加一个请求类型。以后说不定还有其他类型的请求,到时候再加。
|
|
|
+ }
|
|
|
if (rst.length === 0) {
|
|
|
rst.push(projectConst.RATION_ASS);
|
|
|
}
|
|
@@ -276,6 +284,15 @@ class Rpt_Data_Extractor {
|
|
|
setupFunc($PROJECT.SUMMARY, `SegmentDetail`, {"data": rawDataObj.SegmentDetail});
|
|
|
}
|
|
|
}
|
|
|
+ //综合费率
|
|
|
+ let feeRate = getModuleDataByKey(rawDataObj.prjData, "feeRate");
|
|
|
+ if (feeRate) {
|
|
|
+ //把综合费率树结构数据拉扁
|
|
|
+ // console.log(feeRate);
|
|
|
+ let newFeeRates = setupFeeRate(feeRate.data._doc);
|
|
|
+ // console.log(newFeeRates);
|
|
|
+ feeRate.data._doc.rates = newFeeRates;
|
|
|
+ }
|
|
|
|
|
|
if (tpl[JV.NODE_MAP_DATA_HANDLE_INFO]) {
|
|
|
for (let preHandle of tpl[JV.NODE_MAP_DATA_HANDLE_INFO]) {
|
|
@@ -311,6 +328,28 @@ class Rpt_Data_Extractor {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //一些计算(不保存数据,需要动态计算的)
|
|
|
+ if (rawDataObj.hasOwnProperty(`prj`)) {
|
|
|
+ let calcOptions = rawDataObj.prj._doc.property.calcOptions;
|
|
|
+ let decimalObj = rawDataObj.prj._doc.property.decimal;
|
|
|
+ let labourCoeDatas = getModuleDataByKey(rawDataObj.prjData, "labour_coe");
|
|
|
+ let prjGLJDatas = getModuleDataByKey(rawDataObj.prjData, "projectGLJ");
|
|
|
+ let rationDatas = getModuleDataByKey(rawDataObj.prjData, "ration");
|
|
|
+ if (calcOptions && decimalObj && labourCoeDatas && labourCoeDatas && prjGLJDatas && rationDatas) {
|
|
|
+ for (let rationItem of rationDatas.data) {
|
|
|
+ let glj = _.find(prjGLJDatas.data.gljList, {'id': rationItem.projectGLJID});
|
|
|
+ if (glj) {
|
|
|
+ let newGlj = gljUtil.getGLJPrice(glj, prjGLJDatas.data, calcOptions, labourCoeDatas, decimalObj, false, _, scMathUtil);
|
|
|
+ rationItem.marketPrice = newGlj.marketPrice;
|
|
|
+ rationItem.basePrice = newGlj.basePrice;
|
|
|
+ rationItem.adjustPrice = newGlj.adjustPrice;
|
|
|
+ rationItem.marketUnitFee = newGlj.marketPrice;//更新树节点市场单价列的值
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // console.log("重新计算!");
|
|
|
+ }
|
|
|
+ //
|
|
|
let rptDataObj = {};
|
|
|
rptDataObj[JV.DATA_DISCRETE_DATA] = [];
|
|
|
rptDataObj[JV.DATA_MASTER_DATA] = [];
|
|
@@ -1143,6 +1182,43 @@ function setupMainFunc(obj, prop, ownRawObj) {
|
|
|
obj[prop].getFee = ext_mainGetFee;
|
|
|
}
|
|
|
|
|
|
+function setupFeeRate(feeRateData){
|
|
|
+ let cacheObj = {}, topArr = [], rstArr = [], id_pre = 'ID_';
|
|
|
+ const rateProperties = [];
|
|
|
+ for (let rate of feeRateData.rates) {
|
|
|
+ cacheObj[id_pre + rate._doc.ID] = {"obj": rate._doc, "items": []};
|
|
|
+ // cacheObj[id_pre + rate.ID].items = [];
|
|
|
+ if (rate._doc.ParentID === null || rate._doc.ParentID === undefined) {
|
|
|
+ topArr.push(cacheObj[id_pre + rate._doc.ID]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let rate of feeRateData.rates) {
|
|
|
+ if (rate._doc.ParentID && cacheObj[id_pre + rate._doc.ParentID]) {
|
|
|
+ cacheObj[id_pre + rate._doc.ParentID].items.push(cacheObj[id_pre + rate._doc.ID]);
|
|
|
+ if (rateProperties.indexOf(rate._doc.name) < 0) {
|
|
|
+ rateProperties.push(rate._doc.name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let pri_func_set_property_rate = function (orgRateItem, rstRateItem) {
|
|
|
+ rstRateItem[orgRateItem.obj.name] = orgRateItem.obj.rate;
|
|
|
+ for (let subOrgRateItem of orgRateItem.items) {
|
|
|
+ pri_func_set_property_rate(subOrgRateItem, rstRateItem);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ for (let topRate of topArr) {
|
|
|
+ let rstItem = {"name": topRate.obj.name};
|
|
|
+ for (let property of rateProperties) {
|
|
|
+ rstItem[property] = 0;
|
|
|
+ }
|
|
|
+ for (let dtlRateItem of topRate.items) {
|
|
|
+ pri_func_set_property_rate(dtlRateItem, rstItem);
|
|
|
+ }
|
|
|
+ rstArr.push(rstItem);
|
|
|
+ }
|
|
|
+ return rstArr;
|
|
|
+}
|
|
|
+
|
|
|
function setupFunc(obj, prop, ownRawObj) {
|
|
|
obj[prop] = {};
|
|
|
obj[prop]["myOwnRawDataObj"] = ownRawObj;
|
|
@@ -1154,6 +1230,8 @@ function setupFunc(obj, prop, ownRawObj) {
|
|
|
obj[prop].getArrayValues = ext_getArrayValues;
|
|
|
obj[prop].getArrayItemByKey = ext_getArrayItemByKey;
|
|
|
obj[prop].getPropertyByFlag = ext_getPropertyByFlag;
|
|
|
+ obj[prop].getSubRateProperty = ext_getRateProperty;
|
|
|
+ obj[prop].getRateProperty = ext_getRateProperty;
|
|
|
obj[prop].getBlank = ext_getBlank;
|
|
|
if (prop === projectConst.CALC_PROGRAM) obj[prop].getCalcProperty = ext_getCalcProperty;
|
|
|
if (prop === projectConst.FEERATE) obj[prop].getFeeRate = ext_getFeeRate;
|
|
@@ -1250,6 +1328,17 @@ function ext_mainGetPropety(propKey) {
|
|
|
return rst;
|
|
|
}
|
|
|
|
|
|
+function ext_getRateProperty(propKey) {
|
|
|
+ let rst = [], parentObj = this;
|
|
|
+ let dtObj = parentObj["myOwnRawDataObj"];
|
|
|
+ if (propKey && dtObj) {
|
|
|
+ for (let rate of dtObj.data._doc.rates) {
|
|
|
+ rst.push(rate[propKey]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+}
|
|
|
+
|
|
|
function ext_getPropety(propKey) {
|
|
|
let rst = [], parentObj = this;
|
|
|
let dtObj = parentObj["myOwnRawDataObj"];
|