gljUtil.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. /**
  2. * Created by zhang on 2018/6/7.
  3. */
  4. let gljUtil = {
  5. calcProjectGLJQuantity:function (projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal,_,scMathUtil,isTender) {
  6. let project_gljs = projectGLJDatas.gljList;
  7. let mixRatioMap = projectGLJDatas.mixRatioMap;
  8. let rations = rationDatas;
  9. let rationMap = _.indexBy(rations,'ID');
  10. let quantityMap={};
  11. let rationGljGroup = _.groupBy(rationGLJDatas,'projectGLJID');
  12. let IDarray = this.getSubdivisionAndTechBillsLeavesID(billsDatas);//分别取分部分项和技术措施项目的所有叶子清单ID
  13. let billIDs = IDarray[0],tech_billIDS = IDarray[1];
  14. let sField = isTender==true?"tenderSubdivisionQuantity":"subdivisionQuantity";
  15. let tField = isTender==true?"tenderTechQuantity":"techQuantity";
  16. let qField = isTender==true?"tenderQuantity":"quantity";
  17. let mField = "materialQuantity"; //材料计算的工料机消耗量
  18. for(let pglj of project_gljs ){
  19. let pg_index = this.getIndex(pglj,this.gljKeyArray);
  20. pglj[sField] = 0;
  21. pglj[tField] = 0;
  22. pglj[qField] = 0;
  23. pglj[mField] = 0;
  24. let gljGroup = rationGljGroup[pglj.id]?rationGljGroup[pglj.id]:[];//定额工料机没有,有可能是定额类型的工料机
  25. let result = this.getQuantityPerGLJ(gljGroup,rations,rationMap,pglj,billIDs,tech_billIDS,q_decimal,_,scMathUtil,isTender);
  26. pglj[sField] = result.subdivisionQuantity;
  27. pglj[tField] = result.techQuantity;
  28. pglj[qField] = result.quantity;
  29. quantityMap[pg_index] = pglj;
  30. }
  31. //材料计算中,工料机的消耗量
  32. if(projectGLJDatas.freightList) this.setMaterialCalcQuantity(quantityMap,projectGLJDatas.freightList,q_decimal,_,scMathUtil); //运费计算中工料机的消耗量
  33. if(projectGLJDatas.originalList) this.setMaterialCalcQuantity(quantityMap,projectGLJDatas.originalList,q_decimal,_,scMathUtil);//原价计算中工料机的消耗量
  34. //计算做为组成物的消耗量
  35. for(let pkey in mixRatioMap){
  36. let mixRatioList = mixRatioMap[pkey];
  37. for(let m of mixRatioList){
  38. let m_index = this.getIndex(m,this.gljKeyArray);
  39. let m_glj = quantityMap[m_index];
  40. let p_glj = quantityMap[pkey];
  41. if(m_glj&&p_glj&&!gljUtil.isConcreteType(p_glj.type) ){//混凝土、砂浆、配合比组成物的消耗量在定额下已经有体现了,不用再计算进去
  42. let quantity = scMathUtil.roundForObj(parseFloat(p_glj[qField])*parseFloat(m.consumption),q_decimal);
  43. let techQuantity = scMathUtil.roundForObj(parseFloat(p_glj[tField])*parseFloat(m.consumption),q_decimal);
  44. let subdivisionQuantity = scMathUtil.roundForObj(parseFloat(p_glj[sField])*parseFloat(m.consumption),q_decimal);
  45. let materialQuantity = scMathUtil.roundForObj(parseFloat(p_glj[mField])*parseFloat(m.consumption),q_decimal);
  46. m_glj[qField] = scMathUtil.roundForObj(parseFloat(m_glj[qField])+quantity,q_decimal);
  47. m_glj[tField] = scMathUtil.roundForObj(parseFloat(m_glj[tField])+techQuantity,q_decimal);
  48. m_glj[sField] = scMathUtil.roundForObj(parseFloat(m_glj[sField])+subdivisionQuantity,q_decimal);
  49. m_glj[mField] = scMathUtil.roundForObj(parseFloat(m_glj[mField])+materialQuantity,q_decimal);
  50. }
  51. }
  52. }
  53. //计算经过场外运输损耗后的总消耗量
  54. for(let pglj of project_gljs ){
  55. let offSiteTransportLossRate = this.getOffSiteTransportLossRate(pglj);
  56. pglj.offSiteTransportLossRate = parseFloat(offSiteTransportLossRate);//scMathUtil.roundForObj(offSiteTransportLossRate,getDecimal("glj.unitPrice")) ;这里再取小数位数太麻烦了,暂时用保存的吧
  57. offSiteTransportLossRate = offSiteTransportLossRate/100;
  58. pglj.transportLossQuantity = scMathUtil.roundForObj(pglj.quantity*offSiteTransportLossRate,q_decimal);
  59. pglj.quantity = scMathUtil.roundForObj(pglj.quantity + pglj.transportLossQuantity ,q_decimal);
  60. }
  61. },
  62. setMaterialCalcQuantity:function (quantityMap,calcList,q_decimal,_,scMathUtil) {
  63. for(let t of calcList){
  64. let rationIDMap = _.indexBy(t.rations,"ID");
  65. if(t.ration_gljs){
  66. for(let rg of t.ration_gljs){
  67. let rIndex = this.getIndex(rg);
  68. let pglj = quantityMap[rIndex];
  69. let ration = rationIDMap[rg.rationID];
  70. if(pglj && ration){
  71. let rg_quantity = scMathUtil.roundForObj(rg.quantity,q_decimal);
  72. let r_quantity = scMathUtil.roundForObj(ration.quantity,q_decimal);
  73. let result = scMathUtil.roundForObj(rg_quantity * r_quantity,q_decimal);
  74. pglj.quantity = scMathUtil.roundForObj(pglj.quantity + result,q_decimal);
  75. pglj.materialQuantity = scMathUtil.roundForObj(pglj.materialQuantity + result,q_decimal);
  76. }
  77. }
  78. }
  79. }
  80. },
  81. getOffSiteTransportLossRate:function (pglj) {
  82. let offSiteTransportLossRate;//场外运输损耗率
  83. let handlingLossRate;//每增加一次装卸损耗率
  84. let totalLoadingTimes = 1;//没有材料计算,获取不到装卸总次数,则按1计算
  85. //场外总损耗率=场外运输损耗率%+(装卸总次数-1)*每增加一次装卸损耗率%。
  86. if(pglj.unit_price){
  87. if(pglj.unit_price.calcMaterial == 1){//如果是材料计算,则用修改过的新值
  88. offSiteTransportLossRate = pglj.unit_price.offSiteTransportLossRate_n;
  89. handlingLossRate = pglj.unit_price.handlingLossRate_n;
  90. if(pglj.unit_price.totalLoadingTimes && pglj.unit_price.totalLoadingTimes > 1) totalLoadingTimes = parseFloat(pglj.unit_price.totalLoadingTimes)
  91. } else {
  92. offSiteTransportLossRate = pglj.unit_price.offSiteTransportLossRate;
  93. handlingLossRate = pglj.unit_price.handlingLossRate;
  94. }
  95. }
  96. offSiteTransportLossRate = offSiteTransportLossRate?parseFloat(offSiteTransportLossRate):0;
  97. handlingLossRate = handlingLossRate?parseFloat(handlingLossRate):0;
  98. // 场外运输损耗率%+(装卸总次数-1)*每增加一次装卸损耗率%
  99. return (offSiteTransportLossRate + (totalLoadingTimes - 1) * handlingLossRate);
  100. },
  101. getQuantityPerGLJ : function (ration_glj_list,rations,rationMap,pglj,billIDs,tech_billIDS,q_decimal,_,scMathUtil,isTender) {
  102. let result={};
  103. let quantity_sum=0;//工料机汇总消耗量
  104. let sum = 0;//分部分项总消耗量
  105. let tech_sum = 0;//技术措施总消耗量
  106. for(let rg of ration_glj_list){
  107. let tem_ration = rationMap[rg.rationID];
  108. let r_quantity = tem_ration?scMathUtil.roundForObj(tem_ration.quantity,q_decimal):0;
  109. let glj_quantity = scMathUtil.roundForObj(rg.quantity, q_decimal);
  110. if(!r_quantity){
  111. continue;
  112. }
  113. if(isTender == true){
  114. glj_quantity = this.getRationGLJTenderQuantity(rg,tem_ration,q_decimal,scMathUtil);
  115. r_quantity = this.getRationTenderQuantity(tem_ration,q_decimal,scMathUtil);
  116. }
  117. let total = scMathUtil.roundForObj(glj_quantity*r_quantity, q_decimal);
  118. quantity_sum = scMathUtil.roundForObj(quantity_sum+total,q_decimal);
  119. if(_.includes(billIDs,rg.billsItemID)){//计算分部分项
  120. sum = scMathUtil.roundForObj(sum+total,q_decimal);
  121. }
  122. if(_.includes(tech_billIDS,rg.billsItemID)){//计算技术措施项目消耗量
  123. tech_sum = scMathUtil.roundForObj(tech_sum+total,q_decimal);
  124. }
  125. }
  126. for(let ra of rations){//计算定额类型工料机的消耗量
  127. if(ra.type == this.rationType.gljRation&&ra.projectGLJID===pglj.id){
  128. let r_quantity = scMathUtil.roundForObj(ra.quantity,q_decimal);
  129. r_quantity = r_quantity?r_quantity:0;
  130. if(isTender == true){
  131. r_quantity = this.getRationTenderQuantity(ra,q_decimal,scMathUtil);
  132. }
  133. quantity_sum = scMathUtil.roundForObj(quantity_sum+r_quantity,q_decimal);
  134. if(_.includes(billIDs,ra.billsItemID)){//计算分部分项
  135. sum = scMathUtil.roundForObj(sum+r_quantity,q_decimal);
  136. }
  137. if(_.includes(tech_billIDS,ra.billsItemID)){//计算技术措施项目消耗量
  138. tech_sum = scMathUtil.roundForObj(tech_sum+r_quantity,q_decimal);
  139. }
  140. }
  141. }
  142. result.subdivisionQuantity = sum;
  143. result.techQuantity = tech_sum;
  144. result.quantity = quantity_sum;
  145. return result;
  146. },
  147. getRationGLJTenderQuantity:function (ration_glj,ration,q_decimal,scMathUtil) {
  148. let coeMap = {
  149. 1:'labour', //人工
  150. 2:'material',//材料
  151. 3:'machine',//机械
  152. 4:'main', //主材
  153. 5:'equipment'//设备
  154. };
  155. let typeString = ration_glj.type +"";
  156. let coeField = "";
  157. for(let key in coeMap){
  158. if(typeString.indexOf(key)!= -1){
  159. coeField = coeMap[key];
  160. }
  161. }
  162. let coe = ration.quantityCoe&&this.isNotEmpty(ration.quantityCoe[coeField])?ration.quantityCoe[coeField]:1;
  163. coe = parseFloat(coe);
  164. let glj_quantity = scMathUtil.roundForObj(ration_glj.quantity, q_decimal);
  165. return scMathUtil.roundForObj(glj_quantity * coe,q_decimal);
  166. },
  167. getRationTenderQuantity:function (ration,q_decimal,scMathUtil) {
  168. let rationQuantityCoe = this.isNotEmpty(ration.rationQuantityCoe)?ration.rationQuantityCoe:1;
  169. rationQuantityCoe = parseFloat(rationQuantityCoe);
  170. let r_quantity = ration?scMathUtil.roundForObj(ration.quantity,q_decimal):0;
  171. return scMathUtil.roundForObj(r_quantity * rationQuantityCoe,q_decimal);
  172. },
  173. isNotEmpty:function (str) {
  174. return this.isDef(str) && str!="";
  175. },
  176. getSubdivisionAndTechBillsLeavesID:function (billsDatas) {//分别取分部分项和技术措施项目的所有叶子清单ID
  177. if(typeof (projectObj) !== 'undefined'){//存在,说明在前端调用
  178. return [projectObj.project.Bills.getSubdivisionProjectLeavesID(),projectObj.project.Bills.getTechLeavesID()];
  179. }
  180. let parentMap ={};
  181. let subdivisionBillID = null,techBillID = null,sIDs = [],tIDS = [];
  182. for(let b of billsDatas){
  183. if(parentMap[b.ParentID]){
  184. parentMap[b.ParentID].push(b);
  185. }else {
  186. parentMap[b.ParentID]= [b];
  187. }
  188. let flag = this.getFlag(b);
  189. if(this.isDef(flag)&&flag.flag == this.fixedFlag.SUB_ENGINERRING){
  190. subdivisionBillID = b.ID;
  191. }
  192. if(this.isDef(flag)&&flag.flag == this.fixedFlag.CONSTRUCTION_TECH){
  193. techBillID = b.ID;
  194. }
  195. }
  196. getLeaveIDs(subdivisionBillID,parentMap,sIDs);
  197. getLeaveIDs(techBillID,parentMap,tIDS);
  198. return [sIDs,tIDS];
  199. function getLeaveIDs(ID,parentM,leaveIDs) {
  200. if(parentM[ID] && parentM[ID].length > 0){
  201. let children = parentM[ID];
  202. for(let c of children){
  203. if(parentM[c.ID]){
  204. getLeaveIDs(c.ID,parentM,leaveIDs);
  205. }else {
  206. leaveIDs.push(c.ID);
  207. }
  208. }
  209. }
  210. }
  211. },
  212. getFlag:function (b) {
  213. return _.find(b.flags,{"fieldName":"fixed"});
  214. },
  215. getGLJPrice:function (glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil) {
  216. let result = {};
  217. result.marketPrice = this.getMarketPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
  218. if(this.calcPriceDiff(glj,calcOptions)==true){//计取价差
  219. result.basePrice = this.getBasePrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
  220. result.adjustPrice = this.getAdjustPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
  221. }else {//不计价差
  222. result.basePrice = result.marketPrice;
  223. result.adjustPrice = result.marketPrice;
  224. }
  225. return result;
  226. },
  227. getMarketPrice:function (glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil,tenderCoe) {
  228. let price_decimal = decimalObj.glj.unitPrice;
  229. let price_hasM_decimal = decimalObj.glj.unitPriceHasMix?decimalObj.glj.unitPriceHasMix:decimalObj.glj.unitPrice;
  230. let quantity_decimal = decimalObj.glj.quantity;
  231. let process_decimal = decimalObj.process;
  232. let priceCoe = this.isDef(tenderCoe)?tenderCoe:1;
  233. if (!this.isConcreteType(glj.unit_price.type)&& this.notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于机械台班等有组成物的材料,价格需根据组成物计算得出(排除混凝土、配合比、砂浆这几个类型直接为0)。
  234. let p =0;
  235. for(let ratio of glj.ratio_data){
  236. let tem = _.find(projectGLJDatas.gljList,{
  237. 'code': ratio.code,
  238. 'name': ratio.name,
  239. 'specs':ratio.specs,
  240. 'type': ratio.type,
  241. 'unit': ratio.unit
  242. });
  243. if(tem){
  244. let priceData=this.getGLJPrice(tem,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,true,_,scMathUtil);
  245. let temP = scMathUtil.roundForObj(priceData.marketPrice* priceCoe * scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
  246. p = scMathUtil.roundForObj(temP + p,process_decimal);
  247. }
  248. }
  249. return scMathUtil.roundForObj(p,price_hasM_decimal);
  250. }else {
  251. let tem_decimal =price_decimal; //isRadio==true?process_decimal:price_decimal;
  252. let tem_price = scMathUtil.roundForObj(glj.unit_price.market_price,price_decimal);
  253. return scMathUtil.roundForObj(tem_price*priceCoe,tem_decimal);
  254. }
  255. },
  256. getBasePrice:function (glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil) {
  257. let price_decimal = decimalObj.glj.unitPrice;
  258. let price_hasM_decimal = decimalObj.glj.unitPriceHasMix?decimalObj.glj.unitPriceHasMix:decimalObj.glj.unitPrice;
  259. let quantity_decimal = decimalObj.glj.quantity;
  260. let process_decimal = decimalObj.process;
  261. if (this.notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班等有组成物的材料,价格需根据组成物计算得出。
  262. //2018-09-07 需求修改,定额价不按组成物的量和价实时计算出来,直接取单价文件中的定额价
  263. /* let p =0;
  264. for(let ratio of glj.ratio_data){
  265. let tem = _.find( projectGLJDatas.gljList,{
  266. 'code': ratio.code,
  267. 'name': ratio.name,
  268. 'specs':ratio.specs,
  269. 'type': ratio.type,
  270. 'unit': ratio.unit
  271. });
  272. if(tem){
  273. let priceData=this.getGLJPrice(tem,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,true,_,scMathUtil);
  274. let temP = scMathUtil.roundForObj(priceData.basePrice*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
  275. p = scMathUtil.roundForObj(temP + p,process_decimal);
  276. }
  277. }
  278. return scMathUtil.roundForObj(p,price_hasM_decimal);*/
  279. return scMathUtil.roundForObj(glj.unit_price.base_price,price_hasM_decimal);
  280. }else {
  281. let tem_decimal =price_decimal; //isRadio==true?process_decimal:price_decimal;
  282. return scMathUtil.roundForObj(glj.unit_price.base_price,tem_decimal);
  283. }
  284. },
  285. getAdjustPrice:function (glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil) {
  286. let decimal = decimalObj.glj.unitPrice;
  287. let price_hasM_decimal = decimalObj.glj.unitPriceHasMix?decimalObj.glj.unitPriceHasMix:decimalObj.glj.unitPrice;
  288. let quantity_decimal = decimalObj.glj.quantity;
  289. let process_decimal = decimalObj.process;
  290. let tem_decimal = isRadio==true?process_decimal:decimal;
  291. if (glj.unit_price.type == this.gljType.LABOUR || glj.unit_price.type == this.gljType.MACHINE_LABOUR) {//人工、机上人工,调整价根据定额价*调整系数计算得出。
  292. let labour = _.find(labourCoeDatas.coes,{'ID':glj.adjCoe});
  293. let coe = labour && labour.coe ? labour.coe : 1;
  294. return scMathUtil.roundTo(parseFloat(coe * scMathUtil.roundForObj(glj.unit_price.base_price,decimal)), -decimal);
  295. } else if (this.notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
  296. let p =0;
  297. for(let ratio of glj.ratio_data){
  298. let tem = _.find( projectGLJDatas.gljList,{
  299. 'code': ratio.code,
  300. 'name': ratio.name,
  301. 'specs':ratio.specs,
  302. 'type': ratio.type,
  303. 'unit': ratio.unit
  304. })
  305. if(tem){
  306. let priceData=this.getGLJPrice(tem,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,true,_,scMathUtil);
  307. let temP = scMathUtil.roundForObj(priceData.adjustPrice*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
  308. p = scMathUtil.roundForObj(temP + p,process_decimal);
  309. }
  310. }
  311. return scMathUtil.roundForObj(p,price_hasM_decimal);
  312. } else {//对于其他普通材料等,无调整系数,调整价=定额价。
  313. return scMathUtil.roundForObj(glj.unit_price.base_price,decimal)
  314. }
  315. },
  316. calcPriceDiff:function (glj,calcOptions) {
  317. if(glj.is_evaluate==1){//先按是否暂估判断
  318. return calcOptions.calc_est;
  319. }
  320. if(glj.type==this.gljType.MAIN_MATERIAL||glj.type==this.gljType.EQUIPMENT){//再判断是否是主材和设备
  321. return calcOptions.calc_main;
  322. }
  323. if(glj.unit_price.is_add==1){//再判断是否新增
  324. return calcOptions.calc_add;
  325. }
  326. return true;
  327. },
  328. isFlag : function (v) {
  329. return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed) && this.isDef(v.flagsIndex.fixed.flag);
  330. },
  331. isDef:function (v) {
  332. return v !== undefined && v !== null;
  333. },
  334. getIndex(obj, pops){
  335. let t_index = '';
  336. let k_arr = [];
  337. if(!this.isDef(pops)) pops = this.gljKeyArray;
  338. for (let p of pops) {
  339. let tmpK = (obj[p] == undefined || obj[p] == null || obj[p] == '') ? 'null' : obj[p];
  340. k_arr.push(tmpK);
  341. }
  342. t_index = k_arr.join("|-|");
  343. return t_index;
  344. },
  345. getMainType:function (type) {
  346. let str = type + "";
  347. return parseInt(str.substr(0,1));
  348. },
  349. sortRationGLJ:function (list, std) {
  350. const field = std ? 'gljType' : 'type';
  351. list = _.sortByAll(list, [function (item) {
  352. return gljUtil.getMainType(item[field]);
  353. }, gljUtil.getCodeSortMath()]);
  354. return list;
  355. },
  356. sortMixRatio:function (list) {
  357. return _.sortByAll(list, ["code"]);
  358. },
  359. //项目工料机 混凝土、砂浆、配合比排序与定额工料机不一样,同时,type取值的地方不一样
  360. sortProjectGLJ:function (list,lodash) {
  361. let lo = lodash?lodash:_;
  362. let specialMap = {1:-1,303:0,202:9,203:10,204:11};//,人工、机械工排在最前,混凝土、砂浆、配合比 排到最后
  363. list = lo.sortByAll(list, [function (item) {
  364. if(specialMap[item.unit_price.type] != undefined) return specialMap[item.unit_price.type];
  365. return gljUtil.getMainType(item.unit_price.type);
  366. }, gljUtil.getCodeSortMath()]);
  367. return list;
  368. },
  369. getCodeSortMath:function () {
  370. return "code"
  371. },
  372. isConcreteType:function (type) {
  373. let concreteType = [gljUtil.gljType.CONCRETE,gljUtil.gljType.MORTAR,gljUtil.gljType.MIX_RATIO];//混凝土大类:混凝土、砂浆,配合比
  374. return concreteType.indexOf(type)!=-1
  375. },
  376. isCommercialConcreteType:function (type) {
  377. let commercialType = [gljUtil.gljType.COMMERCIAL_CONCRETE,gljUtil.gljType.COMMERCIAL_MORTAR];//商品混凝土、商品砂浆
  378. return commercialType.indexOf(type)!=-1
  379. },
  380. //是否从混凝土改成商品混凝土,并且混凝土的定额消耗量不为空,则原混凝土的自定义消耗改成0,插入一条新的商品混凝土自定义消耗量为原自定义或定额消耗
  381. isAddCommercialForReplace:function (oldType,newType,rationItemQuantity) {
  382. return gljUtil.isConcreteToCommercialConcrete(oldType,newType)&&rationItemQuantity&&rationItemQuantity!='0';
  383. },
  384. isMaterialType:function (type) {
  385. let materialType = [gljType.GENERAL_MATERIAL,gljType.GREEN_SEEDLING,gljType.PURCHASE_COMPONENT,gljType.COMMERCIAL_CONCRETE,gljType.COMMERCIAL_MORTAR];//可以添加材料计算的类型普通材料”、“绿化苗木”、“外购砼构件”、“商品混凝土”、“商品砂浆”
  386. return materialType.indexOf(type)!= -1
  387. },
  388. isConcreteToCommercialConcrete:function (oldType,newType) {
  389. return gljUtil.isConcreteType(oldType)&&gljUtil.isCommercialConcreteType(newType)
  390. },
  391. hasComposition:function (ration_glj,isRationType) {//判断是否有组成物,有则返回true 现在主材类型的工料机也有可能有组成物。
  392. let type = isRationType==true? ration_glj.subType:ration_glj.type;
  393. if(gljUtil.notEditType.indexOf(type)!=-1||type==gljType.MAIN_MATERIAL){
  394. let keyArray = isRationType==true? rationKeyArray:gljKeyArray;
  395. let con_key = gljUtil.getIndex(ration_glj,keyArray);
  396. var mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
  397. if(mixRatioMap[con_key]&&mixRatioMap[con_key].length>0){
  398. return true;
  399. }
  400. }
  401. return false;
  402. },
  403. getCCSProjectGLJ: function (unitFileID,project_id){
  404. return {"ratio_data":[],"unit_price":{"base_price":"1","market_price":"1","code":"80CCS","name":"车船税","unit_price_file_id":unitFileID,"type":302,"short_name":"机","glj_id":-99,"unit":"元","original_code":"80CCS","id":-99,"is_add":0,"specs":""},"glj_id":-99,"project_id":project_id,"code":"80CCS","unit":"元","type":302,"original_code":"80CCS","id":-99,"from":"std","is_main_material":1,"specs":"","is_adjust_price":0,"delivery_address":"","delivery":"","supply_quantity":0,"supply":0,"is_evaluate":0,"name":"车船税"}
  405. },
  406. getBaseCCSMixRatio:function (unitFileID,consumption,connect_key) {
  407. return {glj_id:-99,unit_price_file_id:unitFileID,connect_key:connect_key,consumption:consumption,code:'80CCS',name:'车船税',unit:'元',type:302,specs:''}
  408. },
  409. updateProperty: function (obj, doc) {
  410. _.forEach(doc, function (n, key) {
  411. obj[key] = n;
  412. });
  413. },
  414. getTotalQuantity:function(glj,ration,rd,gd){
  415. if(ration){
  416. let quantity = ration.quantity;
  417. quantity = (quantity == 0 || quantity == undefined || quantity == null || quantity == "") ? 0 : quantity;
  418. quantity = scMathUtil.roundForObj(quantity, rd);//计算前进行4舍5入
  419. glj.quantity = scMathUtil.roundForObj(glj.quantity, gd);
  420. return scMathUtil.roundToString(quantity * glj.quantity, gd);
  421. }
  422. },
  423. setMaterialCalcRationFee:function (ration,ration_gljs,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,_,scMathUtil) {
  424. let pMap =_.indexBy(projectGLJDatas.gljList, 'id');
  425. let process_decimal = decimalObj.process;
  426. let ration_quantity_decimal = decimalObj.ration.quantity;
  427. let glj_quantity_decimal = decimalObj.glj.quantity;
  428. let glj_unitPrice_decimal = decimalObj.glj.unitPrice;
  429. let assFeeRate = scMathUtil.roundForObj(projectGLJDatas.constData.assistProductionFeeRate,decimalObj.feeRate) * 0.01;//辅助生产间接费费率
  430. let rationLaberFee = 0; //定额人工费(市场价)
  431. let rationMachineFee = 0; //定额施工机械使用费(市场价)
  432. let rationLaberFee_b = 0; //定额人工费(定额价)
  433. let rationMachineFee_b = 0; //定额施工机械使用费(定额价)
  434. let directFee = 0;//直接费
  435. let rationQuantity = scMathUtil.roundForObj(ration.quantity,ration_quantity_decimal);
  436. for(let g of ration_gljs){
  437. let result = gljUtil.getGLJPrice(pMap[g.projectGLJID],projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,false,_,scMathUtil);
  438. g.marketPrice = result.marketPrice;
  439. g.basePrice = result.basePrice;
  440. let quantity = scMathUtil.roundForObj(g.quantity,glj_quantity_decimal);
  441. let t = scMathUtil.roundForObj(quantity * g.marketPrice * rationQuantity,process_decimal);//市场价
  442. let rt = scMathUtil.roundForObj(quantity * g.basePrice * rationQuantity,process_decimal);//定额价
  443. if(g.type == gljUtil.gljType.LABOUR){
  444. rationLaberFee = scMathUtil.roundForObj(rationLaberFee+t,process_decimal);
  445. rationLaberFee_b = scMathUtil.roundForObj(rationLaberFee_b+rt,process_decimal);
  446. }else if(gljUtil.getMainType(g.type) == 3){
  447. rationMachineFee = scMathUtil.roundForObj(rationMachineFee+t,process_decimal);
  448. rationMachineFee_b = scMathUtil.roundForObj(rationMachineFee_b+rt,process_decimal);
  449. }
  450. directFee = scMathUtil.roundForObj(directFee + t,process_decimal);
  451. }
  452. ration.assistProductionFee = scMathUtil.roundForObj(rationLaberFee_b * assFeeRate,glj_unitPrice_decimal);//辅助生产间接费
  453. ration.rationLaberFee = scMathUtil.roundForObj(rationLaberFee,glj_unitPrice_decimal);//定额人工费(市场价)
  454. ration.rationMachineFee = scMathUtil.roundForObj(rationMachineFee,glj_unitPrice_decimal);//定额施工机械使用费(市场价)
  455. ration.directFee = scMathUtil.roundForObj(directFee,glj_unitPrice_decimal);//直接费
  456. //to do 高原取费类别的情况待确认
  457. //let hs = scMathUtil.roundForObj(tt*hightFeeRate,process_decimal);//(人工定额消耗量*定额价*定额工程量+机械定额消耗量*定额价*定额工程量)*高原取费类别费率
  458. },
  459. fixedFlag : {
  460. // 分部分项工程
  461. SUB_ENGINERRING: 1,
  462. // 措施项目
  463. MEASURE: 2,
  464. // 施工技术措施项目
  465. CONSTRUCTION_TECH: 3
  466. },
  467. gljType : {
  468. LABOUR: 1, // 人工
  469. // ==============材料类型 ↓=================
  470. GENERAL_MATERIAL: 201, // 普通材料
  471. CONCRETE: 202, // 混凝土
  472. MORTAR: 203, // 砂浆
  473. MIX_RATIO: 204, // 配合比
  474. COMMERCIAL_CONCRETE: 205, // 商品混凝土
  475. COMMERCIAL_MORTAR: 206, // 商品砂浆
  476. OTHER_MATERIAL: 207, // 其它材料
  477. PURCHASE_COMPONENT: 208, // 外购砼构件
  478. GREEN_SEEDLING: 209, // 绿化苗木
  479. // ==============材料类型 ↑=================
  480. // ==============机械类型 ↓=================
  481. GENERAL_MACHINE: 301, // 机械台班
  482. MACHINE_COMPOSITION: 302, // 机械组成物
  483. MACHINE_LABOUR: 303, // 机上人工
  484. INSTRUMENT: 304, // 仪器仪表
  485. FUEL_POWER_FEE:305, // 燃料动力费
  486. DEPRECIATION_FEE:306, // 折旧费
  487. INSPECTION_FEE:307, // 检修费
  488. MAINTENANCE:308, // 维护费
  489. DISMANTLING_FREIGHT_FEE:309, // 安拆费及场外运费
  490. VERIFICATION_FEE:310, // 校验费
  491. OTHER_FEE:311, // 其他费用
  492. OTHER_MACHINE_USED:312, // 其他施工机具使用费
  493. // ==============机械类型 ↑=================
  494. MAIN_MATERIAL: 4, // 主材
  495. EQUIPMENT: 5, // 设备
  496. MANAGEMENT_FEE: 6, // 企业管理费
  497. PROFIT: 7, // 利润
  498. GENERAL_RISK_FEE: 8 // 一般风险费
  499. },
  500. extraType:[6,7,8],//一些其它的工料机类型
  501. notEditType : [202,203,204,301,304,4],
  502. gljKeyArray : ['code','name','specs','unit','type'],
  503. rationType : {
  504. ration: 1,
  505. volumePrice: 2,
  506. gljRation: 3,
  507. install:4
  508. },
  509. hasCompMaterial:[202, 203, 204],//有组成物的材料
  510. hasCompMachine:[301],//有组成物的机械
  511. machineComposition:[302,303]//可以做为机械组成物的类型
  512. }