glj_calculate_facade.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /**
  2. * Created by chen on 2017/7/12.
  3. */
  4. let mongoose = require('mongoose');
  5. let _=require("lodash");
  6. let ration_glj = mongoose.model('ration_glj');
  7. let ration = mongoose.model('ration');
  8. let ration_coe = mongoose.model('ration_coe');
  9. const ProjectModel = require('../../pm/models/project_model').project;
  10. let mixRatioModel = mongoose.model('mix_ratio');
  11. let std_ration_lib_ration_items = mongoose.model('std_ration_lib_ration_items');
  12. let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
  13. let glj_type_util = require('../../../public/cache/std_glj_type_util');
  14. const scMathUtil = require('../../../public/scMathUtil').getUtil();
  15. let decimal_facade = require('../../main/facade/decimal_facade');
  16. let gljUtil = require('../../../public/gljUtil');
  17. module.exports={
  18. calculateQuantity:calculateQuantity,
  19. getGLJTypeByID:getGLJTypeByID
  20. }
  21. //辅助定额调整、替换工料机、标准附注条件调整、添加工料机、自定义消耗量(包括删除工料机)、自定义乘系数、市场单价调整
  22. let stateSeq ={
  23. ass:1,
  24. replace:2,
  25. coe:3,
  26. add:4,
  27. cusQuantity:5,
  28. cusCoe:6,
  29. adjMak:7
  30. };
  31. //自定义乘系数与定额工料机类型映射表
  32. let coeTypeMap = {
  33. "人工":1,
  34. "材料":2,
  35. "机械":3,
  36. "施工机具":3,
  37. "主材":4,
  38. "设备":5
  39. };
  40. async function calculateQuantity(query,noNeedCal=null,refreshRationName = false){
  41. try {
  42. let result ={
  43. glj_result:[],
  44. rationID:query.rationID
  45. };
  46. let impactRation = await ration.findOne({ID:query.rationID,projectID:query.projectID});
  47. let gljList = await ration_glj.find(query);//{projectID:query.projectID,rationID:query.rationID}
  48. let coeList = await ration_coe.find({projectID:query.projectID,rationID:query.rationID}).sort('seq').exec();
  49. let assList=[], assRation = null, adjustState=[],mixRatioMap = {};
  50. if(!impactRation){//如果定额不存在或者已删除,返回空
  51. return null;
  52. }
  53. if(impactRation._doc.hasOwnProperty("rationAssList")&&impactRation.rationAssList.length>0){
  54. prepareAss(impactRation.rationAssList);
  55. let temTimes = [];
  56. let thirdRationCodes=[];
  57. for(let i=0;i<impactRation.rationAssList.length;i++){
  58. let times = calculateTimes(impactRation.rationAssList[i]);
  59. if(times!=0){
  60. let thirdRationCode = impactRation.rationAssList[i].thirdRationCode;
  61. if(thirdRationCode && thirdRationCode !=''){
  62. temTimes.push(times);
  63. thirdRationCodes.push(thirdRationCode)
  64. }
  65. assRation = await std_ration_lib_ration_items.findOne({rationRepId:impactRation.libID,code:impactRation.rationAssList[i].assistCode});
  66. assList.push({times:times,assRation:assRation});
  67. adjustState.push({index:stateSeq.ass,content:impactRation.rationAssList[i].name+" "+impactRation.rationAssList[i].actualValue+" : +"+impactRation.rationAssList[i].assistCode+"x"+times});
  68. }
  69. }
  70. if(temTimes.length == 2 &&thirdRationCodes[0] == thirdRationCodes[1] ){ //说明有第三定额
  71. let times_t = temTimes[0] * temTimes[1];
  72. let tration = await std_ration_lib_ration_items.findOne({rationRepId:impactRation.libID,code:thirdRationCodes[0]});
  73. if(tration){
  74. assList.push({times:times_t,assRation:tration});
  75. adjustState.push({index:stateSeq.ass,content:"+"+thirdRationCodes[0]+"x"+times_t});
  76. }
  77. }
  78. }
  79. for(let glj of gljList){//先把混凝土,砂浆,配合比有自定义消耗的挑出来
  80. if(gljUtil.isConcreteType(glj.type)) await getMixRatioMap(glj,gljList,coeList,assList,mixRatioMap);
  81. }
  82. gljList = gljUtil.sortRationGLJ(gljList);
  83. for(let i =0;i<gljList.length;i++ ){
  84. let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,mixRatioMap,noNeedCal);
  85. result.glj_result.push(r);
  86. }
  87. if(noNeedCal==null){
  88. await ration_glj.bulkWrite(generateUpdateTasks(result.glj_result));
  89. }
  90. adjustState= _.sortByOrder(adjustState, ['index'], ['asc']);
  91. adjustState=_.map(adjustState, _.property('content'));
  92. let adjustStateString = adjustState.join(';');
  93. let setData = {adjustState:adjustStateString};
  94. if(refreshRationName == true){//需要更新定额名称
  95. let newName = generateRationName(impactRation,gljList);
  96. setData.name = newName;
  97. result.rationName = newName;
  98. }
  99. await ration.update({projectID:query.projectID,ID:query.rationID,deleteInfo: null},setData);
  100. result.adjustState=adjustStateString;
  101. return result;
  102. }catch (err){
  103. console.log(err);
  104. throw err;
  105. }
  106. }
  107. function generateRationName(ration,gljList) {
  108. let caption = ration.caption ? ration.caption:ration.name;
  109. let replaceList = [];
  110. if(ration.rationAssList && ration.rationAssList.length > 0){//这里要处理第三定额和多辅助定额的情况
  111. let isThird = ration.rationAssList.length == 2 && ration.rationAssList[0].thirdRationCode&&ration.rationAssList[0].thirdRationCode!='';//说明有第三定额的情况
  112. let adjustMatch = "",notAdjust="";
  113. for(let ass of ration.rationAssList){
  114. let tem = "";
  115. if( ass.isAdjust == 1 && ass.actualValue != null && ass.actualValue != undefined ){
  116. tem = ass.actualValue;
  117. adjustMatch = tem;
  118. }else {
  119. tem = ass.stdValue;
  120. notAdjust = tem;
  121. }
  122. if(isThird) replaceList.push(tem);
  123. }
  124. if(replaceList.length == 0){
  125. adjustMatch!=""?replaceList.push(adjustMatch):replaceList.push(notAdjust);
  126. }
  127. for(let r of replaceList){
  128. caption = caption.replace('%s',r);
  129. }
  130. }
  131. let reNameList = [];
  132. for(let g of gljList){
  133. //glj._doc.createType=='replace'&&glj.rcode!=glj.code
  134. if(g.createType=='replace'&&g.rcode!=g.code){ //是替换工料机
  135. let reName = g.name;
  136. if(!_.isEmpty(g.specs)) reName = reName + ' '+g.specs;
  137. reNameList.push(reName);
  138. }
  139. }
  140. if(reNameList.length > 0){
  141. let reNameString = reNameList.join(" ");
  142. caption = caption + " 换为【"+ reNameString + "】";
  143. }
  144. return caption;
  145. }
  146. function generateUpdateTasks(result) {
  147. let tasks = [];
  148. for(let i =0;i<result.length;i++){
  149. let task= {
  150. updateOne: {
  151. filter: result[i].query,
  152. update: result[i].doc
  153. }
  154. }
  155. tasks.push(task);
  156. }
  157. return tasks;
  158. }
  159. async function calcWhenNoCustomQuantiyt(decimal,glj,gljList,coeList,assList) {
  160. let quantity = glj.rationItemQuantity ? scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal):0;
  161. quantity =scMathUtil.roundTo(await calculateAss(quantity,assList,glj),-decimal);
  162. quantity = calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal);
  163. return quantity;
  164. }
  165. async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,mixRatioMap,noNeedCal) {
  166. let decimalObject = await decimal_facade.getProjectDecimal(glj.projectID);
  167. let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
  168. let quantity = scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
  169. let result={
  170. query:{
  171. ID:glj.ID,
  172. projectID:glj.projectID
  173. },
  174. doc:{
  175. quantity: quantity
  176. }
  177. };
  178. try {
  179. if(noNeedCal==null){//计算顺序:辅助定额,附注条件,自定义消耗(如果有就不用前计算两项),自定义乘系数
  180. if(noCustomQuantiyt(glj)){
  181. quantity = await calcWhenNoCustomQuantiyt(decimal,glj,gljList,coeList,assList);
  182. let mIndex = gljUtil.getIndex(glj);
  183. if(mixRatioMap[mIndex]){//组成物
  184. quantity = calcQuantityForMix(quantity,mixRatioMap[mIndex],decimal);
  185. }
  186. }else {//对于有自定义消耗量的,并且是混凝土,浆砂,配合比 这三种类型,其组成物的消耗量要跟据自定义消耗量做相应的换算
  187. quantity = glj.customQuantity;
  188. result.doc.customQuantity = glj.customQuantity;
  189. }
  190. let customerCoe = _.last(coeList);
  191. if(customerCoe&&customerCoe.isAdjust==1){
  192. quantity = scMathUtil.roundToString(quantity,decimal);
  193. quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj,decimal);
  194. }
  195. if(quantity < 0) quantity = 0;
  196. result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
  197. //2019-01-03 需求修改中间过程的价格不参与计算
  198. //glj.quantity = quantity;//这里保存中间过程计算出来的消耗量,后面处理“+*”操作符时要用到
  199. }
  200. generateAdjustState(glj,coeList,adjustState,gljList,result.doc.quantity);
  201. return result;
  202. }catch (err){
  203. throw err;
  204. }
  205. }
  206. function calcQuantityForMix(quantity,plist,decimal) {
  207. for(let pglj of plist){
  208. let consumption = scMathUtil.roundForObj(pglj.consumption,decimal);
  209. let customQuantity = scMathUtil.roundForObj(pglj.customQuantity,decimal);
  210. let temQuantity = scMathUtil.roundForObj(consumption * pglj.assCoeQuantity,6);
  211. let pcustomQuantity = scMathUtil.roundForObj(consumption * customQuantity,6);
  212. quantity = scMathUtil.roundForObj(quantity - temQuantity,6);
  213. quantity = scMathUtil.roundForObj(quantity + pcustomQuantity,decimal);
  214. }
  215. return quantity;
  216. }
  217. async function getMixRatioMap(glj,gljList,coeList,assList,mixRatioMap) {//生成组成物对应的父工料机的映射表
  218. let decimalObject = await decimal_facade.getProjectDecimal(glj.projectID);
  219. let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
  220. let assCoeQuantity = await calcWhenNoCustomQuantiyt(decimal,glj,gljList,coeList,assList);//计算要用父工料机经过辅助子目换算后的量
  221. let unitPriceFileId = await ProjectModel.getUnitPriceFileId(glj.projectID);
  222. let connect_key = gljUtil.getIndex(glj);
  223. let mixList = await mixRatioModel.find({"unit_price_file_id":unitPriceFileId,'connect_key':connect_key});
  224. for(let m of mixList){
  225. if(glj.createType == 'replace'&& glj.mIndexObj){//如果是替换过的工料机,要造一条加的数据去补回下面的减数据
  226. //与下面的减相对应,如果有没被引用子组成物工料机,会少一条加的数据,这样,那条没被引用的消耗量会被减为0
  227. addToMixMap(m,mixRatioMap,assCoeQuantity,0); //addToMixMap(m,mixRatioMap,glj.rationItemQuantity,0); -- 2019-04-15 和下面的减相对做修改
  228. }
  229. if(!noCustomQuantiyt(glj)) {//有自定义消耗量才做正常的计算处理
  230. addToMixMap(m,mixRatioMap,glj.customQuantity,assCoeQuantity);
  231. }
  232. }
  233. if(glj.createType == 'replace' && glj.mIndexObj){//如果这条是替换过的混凝土,原来的组成物的消耗量还要减去替换前的混凝土得到的消耗量
  234. let t_con_key = gljUtil.getIndex(glj.mIndexObj);
  235. let tmixList = await mixRatioModel.find({"unit_price_file_id":unitPriceFileId,'connect_key':t_con_key});
  236. for(let tm of tmixList ){
  237. addToMixMap(tm,mixRatioMap,0,assCoeQuantity); //addToMixMap(tm,mixRatioMap,0,glj.rationItemQuantity);
  238. // -- 2019-04-15 修改bugs 这里把glj.rationItemQuantity 改成assCoeQuantity。 定额下组成物的消耗量要减去父工料机经过辅助定额或者子目换算后的对应的增加量
  239. }
  240. }
  241. function addToMixMap(m,map,cust,ass,isReplace = false) {
  242. let mkey = gljUtil.getIndex(m);
  243. let pObj = {customQuantity:cust,assCoeQuantity:ass,consumption:m.consumption,isReplace:isReplace};
  244. if(map[mkey]){
  245. map[mkey].push(pObj);
  246. }else {
  247. map[mkey] = [pObj];
  248. }
  249. }
  250. }
  251. function noCustomQuantiyt(glj) {//是否有自定义消耗量
  252. return !glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null||glj.customQuantity==""
  253. }
  254. async function calculateAss(quantity,assList,glj) {
  255. for(let i=0;i<assList.length;i++){
  256. if(assList[i].assRation){
  257. let assglj = null;
  258. for(let aglj of assList[i].assRation.rationGljList){
  259. if(glj.createType == 'replace'){//如果工料机是替换过的,要用原始的编码来匹配
  260. let std_glj = await std_glj_lib_gljList_model.findOne({'ID':aglj.gljId});
  261. if(glj.rcode == std_glj.code){
  262. assglj = aglj;
  263. break;
  264. }
  265. }else if(aglj.gljId == glj.GLJID){
  266. assglj = aglj;
  267. break;
  268. }
  269. }
  270. if(assglj){
  271. let calQuantity = assglj.consumeAmt*assList[i].times;
  272. quantity += calQuantity
  273. }
  274. }
  275. }
  276. return scMathUtil.roundTo(quantity,-6);
  277. }
  278. function generateAdjustState(glj,coeList,adjustState,gljList,quantity) {
  279. //替换工料机 and 添加工料机
  280. if(glj._doc.createType=='replace'&&glj.rcode!=glj.code){
  281. adjustState.push({index:stateSeq.replace,content:glj.rcode+'换'+glj.code});
  282. }else if(glj._doc.createType=='add'){
  283. let displayQuantity = quantity;
  284. if(glj._doc.hasOwnProperty('customQuantity')&&(glj.customQuantity != null||glj.customQuantity != '')){
  285. displayQuantity = glj.customQuantity;
  286. }
  287. displayQuantity = displayQuantity&&displayQuantity!=""?parseFloat(displayQuantity):0;
  288. adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+ displayQuantity,type:"添"+glj.code});
  289. }
  290. // to do
  291. //标准附注条件调整 + 自定义乘系数
  292. if(_.last(gljList).ID == glj.ID){//最后一个工料机的时候才生成,生成一次就可以了
  293. for(let i=0;i<coeList.length;i++){
  294. if(coeList[i].isAdjust==1){
  295. if(i==coeList.length-1){
  296. adjustState.push({index:stateSeq.cusCoe,content:getContent(coeList[i].coes)});//自定义乘系数要去掉倍数为1的
  297. }else {
  298. if(coeList[i].select_code && coeList[i].select_code!=""){
  299. _.remove(adjustState,{'content':coeList[i].original_code+'换'+coeList[i].select_code});//去掉替换工料机自动生成的调整状态
  300. adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].original_code+'换'+coeList[i].select_code});
  301. }
  302. for(let c of coeList[i].coes){
  303. if(c.coeType=='单个工料机') _.remove(adjustState,{'type':"添"+c.gljCode});//如果是单个工料机子目换算类型自动添加的,去掉前面手动生成的调整状态
  304. if(c.coeType=='替换人材机') _.remove(adjustState,{'content':c.gljCode+'换'+c.replaceCode});//如果是替换人材机子目换算类型自动添加的,去掉前面手动生成的调整状态
  305. }
  306. if(coeList[i].content) adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});//coeList[i].content
  307. }
  308. }
  309. }
  310. }
  311. //自定义消耗量
  312. if(glj._doc.createType!='add'&&glj._doc.hasOwnProperty('customQuantity')){
  313. if(glj.customQuantity!==null&&glj.customQuantity!=""){
  314. adjustState.push({index:stateSeq.cusQuantity,content:glj.code+'量'+parseFloat(glj.customQuantity)});
  315. }
  316. }
  317. //市场单价调整
  318. if(glj._doc.hasOwnProperty('marketPriceAdjust')&&glj.marketPriceAdjust&&glj.marketPriceAdjust!=0){
  319. //0101005价66.00
  320. adjustState.push({index:stateSeq.adjMak,content:glj.code+'价'+glj.marketPriceAdjust});
  321. }
  322. return adjustState;
  323. }
  324. function getContent(coes) {
  325. let stringList=[];
  326. let temAmount = null;
  327. let theSame = true;
  328. for(let t of coes){
  329. if(temAmount == null){
  330. temAmount = t.amount;
  331. }else if(temAmount != t.amount){
  332. theSame = false;
  333. break;
  334. }
  335. }
  336. for(let c of coes){
  337. if( c.amount&&c.amount!=1){
  338. let operator = c.operator;
  339. if(c.operator =="*"){
  340. operator = "X";
  341. }
  342. if(theSame == true && c.coeType == "定额"){
  343. stringList.push(c.coeType+operator+c.amount);
  344. break;
  345. }else
  346. if(theSame == false && c.coeType != "定额"){
  347. stringList.push(c.coeType+operator+c.amount);
  348. }
  349. }
  350. }
  351. return stringList.join(",");
  352. }
  353. function prepareAss(assList) {//处理辅助定额,支持多个辅助定额的情况
  354. for(let a of assList){
  355. if(a.groupList && a.groupList.length > 1){//组里有多个定额的情况
  356. let newList = _.sortByAll(a.groupList,['param']);//先按参数排序
  357. for(let n of newList){
  358. if(a.actualValue > n.stdValue && a.actualValue <= parseFloat(n.param)){//落在中间,则用组里的这条定额
  359. a._doc.param = n.param;
  360. a._doc.paramName = n.paramName;
  361. a._doc.assistCode = n.assistCode;
  362. break;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. function calculateTimes(ass){
  369. if(ass.isAdjust == 0) return 0;//打勾辅助定额才计算
  370. let times =(ass.actualValue-ass.stdValue)/ass.stepValue;
  371. let r = false;
  372. if(times<0){
  373. r=true;
  374. times=times*-1;
  375. }
  376. if(ass.carryBit=='四舍五入'){
  377. times = _.round(times,ass.decimal);
  378. }else if (ass.carryBit=='进一'){
  379. times =_.ceil(times,ass.decimal);
  380. }else if(ass.carryBit == '舍一'){
  381. times = _.floor(times,ass.decimal);
  382. }
  383. if(r){
  384. times=times*-1;
  385. }
  386. return scMathUtil.roundTo(times,-6);
  387. }
  388. function calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal){
  389. let coeQuantity = quantity;
  390. if(coeList.length>1){
  391. for(let i=0;i<coeList.length-1;i++){
  392. coeQuantity = everyCoe(coeQuantity,coeList[i],glj,gljList,decimal);
  393. }
  394. }
  395. return scMathUtil.roundTo(coeQuantity,-6);
  396. }
  397. function everyCoe(quantity,coe,glj,gljList,decimal) {
  398. let coeQuantity = quantity;
  399. if(coe.isAdjust==1){
  400. for(let i=0;i<coe.coes.length;i++){
  401. if(coe.coes[i].coeType=='单个工料机' &&coe.coes[i].gljCode==glj.code){//if(coe.coes[i].coeType=='单个工料机'&&coe.coes[i].gljCode==glj.code)
  402. coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
  403. }else if(coe.coes[i].coeType== "替换人材机" && glj.rcode == coe.coes[i].gljCode && glj.code == coe.coes[i].replaceCode){
  404. coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
  405. }else if(coe.coes[i].coeType== "所选人材机" && glj.rcode == coe.original_code && glj.code == coe.select_code ){
  406. coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
  407. } else if(coe.coes[i].coeType=='定额'){
  408. coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
  409. }else if(coeTypeMap[coe.coes[i].coeType]==getRootGLJType(glj.type).ID){
  410. coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
  411. }
  412. }
  413. }
  414. return scMathUtil.roundTo(coeQuantity,-6);
  415. }
  416. function calculateQuantityByCustomerCoes(quantify,coe,glj) {
  417. let rationAmount = coe.coes[0].amount;
  418. if(_.every(coe.coes,'amount',rationAmount)){
  419. return getCalculateResult(quantify, coe.coes[0])
  420. }else {
  421. for(let i=1;i<coe.coes.length;i++){
  422. if(coeTypeMap[coe.coes[i].coeType]==getRootGLJType(glj.type).ID){
  423. return getCalculateResult(quantify,coe.coes[i])
  424. }
  425. }
  426. }
  427. return quantify
  428. }
  429. function getCoeSelectedGLJ(gljList,rcode,code) {
  430. if(gljList&& code && code !=""){
  431. let o_glj = _.find(gljList,{'rcode':rcode,'code':code});
  432. return o_glj;
  433. }
  434. return null;
  435. }
  436. function getCalculateResult(quantify,c,coe,gljList,decimal) {
  437. let q = quantify;
  438. let o_glj = null;
  439. switch (c.operator){
  440. case '+' :
  441. q = q + c.amount;
  442. break;
  443. case '-' :
  444. q = q - c.amount;
  445. break;
  446. case '*' :
  447. q = q * c.amount;
  448. break;
  449. case '/' :
  450. q = q / c.amount;
  451. break;
  452. case '+*' :
  453. o_glj = getCoeSelectedGLJ(gljList,coe.original_code,coe.select_code);
  454. if(o_glj){
  455. q = q + c.amount * scMathUtil.roundForObj(o_glj.rationItemQuantity,decimal);
  456. }
  457. break;
  458. case '-*' :
  459. o_glj = getCoeSelectedGLJ(gljList,coe.original_code,coe.select_code);
  460. if(o_glj){
  461. q = q - c.amount * scMathUtil.roundForObj(o_glj.rationItemQuantity,decimal);
  462. }
  463. break;
  464. case '=' :
  465. q = c.amount;
  466. break;
  467. }
  468. return q;
  469. }
  470. function getRootGLJType(id){
  471. let glj_type_object = glj_type_util.getStdGljTypeCacheObj();
  472. let topTypeId = glj_type_object.getTopParentIdByItemId(id);
  473. let type = glj_type_object.getItemById(topTypeId);
  474. return type;
  475. }
  476. function getGLJTypeByID(id) {
  477. let type = getRootGLJType(id);
  478. if(type!=undefined){
  479. return type.fullName;
  480. }else {
  481. return '';
  482. }
  483. }