|
@@ -41,6 +41,7 @@ ProjectGLJ.prototype.loadData = function (callback = null) {
|
|
|
return false;
|
|
|
}
|
|
|
self.datas = response.data;
|
|
|
+ self.calcQuantity();
|
|
|
// 回调函数
|
|
|
if (callback !== null) {
|
|
|
callback(response.data);
|
|
@@ -396,3 +397,93 @@ ProjectGLJ.prototype.getShortNameByID = function (ID) {
|
|
|
let gljTypeMap = this.datas.constData.gljTypeMap;
|
|
|
return gljTypeMap["typeId" + ID].shortName;
|
|
|
}
|
|
|
+
|
|
|
+ProjectGLJ.prototype.calcQuantity = function (){
|
|
|
+ let project_gljs = this.datas.gljList;
|
|
|
+ let mixRatioConnectData = this.datas.mixRatioConnectData;
|
|
|
+ let mixRatioSubdivisionMap = {};
|
|
|
+ let mixRatioTechMap={};
|
|
|
+ for(let pglj of project_gljs ){
|
|
|
+ if(pglj.quantity !== 0 && pglj.quantity !== '0'){
|
|
|
+ let result = this.getQuantityPerGLJ(pglj,mixRatioSubdivisionMap,mixRatioTechMap);
|
|
|
+ pglj.subdivisionQuantity = result.subdivisionQuantity;
|
|
|
+ pglj.techQuantity = result.techQuantity;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算做为组成物的消耗量
|
|
|
+ for(let pg of project_gljs ){
|
|
|
+ if(pg.quantity !== 0 && pg.quantity !== '0'){
|
|
|
+ let pg_index = gljOprObj.getIndex(pg,gljKeyArray);
|
|
|
+ if(mixRatioConnectData[pg_index]){
|
|
|
+ if(mixRatioSubdivisionMap[pg_index]){
|
|
|
+ pg.subdivisionQuantity = scMathUtil.roundForObj(mixRatioSubdivisionMap[pg_index]+pg.subdivisionQuantity,getDecimal("glj.quantity"));
|
|
|
+ }
|
|
|
+ if(mixRatioTechMap[pg_index]){
|
|
|
+ pg.techQuantity = scMathUtil.roundForObj(mixRatioTechMap[pg_index]+pg.techQuantity,getDecimal("glj.quantity"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+ProjectGLJ.prototype.getQuantityPerGLJ =function (pglj,mixRatioSubdivisionMap,mixRatioTechMap) {
|
|
|
+ let billIDs = projectObj.project.Bills.getSubdivisionProjectLeavesID();//取分部分项上的所有叶子清单ID
|
|
|
+ let tech_billIDS = projectObj.project.Bills.getTechLeavesID();//取所有技术措施项目叶子清单ID
|
|
|
+ let ration_glj_list = projectObj.project.ration_glj.datas;
|
|
|
+ let mixRatioMap = this.datas.mixRatioMap;
|
|
|
+ let rations = projectObj.project.Ration.datas;
|
|
|
+ let q_decimal = getDecimal("glj.quantity");
|
|
|
+ let result={};
|
|
|
+ let sum = 0;
|
|
|
+ let tech_sum = 0;
|
|
|
+ for(let rg of ration_glj_list){
|
|
|
+ if(rg.projectGLJID==pglj.id){
|
|
|
+ if(_.includes(billIDs,rg.billsItemID)){//计算分部分项
|
|
|
+ let total = calcQuantity(rg,mixRatioSubdivisionMap);
|
|
|
+ sum = scMathUtil.roundForObj(sum+total,q_decimal);
|
|
|
+ }
|
|
|
+ if(_.includes(tech_billIDS,rg.billsItemID)){//计算技术措施项目消耗量
|
|
|
+ let tech_total = calcQuantity(rg,mixRatioTechMap);
|
|
|
+ tech_sum = scMathUtil.roundForObj(tech_sum+tech_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;
|
|
|
+ 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;
|
|
|
+ return result;
|
|
|
+
|
|
|
+ function calcQuantity(rg,quantityMap) { //计算工料机在所属定额下的总消耗量
|
|
|
+ let tem_ration = _.find(rations,{"ID":rg.rationID});
|
|
|
+ let total = parseFloat(gljOprObj.getTotalQuantity(rg,tem_ration));
|
|
|
+ let r_index = gljOprObj.getIndex(rg,gljKeyArray);
|
|
|
+ if(mixRatioMap.hasOwnProperty(r_index)){
|
|
|
+ let mixRatioList = mixRatioMap[r_index];
|
|
|
+ for(let m of mixRatioList){
|
|
|
+ let m_index = gljOprObj.getIndex(m,gljKeyArray);
|
|
|
+ let m_quantity = scMathUtil.roundForObj(total*m.consumption,q_decimal);
|
|
|
+ if(quantityMap[m_index]){
|
|
|
+ quantityMap[m_index] = scMathUtil.roundForObj(quantityMap[m_index]+m_quantity,q_decimal);
|
|
|
+ }else {
|
|
|
+ quantityMap[m_index] = m_quantity;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return total;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|