neimenggu_2017.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Zhong
  6. * @date 2019/4/17
  7. * @version
  8. */
  9. //允许使用的工料机类型:人工、普通材料、混凝土、砂浆、配合比、商品混凝土、商品砂浆、机械台班、机械组成物、机上人工、主材、设备、企业管理费、利润
  10. if(typeof allowGljType !== 'undefined'){
  11. allowGljType = [1, 201, 202, 203, 204, 205, 206, 301, 302, 303, 4, 5, 6, 7];
  12. }
  13. if(typeof allowComponent !== 'undefined'){
  14. //允许含有组成物的工料机类型:混凝土、砂浆、配合比、机械台班、主材
  15. allowComponent = [202, 203, 204, 301, 4];
  16. }
  17. if(typeof componentType !== 'undefined'){
  18. //可以作为组成物的工料机类型:普通材料、机械组成物、机上人工、主材
  19. componentType = [201, 302, 303, 4];
  20. }
  21. if(typeof machineAllowComponent !== 'undefined'){
  22. //允许含有组成物的机械工料机类型:机械台班
  23. machineAllowComponent = [301];
  24. }
  25. if(typeof machineComponent !== 'undefined'){
  26. //可以作为机械工料机组成物的工料机类型:机械组成物、机上人工
  27. machineComponent = [302, 303];
  28. }
  29. if(typeof materialAllowComponent !== 'undefined'){
  30. //允许含有组成物的材料工料机类型:混凝土、砂浆、配合比
  31. materialAllowComponent = [202, 203, 204];
  32. }
  33. if(typeof materialComponent !== 'undefined'){
  34. //可以作为材料工料机组成物的工料机类型:普通材料
  35. materialComponent = [201];
  36. }
  37. //覆盖前端定额基价计算
  38. //基价=人工费+材料费+机械费+管理费利润
  39. //管理费利润=Round(人工费*(管理费消耗量+利润消耗量)%,2) 注:书中管理费、利润的单位都是“%”
  40. if (typeof rationGLJOprObj !== 'undefined' && typeof rationGLJOprObj.rationCal !== 'undefined') {
  41. rationGLJOprObj.rationCal = function () {
  42. let me = rationGLJOprObj;
  43. let price = {gljType1: [], gljType2: [], gljType3: []},
  44. rst = {labourPrice: 0, materialPrice: 0, machinePrice: 0},
  45. rationBasePrc = 0;
  46. let manageProfitConsume = 0; //管理费、利润消耗量
  47. if(me.currentRationItem && me.cache['_GLJ_' + me.currentRationItem.ID]){
  48. let cacheArr = me.cache['_GLJ_' + me.currentRationItem.ID];
  49. cacheArr.forEach(function (gljData) {
  50. if(gljData.gljType && gljData.basePrice && gljData.consumeAmt){
  51. let parentGLJType = parseInt(String(gljData.gljType)[0]);
  52. if (parentGLJType <= 3) { // 人工、材料、机械
  53. // 单位为%,单条基价计算为定额价*消耗量*0.01
  54. if (gljData.unit === '%') {
  55. price['gljType' + parentGLJType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt * 0.01, -3));//取三位
  56. } else {
  57. price['gljType' + parentGLJType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, -3));//取三位
  58. }
  59. }
  60. if([6, 7].includes(gljData.gljType)){
  61. manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljData.consumeAmt, -6);
  62. }
  63. }
  64. });
  65. if(price.gljType1.length > 0){
  66. let labourPrice = 0;
  67. price.gljType1.forEach(function (singlePrc) {
  68. labourPrice = scMathUtil.roundTo(labourPrice + singlePrc, me.processDecimal);
  69. });
  70. let roundPrice = scMathUtil.roundTo(labourPrice, -2);
  71. rst.labourPrice = roundPrice;
  72. rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
  73. //管理费利润
  74. let manageProfitPrc = scMathUtil.roundTo(roundPrice * manageProfitConsume * 0.01, -2);
  75. rationBasePrc = scMathUtil.roundTo(rationBasePrc + manageProfitPrc, -2);
  76. }
  77. if(price.gljType2.length > 0){
  78. let materialPrice = 0;
  79. price.gljType2.forEach(function (singlePrc) {
  80. materialPrice = scMathUtil.roundTo(materialPrice + singlePrc, me.processDecimal);
  81. });
  82. let roundPrice = scMathUtil.roundTo(materialPrice, -2);
  83. rst.materialPrice = roundPrice;
  84. rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
  85. }
  86. if(price.gljType3.length > 0){
  87. let machinePrice = 0;
  88. price.gljType3.forEach(function (singlePrc) {
  89. machinePrice = scMathUtil.roundTo(machinePrice + singlePrc, me.processDecimal);
  90. });
  91. let roundPrice = scMathUtil.roundTo(machinePrice, -2);
  92. rst.machinePrice = roundPrice;
  93. rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
  94. }
  95. rst.rationBasePrc = rationBasePrc;
  96. }
  97. return rst;
  98. }
  99. }
  100. if (typeof module !== 'undefined') {
  101. module.exports = {
  102. // 计算定额基价
  103. calcRation: function (gljArr, scMathUtil) {
  104. let labourPrc = [],
  105. materialPrc = [],
  106. machinePrc = [],
  107. manageProfitConsume = 0,
  108. singlePrc,
  109. updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, manageProfitPrice: 0, basePrice: 0};
  110. gljArr.forEach(function (gljItem) {
  111. if(gljItem.gljParentType !== -1){
  112. if (gljItem.gljParentType <= 3 && gljItem.unit === '%') {
  113. singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt * 0.01, -3);
  114. } else {
  115. singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
  116. }
  117. if(gljItem.gljParentType === 1){
  118. labourPrc.push(singlePrc);
  119. } else if(gljItem.gljParentType ===2){
  120. materialPrc.push(singlePrc);
  121. } else if(gljItem.gljParentType === 3){
  122. machinePrc.push(singlePrc);
  123. } else if(gljItem.gljParentType === 6){
  124. manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
  125. } else if(gljItem.gljParentType === 7){
  126. manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
  127. }
  128. }
  129. });
  130. if(labourPrc.length > 0){
  131. let sumLaP = 0;
  132. for(let i=0; i<labourPrc.length; i++){
  133. sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], -6);
  134. }
  135. updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
  136. updatePrc.manageProfitPrice = scMathUtil.roundTo(updatePrc.labourPrice * manageProfitConsume * 0.01, -2);
  137. updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.manageProfitPrice, -2);
  138. }
  139. if(materialPrc.length > 0){
  140. let sumMtP = 0;
  141. for(let i= 0; i<materialPrc.length; i++){
  142. sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], -6);
  143. }
  144. updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
  145. updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.materialPrice, -2);
  146. }
  147. if(machinePrc.length > 0){
  148. let sumMaP = 0;
  149. for(let i =0; i< machinePrc.length; i++){
  150. sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], -6);
  151. }
  152. updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
  153. updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.machinePrice, -2);
  154. }
  155. return updatePrc;
  156. }
  157. };
  158. }