rpt_yanghu_data_util.js 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994
  1. /**
  2. * Created by Tony on 2017/7/14.
  3. * 报表数据提取class,是协助报表模板里指标字段自主提取数据的工具类
  4. */
  5. let JV = require('../rpt_component/jpc_value_define');
  6. let $JE = require('../rpt_component/jpc_rte');
  7. let consts = require('../../../modules/main/models/project_consts');
  8. let fsUtil = require("../../../public/fsUtil");
  9. let stringUtil = require("../../../public/stringUtil");
  10. let scMathUtil = require("../../../public/scMathUtil");
  11. let _ = require("lodash");
  12. let treeUtil = require('../../../public/treeUtil');
  13. let projectConst = consts.projectConst;
  14. let projectConstList = consts.projectConstList;
  15. const gljUtil = require('../../../public/gljUtil');
  16. const gljType = require('../../common/const/glj_type_const');
  17. // const pm_facade = require('../../pm/facade/pm_facade');
  18. const GLJID_PRE = `gljId_`, COMPONENT_GLJID_PRE = `componetGljId_`;
  19. const GLJ_TYPE = {
  20. Labour: 1,
  21. Material: 2,
  22. Machine: 3,
  23. Main_Material: 4,
  24. Equipment: 5,
  25. OTHER_MATERIAL: 207,
  26. MACHINE_LABOUR: 303,
  27. INSTRUMENT: 304,
  28. FUEL_POWER_FEE: 305
  29. };
  30. const oprMachines = [306, 307, 308, 309, 310, 311, 312];
  31. class Rpt_Common{
  32. initialize(rpt_tpl, currentDataObj) {
  33. this.template = rpt_tpl;
  34. this.currentDataObj = currentDataObj;
  35. };
  36. Multiply(val1, val2, fixFormat) {
  37. let rst = [], maxLen = val1.length, minLen = val2.length;
  38. if (minLen > maxLen) {
  39. maxLen = maxLen + minLen; minLen = maxLen - minLen; maxLen = maxLen - minLen;
  40. }
  41. for (let i = 0; i < maxLen; i++) {
  42. let value = ((i < val1.length)?val1[i]:val1[minLen - 1]) * ((i < val2.length)?val2[i]:val2[minLen - 1]);
  43. if (value === null || value === undefined) {
  44. value = '0';
  45. }
  46. if (fixFormat) value = value.toFixed(fixFormat);
  47. rst.push(value);
  48. }
  49. return rst;
  50. };
  51. Divide(val1, val2, fixFormat) {
  52. let rst = [], maxLen = val1.length, minLen = val2.length;
  53. if (minLen > maxLen) {
  54. maxLen = maxLen + minLen; minLen = maxLen - minLen; maxLen = maxLen - minLen;
  55. }
  56. for (let i = 0; i < maxLen; i++) {
  57. let value = ((i < val1.length)?val1[i]:val1[minLen - 1]) / ((i < val2.length)?val2[i]:val2[minLen - 1]);
  58. if (fixFormat) value = value.toFixed(fixFormat);
  59. rst.push(value);
  60. }
  61. return rst;
  62. };
  63. Plus(val1, val2, fixFormat) {
  64. let rst = [], maxLen = val1.length, minLen = val2.length;
  65. if (minLen > maxLen) {
  66. maxLen = maxLen + minLen; minLen = maxLen - minLen; maxLen = maxLen - minLen;
  67. }
  68. for (let i = 0; i < maxLen; i++) {
  69. let value = ((i < val1.length)?val1[i]:val1[minLen - 1]) + ((i < val2.length)?val2[i]:val2[minLen - 1]);
  70. if (fixFormat) value = value.toFixed(fixFormat);
  71. rst.push(value);
  72. }
  73. return rst;
  74. };
  75. MultiPlus(arrVal, fixFormat) {
  76. let rst = [];
  77. for (let i = 0; i < arrVal.length; i++) {
  78. let valItem = arrVal[i];
  79. if (i === 0) {
  80. for (let dtl of valItem) {
  81. let value = parseFloat(dtl);
  82. if (fixFormat) value = value.toFixed(fixFormat);
  83. rst.push(value);
  84. }
  85. } else {
  86. for (let j = 0; j < valItem.length; j++) {
  87. if (j < rst.length) {
  88. let value = rst[j] + valItem[j];
  89. if (fixFormat) value = value.toFixed(fixFormat);
  90. rst[j] = value;
  91. } else {
  92. let value = parseFloat(valItem[j]);
  93. if (fixFormat) value = value.toFixed(fixFormat);
  94. rst.push(value);
  95. }
  96. }
  97. }
  98. }
  99. return rst;
  100. };
  101. Minus(val1, val2, fixFormat) {
  102. let rst = [], maxLen = val1.length, minLen = val2.length;
  103. if (minLen > maxLen) {
  104. maxLen = maxLen + minLen; minLen = maxLen - minLen; maxLen = maxLen - minLen;
  105. }
  106. for (let i = 0; i < maxLen; i++) {
  107. let value = ((i < val1.length)?val1[i]:val1[minLen - 1]) - ((i < val2.length)?val2[i]:val2[minLen - 1]);
  108. if (fixFormat) value = value.toFixed(fixFormat);
  109. rst.push(value);
  110. }
  111. return rst;
  112. };
  113. FormatString(arrVal, formatStr){
  114. let rst = [];
  115. for (let val of arrVal) {
  116. rst.push(stringUtil.replaceAll(formatStr, '%S', val));
  117. }
  118. return rst;
  119. };
  120. }
  121. class Rpt_Data_Extractor {
  122. constructor () {
  123. this.COMMON = new Rpt_Common();
  124. };
  125. initialize(tpl) {
  126. this.rptTpl = tpl;
  127. };
  128. //-- 根据报表模板映射指标(非离散指标)的定义,罗列出所有需要用到的data对象key,作为数据请求的过滤依据
  129. getDataRequestFilter(summaryRst) {
  130. let rst = [];
  131. let tpl = this.rptTpl;
  132. let pri_func_chk_filter = function (field) {
  133. for (let key of projectConstList) {
  134. if (rst.indexOf(key) < 0) {
  135. if (field[JV.PROP_FIELD_EXP_MAP]) {
  136. if (field[JV.PROP_FIELD_EXP_MAP].indexOf('.' + key + '.') >= 0) {
  137. rst.push(key);
  138. if (key === projectConst.RATION_GLJ && (rst.indexOf(projectConst.PROJECTGLJ) < 0)) {
  139. rst.push(projectConst.PROJECTGLJ);
  140. if (rst.indexOf(projectConst.LABOUR_COE < 0)) rst.push(projectConst.LABOUR_COE);
  141. }
  142. if (key === projectConst.PROJECTGLJ) {
  143. if (rst.indexOf(projectConst.LABOUR_COE < 0)) rst.push(projectConst.LABOUR_COE);
  144. if (rst.indexOf(projectConst.RATION_GLJ) < 0) rst.push(projectConst.RATION_GLJ);
  145. if (field[JV.PROP_FIELD_EXP_MAP].indexOf("'quantity'") > 0 ||
  146. field[JV.PROP_FIELD_EXP_MAP].indexOf("'subdivisionQuantity'") > 0 ||
  147. field[JV.PROP_FIELD_EXP_MAP].indexOf("'techQuantity'") > 0 ) {
  148. if (rst.indexOf(projectConst.RATION) < 0) rst.push(projectConst.RATION);
  149. if (rst.indexOf(projectConst.BILLS) < 0) rst.push(projectConst.BILLS);
  150. //备注:项目工料机的数量是需要根据定额清单来计算的!这里的逻辑是对的
  151. }
  152. }
  153. }
  154. }
  155. } else if (key === projectConst.PROJECTGLJ) {
  156. if (rst.indexOf(projectConst.RATION_GLJ) < 0) rst.push(projectConst.RATION_GLJ);
  157. if (field[JV.PROP_FIELD_EXP_MAP].indexOf("'quantity'") > 0 ||
  158. field[JV.PROP_FIELD_EXP_MAP].indexOf("'subdivisionQuantity'") > 0 ||
  159. field[JV.PROP_FIELD_EXP_MAP].indexOf("'techQuantity'") > 0 ) {
  160. if (rst.indexOf(projectConst.RATION) < 0) rst.push(projectConst.RATION);
  161. if (rst.indexOf(projectConst.BILLS) < 0) rst.push(projectConst.BILLS);
  162. //备注:项目工料机的数量是需要根据定额清单来计算的!这里的逻辑是对的
  163. }
  164. }
  165. }
  166. if (summaryRst instanceof Array) {
  167. for (let key of consts.summaryConstList) {
  168. if (summaryRst.indexOf(key) < 0) {
  169. if (field[JV.PROP_FIELD_EXP_MAP]) {
  170. if (field[JV.PROP_FIELD_EXP_MAP].indexOf('.' + key + '.') >= 0) {
  171. summaryRst.push(key);
  172. }
  173. }
  174. }
  175. }
  176. }
  177. };
  178. let pri_setup_filter = function (FIELD_LIST_KEY) {
  179. if (tpl[JV.NODE_FIELD_MAP][FIELD_LIST_KEY]) {
  180. for (let field of tpl[JV.NODE_FIELD_MAP][FIELD_LIST_KEY]) {
  181. pri_func_chk_filter(field);
  182. }
  183. }
  184. };
  185. pri_setup_filter(JV.NODE_DISCRETE_FIELDS);
  186. pri_setup_filter(JV.NODE_MASTER_FIELDS);
  187. pri_setup_filter(JV.NODE_DETAIL_FIELDS);
  188. pri_setup_filter(JV.NODE_MASTER_FIELDS_EX);
  189. pri_setup_filter(JV.NODE_DETAIL_FIELDS_EX);
  190. if (tpl[JV.NODE_MAP_DATA_HANDLE_INFO] && tpl[JV.NODE_MAP_DATA_HANDLE_INFO].length > 0) {
  191. for (let preHandle of tpl[JV.NODE_MAP_DATA_HANDLE_INFO]) {
  192. if (rst.indexOf(preHandle[JV.PROP_DATA_KEY]) < 0) {
  193. rst.push(preHandle[JV.PROP_DATA_KEY]);
  194. }
  195. if (preHandle[JV.PROP_HANDLE_TYPE] === JV.PROP_HANDLE_TYPE_FILTER) {
  196. if (preHandle[JV.PROP_FILTER_KEYS]) {
  197. for (let filter of preHandle[JV.PROP_FILTER_KEYS]) {
  198. if (filter[JV.PROP_FILTER_COMPARE_OBJ] && rst.indexOf(filter[JV.PROP_FILTER_COMPARE_OBJ]) < 0) {
  199. rst.push(filter[JV.PROP_FILTER_COMPARE_OBJ]);
  200. }
  201. }
  202. }
  203. } else if (preHandle[JV.PROP_HANDLE_TYPE] === JV.PROP_HANDLE_TYPE_SUM) {
  204. if (preHandle[JV.PROP_SUM_GROUP_KEYS]) {
  205. for (let grpKey of preHandle[JV.PROP_SUM_GROUP_KEYS]) {
  206. if (grpKey.seeking_parent && rst.indexOf(grpKey.seeking_parent) < 0) {
  207. rst.push(grpKey.seeking_parent);
  208. }
  209. }
  210. }
  211. } else if (preHandle[JV.PROP_PARENT_CHILD_SORT_KEY] && preHandle[JV.PROP_PARENT_CHILD_SORT_KEY].length > 0) {
  212. for (let item of preHandle[JV.PROP_PARENT_CHILD_SORT_KEY]) {
  213. if (rst.indexOf(item[JV.PROP_PARENT_DATA_KEY]) < 0) {
  214. rst.push(item[JV.PROP_PARENT_DATA_KEY]);
  215. }
  216. }
  217. }
  218. }
  219. }
  220. if (rst.indexOf(projectConst.RATION) >= 0 &&
  221. rst.indexOf(projectConst.RATION_GLJ) >= 0 && rst.indexOf(projectConst.RATION_COE) < 0) {
  222. rst.push(projectConst.RATION_COE);
  223. //备注:在此情况下,根据业务特点,有可能需要额外计算project工料机的基价单价及市场单价,需要用到一些额外信息处理。
  224. // 这里也不精细控制,直接多加一个请求类型。以后说不定还有其他类型的请求,到时候再加。
  225. }
  226. if (rst.length === 0) {
  227. rst.push(projectConst.RATION_ASS);
  228. }
  229. return rst;
  230. };
  231. //--- 装配数据(把收集到的数据,依据报表模板的指示,预处理(如:排序、过滤、合计)及装配到相关指标) ---//
  232. assembleData(rawDataObj) {
  233. let $PROJECT = {"COMMON": null, "MAIN": {}, "DETAIL": {}};
  234. let tpl = this.rptTpl;
  235. this.COMMON.initialize(tpl, rawDataObj);
  236. $PROJECT.COMMON = this.COMMON;
  237. if (rawDataObj.hasOwnProperty(`prj`) && rawDataObj.hasOwnProperty(`prjData`)) {
  238. setupMainFunc($PROJECT, `MAIN`, rawDataObj.prj._doc);
  239. // $PROJECT.MAIN["myOwnRawDataObj"] = rawDataObj.prj._doc;
  240. // $PROJECT.MAIN.getProperty = ext_mainGetPropety;
  241. // $PROJECT.MAIN.getFee = ext_mainGetFee;
  242. for (let item of rawDataObj.prjData) {
  243. setupFunc($PROJECT.DETAIL, item.moduleName, item);
  244. }
  245. let projectGLJDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.PROJECTGLJ);
  246. if (projectGLJDatas) {
  247. //增加一个辅助对象,方便通过gljid key直接获取数据,省去循环时间
  248. let gljAssitantObj = {"gljIds": {}, "componentGljIds": {}};
  249. projectGLJDatas.data.gljAssistant = gljAssitantObj;
  250. for (let gljItem of projectGLJDatas.data.gljList) {
  251. gljAssitantObj.gljIds[GLJID_PRE + gljItem.id] = gljItem;
  252. if (!(gljItem.ratio_data) || gljItem.ratio_data.length === 0) {
  253. gljAssitantObj.componentGljIds[COMPONENT_GLJID_PRE + gljItem.glj_id] = gljItem;
  254. }
  255. }
  256. //顺便做个排序(跟UI一致的排序)
  257. }
  258. let labourCoeDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.LABOUR_COE);
  259. let rationGLJDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION_GLJ);
  260. let rationDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION);
  261. let billsDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.BILLS);
  262. let decimal = rawDataObj.prj.property.decimal.glj.quantity;
  263. // let labourCoeDatas = getModuleDataByKey(rawDataObj.prjData, "labour_coe");
  264. let calcOptions = rawDataObj.prj.property.calcOptions;
  265. if (projectGLJDatas && rationGLJDatas && rationDatas && billsDatas) {
  266. gljUtil.calcProjectGLJQuantity(projectGLJDatas.data, rationGLJDatas.data, rationDatas.data, billsDatas.data, decimal);
  267. }
  268. if (projectGLJDatas && rationGLJDatas && labourCoeDatas) {
  269. //考虑调价情况
  270. const newAdjPriceArr = [];
  271. for (const glj of projectGLJDatas.data.gljList) {
  272. newAdjPriceArr.push(gljUtil.getGLJPrice(glj, projectGLJDatas.data, calcOptions, labourCoeDatas, rawDataObj.prj.property.decimal, false, gljUtil.getTenderPriceCoe(glj, rawDataObj.prj.property), true));
  273. // glj.unit_price.market_price = gljUtil.getMarketPrice(glj, projectGLJDatas.data, calcOptions, [], rawDataObj.prj.property.decimal, false);
  274. }
  275. for (let gljIdx = 0; gljIdx < newAdjPriceArr.length; gljIdx++) {
  276. let newGlj = newAdjPriceArr[gljIdx];
  277. let gljItem = projectGLJDatas.data.gljList[gljIdx];
  278. let unit_price = gljItem.unit_price._doc ? gljItem.unit_price._doc : gljItem.unit_price;
  279. unit_price.org_market_price = gljItem.unit_price.marketPrice;
  280. unit_price.market_price = newGlj.marketPrice;
  281. unit_price.org_basePrice = gljItem.unit_price.base_price;
  282. unit_price.base_price = newGlj.basePrice;
  283. }
  284. // 备注:养护新增调价,处理上与建筑同步
  285. }
  286. }
  287. //还有汇总的...
  288. if (rawDataObj.hasOwnProperty(`Construct`) || rawDataObj.hasOwnProperty(`ConstructDetail`) || rawDataObj.hasOwnProperty(`Segment`) || rawDataObj.hasOwnProperty(`SegmentDetail`)
  289. || rawDataObj.hasOwnProperty(`SummaryAudit`) || rawDataObj.hasOwnProperty(`SummaryAuditDetail`)
  290. || rawDataObj.hasOwnProperty(`SummaryGljAudit`) || rawDataObj.hasOwnProperty(`SummaryGljAuditDetail`)) {
  291. $PROJECT.SUMMARY = {};
  292. if (rawDataObj.Construct) {
  293. setupMainFunc($PROJECT.SUMMARY, `Construct`, rawDataObj.Construct);
  294. }
  295. if (rawDataObj.ConstructDetail) {
  296. setupFunc($PROJECT.SUMMARY, `ConstructDetail`, {"data": rawDataObj.ConstructDetail});
  297. }
  298. if (rawDataObj.Segment) {
  299. setupMainFunc($PROJECT.SUMMARY, `Segment`, rawDataObj.Segment);
  300. }
  301. if (rawDataObj.SegmentDetail) {
  302. setupFunc($PROJECT.SUMMARY, `SegmentDetail`, {"data": rawDataObj.SegmentDetail});
  303. }
  304. if (rawDataObj.SummaryAudit) {
  305. setupMainFunc($PROJECT.SUMMARY, `SummaryAudit`, rawDataObj.SummaryAudit);
  306. }
  307. if (rawDataObj.SummaryAuditDetail) {
  308. setupFunc($PROJECT.SUMMARY, `SummaryAuditDetail`, {"data": rawDataObj.SummaryAuditDetail});
  309. }
  310. if (rawDataObj.SummaryGljAudit) {
  311. setupMainFunc($PROJECT.SUMMARY, `SummaryGljAudit`, rawDataObj.SummaryGljAudit);
  312. }
  313. if (rawDataObj.SummaryGljAuditDetail) {
  314. setupFunc($PROJECT.SUMMARY, `SummaryGljAuditDetail`, {"data": rawDataObj.SummaryGljAuditDetail});
  315. }
  316. }
  317. //综合费率
  318. let feeRate = getModuleDataByKey(rawDataObj.prjData, "feeRate");
  319. if (feeRate) {
  320. //把综合费率树结构数据拉扁
  321. // fsUtil.writeObjToFile(feeRate, "D:/GitHome/temp/feeRateObj.jsp");
  322. // console.log(feeRate);
  323. let newFeeRates = setupFeeRate(feeRate.data._doc);
  324. // console.log(newFeeRates);
  325. // fsUtil.writeObjToFile(newFeeRates, "D:/GitHome/temp/newFeeRateObj.js");
  326. feeRate.data._doc.rates = newFeeRates;
  327. }
  328. if (tpl[JV.NODE_MAP_DATA_HANDLE_INFO]) {
  329. for (let preHandle of tpl[JV.NODE_MAP_DATA_HANDLE_INFO]) {
  330. let srcData = getModuleDataByKey(rawDataObj.prjData, preHandle[JV.PROP_DATA_KEY]);
  331. switch(preHandle[JV.PROP_HANDLE_TYPE]) {
  332. case JV.PROP_HANDLE_TYPE_SORT:
  333. sortData(srcData, preHandle, rawDataObj.prjData);
  334. break;
  335. case JV.PROP_HANDLE_TYPE_FILTER:
  336. filterData(srcData, preHandle, rawDataObj.prjData);
  337. break;
  338. case JV.PROP_HANDLE_TYPE_SUM:
  339. // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/temp/insertedRawDataData10.jsp");
  340. summaryData(srcData, preHandle, rawDataObj.prjData, rawDataObj.prj);
  341. // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/temp/insertedRawDataData11.jsp");
  342. break;
  343. case JV.PROP_HANDLE_TYPE_ADD_DUMMY:
  344. addDummyData(srcData, preHandle);
  345. break;
  346. case JV.PROP_HANDLE_TYPE_ADJUST:
  347. adjustData(srcData, preHandle);
  348. break;
  349. case JV.PROP_HANDLE_TYPE_BILLS_DATA_MOVE:
  350. //把显示在清单中的量材转移到工料机去, 顺带把项目工料机的组成物工料机分解出来,分解的工料机作为定额工料机保存(02表用)
  351. moveRationData(srcData, rawDataObj);
  352. break;
  353. case JV.PROP_HANDLE_TYPE_COMPONENT_MOVE:
  354. //把定额下的组成物的工料机分解出来,分解的工料机作为定额工料机保存(02表用)
  355. moveRationComponentData(srcData, rawDataObj);
  356. break;
  357. case JV.PROP_HANDLE_TYPE_COMPONENT_REPLACEMENT:
  358. //重庆2018 09-x表专用,机械数据用 组成物替换掉 ^_^!
  359. componentReplacement(rawDataObj);
  360. break;
  361. default:
  362. break;
  363. }
  364. }
  365. }
  366. //一些计算(不保存数据,需要动态计算的)
  367. if (rawDataObj.hasOwnProperty(`prj`) && rawDataObj.hasOwnProperty(`prjData`)) {
  368. let calcOptions = rawDataObj.prj._doc.property.calcOptions;
  369. let decimalObj = rawDataObj.prj._doc.property.decimal;
  370. let labourCoeDatas = getModuleDataByKey(rawDataObj.prjData, "labour_coe");
  371. let prjGLJDatas = getModuleDataByKey(rawDataObj.prjData, "projectGLJ");
  372. let rationDatas = getModuleDataByKey(rawDataObj.prjData, "ration");
  373. if (calcOptions && decimalObj && labourCoeDatas && labourCoeDatas && prjGLJDatas && rationDatas) {
  374. for (let rationItem of rationDatas.data) {
  375. let glj = _.find(prjGLJDatas.data.gljList, {'id': rationItem.projectGLJID});
  376. if (glj) {
  377. let newGlj = gljUtil.getGLJPrice(glj, prjGLJDatas.data, calcOptions, labourCoeDatas, decimalObj, false, _, scMathUtil);
  378. rationItem.marketPrice = newGlj.marketPrice;
  379. rationItem.basePrice = newGlj.basePrice;
  380. rationItem.adjustPrice = newGlj.adjustPrice;
  381. rationItem.marketUnitFee = newGlj.marketPrice;//更新树节点市场单价列的值
  382. }
  383. }
  384. }
  385. // console.log("重新计算!");
  386. }
  387. //
  388. let rptDataObj = {};
  389. rptDataObj[JV.DATA_DISCRETE_DATA] = [];
  390. rptDataObj[JV.DATA_MASTER_DATA] = [];
  391. rptDataObj[JV.DATA_DETAIL_DATA] = [];
  392. rptDataObj[JV.DATA_MASTER_DATA_EX] = [];
  393. rptDataObj[JV.DATA_DETAIL_DATA_EX] = [];
  394. if (rawDataObj.hasOwnProperty(`prj`) && rawDataObj.hasOwnProperty(`prjData`)) {
  395. rptDataObj.DecimalObj = {};
  396. rptDataObj.DecimalObj.prjDecimal = $PROJECT.MAIN["myOwnRawDataObj"].decimal; //为函数 P_REF() 准备数据
  397. rptDataObj.DecimalObj.unitDecimal = getUnitDecimal($PROJECT.MAIN["myOwnRawDataObj"].billsQuantityDecimal); //为函数 U_REF() 准备数据
  398. }
  399. assembleFields(tpl[JV.NODE_FIELD_MAP][JV.NODE_DISCRETE_FIELDS], rptDataObj[JV.DATA_DISCRETE_DATA], $PROJECT);
  400. // console.log(JV.DATA_DISCRETE_DATA);
  401. // console.log(rptDataObj[JV.DATA_DISCRETE_DATA]);
  402. assembleFields(tpl[JV.NODE_FIELD_MAP][JV.NODE_MASTER_FIELDS], rptDataObj[JV.DATA_MASTER_DATA], $PROJECT);
  403. // console.log(JV.DATA_MASTER_DATA);
  404. // console.log(rptDataObj[JV.DATA_MASTER_DATA]);
  405. assembleFields(tpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS], rptDataObj[JV.DATA_DETAIL_DATA], $PROJECT);
  406. // console.log(JV.DATA_DETAIL_DATA);
  407. // console.log(rptDataObj[JV.DATA_DETAIL_DATA]);
  408. assembleFields(tpl[JV.NODE_FIELD_MAP][JV.NODE_MASTER_FIELDS_EX], rptDataObj[JV.DATA_MASTER_DATA_EX], $PROJECT);
  409. // console.log(JV.DATA_MASTER_DATA_EX);
  410. // console.log(rptDataObj[JV.DATA_MASTER_DATA_EX]);
  411. assembleFields(tpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS_EX], rptDataObj[JV.DATA_DETAIL_DATA_EX], $PROJECT);
  412. // console.log(JV.DATA_DETAIL_DATA_EX);
  413. // console.log(rptDataObj[JV.DATA_DETAIL_DATA_EX]);
  414. // fsUtil.writeObjToFile(rptDataObj, "D:/GitHome/temp/insertedOriginalData.jsp");
  415. // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/temp/insertedRawDataData.jsp");
  416. // fsUtil.writeObjToFile($PROJECT, "D:/GitHome/temp/$PROJECTData.jsp");
  417. // fsUtil.writeObjToFile(tpl[JV.NODE_FIELD_MAP][JV.NODE_MASTER_FIELDS], "D:/GitHome/temp/masterFieldsAfterAssemble.jsp");
  418. // fsUtil.writeObjToFile(tpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS], "D:/GitHome/temp/detailFieldsAfterAssemble.jsp");
  419. return rptDataObj;
  420. };
  421. }
  422. //小数位数依据单位来调整(如吨、公斤的精度要求就不同)
  423. function getUnitDecimal(unitDecimalArr) {
  424. let rst = {"default_decimal": 2};
  425. if (unitDecimalArr) {
  426. for (let item of unitDecimalArr) {
  427. if (item.unit === "其他未列单位") {
  428. rst["default_decimal"] = item.decimal;
  429. } else {
  430. rst['unit_decimal_' + item.unit] = item.decimal;
  431. }
  432. }
  433. }
  434. return rst;
  435. }
  436. function getModuleDataByKey(prjData, key) {
  437. let rst = null;
  438. if (prjData) {
  439. for (let item of prjData) {
  440. if (item.moduleName === key) {
  441. rst = item;
  442. break;
  443. }
  444. }
  445. }
  446. return rst;
  447. }
  448. function summaryData(sourceData, handleCfg, prjData, prjMain){
  449. let rstArr = [], tempRstArr = [];
  450. let curParentPrjData = {};
  451. let precision = 6;
  452. if (handleCfg[JV.PROP_HANDLE_TYPE_PRECISION]) {
  453. if (isNaN(parseInt(handleCfg[JV.PROP_HANDLE_TYPE_PRECISION]))) {
  454. let properties = handleCfg[JV.PROP_HANDLE_TYPE_PRECISION].split('.');
  455. let currentProperty = prjMain[properties[0]];
  456. for (let idx = 1; idx < properties.length; idx++) {
  457. currentProperty = currentProperty[properties[idx]];
  458. }
  459. if (!isNaN(parseInt(currentProperty))) {
  460. precision = parseInt(currentProperty);
  461. }
  462. } else {
  463. precision = parseInt(handleCfg[JV.PROP_HANDLE_TYPE_PRECISION]);
  464. }
  465. }
  466. for (let item of getActDataArr(sourceData)) {
  467. if (item._doc) {
  468. tempRstArr.push(item._doc);
  469. } else {
  470. tempRstArr.push(item);
  471. }
  472. }
  473. let private_cal_before_sum = function () {
  474. for (let calcAheadObj of handleCfg[JV.PROP_SUM_CALC_AHEAD]) {
  475. if (!curParentPrjData[calcAheadObj["seeking_parent"]]) curParentPrjData[calcAheadObj["seeking_parent"]] = getModuleDataByKey(prjData, calcAheadObj["seeking_parent"]);
  476. for (let idxP = 0; idxP < curParentPrjData[calcAheadObj["seeking_parent"]].data.length; idxP++) {
  477. let pDataItem = curParentPrjData[calcAheadObj["seeking_parent"]].data[idxP];
  478. let data = (pDataItem._doc)?pDataItem._doc:pDataItem;
  479. for (let idx = 0; idx < tempRstArr.length; idx++) {
  480. let dtlItem = tempRstArr[idx];
  481. if (dtlItem[calcAheadObj["seeking_key"]] === data[calcAheadObj["parent_key"]]) {
  482. for (let sumKey of handleCfg[JV.PROP_SUM_SUM_KEYS]) {
  483. switch (calcAheadObj[JV.PROP_SUM_CACL_TYPE]) {
  484. case "+":
  485. dtlItem[sumKey] = parseFloat(dtlItem[sumKey]) + parseFloat(data[calcAheadObj["calc_property"]]);
  486. break;
  487. case "-":
  488. dtlItem[sumKey] = parseFloat(dtlItem[sumKey]) - parseFloat(data[calcAheadObj["calc_property"]]);
  489. break;
  490. case "*":
  491. dtlItem[sumKey] = dtlItem[sumKey] * parseFloat(data[calcAheadObj["calc_property"]]);
  492. break;
  493. case "/":
  494. dtlItem[sumKey] = dtlItem[sumKey] / parseFloat(data[calcAheadObj["calc_property"]]);
  495. break;
  496. default:
  497. break;
  498. }
  499. }
  500. // break;
  501. }
  502. }
  503. }
  504. }
  505. };
  506. let private_get_grp_key = function (item) {
  507. let keys = [];
  508. for (let cfg of handleCfg[JV.PROP_SUM_GROUP_KEYS]) {
  509. if (typeof cfg === "string") {
  510. keys.push(item[cfg]);
  511. } else {
  512. if (!curParentPrjData[cfg["seeking_parent"]]) curParentPrjData[cfg["seeking_parent"]] = getModuleDataByKey(prjData, cfg["seeking_parent"]);
  513. for (let pDataItem of curParentPrjData[cfg["seeking_parent"]].data) {
  514. let data = (pDataItem._doc)?pDataItem._doc:pDataItem;
  515. if (item[cfg["seeking_key"]] === data[cfg["parent_key"]]) {
  516. keys.push(data[cfg["parent_grp_key"]]);
  517. break;
  518. }
  519. }
  520. }
  521. }
  522. return ( "grp_key_" + keys.join('_'));
  523. };
  524. let sumObj = {};
  525. if (handleCfg[JV.PROP_SUM_CALC_AHEAD] && handleCfg[JV.PROP_SUM_CALC_AHEAD].length > 0) {
  526. private_cal_before_sum();
  527. }
  528. for (let dtl of tempRstArr) {
  529. let grpKey = private_get_grp_key(dtl);
  530. if (sumObj[grpKey] === null || sumObj[grpKey] === undefined) {
  531. sumObj[grpKey] = dtl;
  532. rstArr.push(dtl);
  533. } else {
  534. for (let sumKey of handleCfg[JV.PROP_SUM_SUM_KEYS]) {
  535. if (dtl[sumKey]) {
  536. // sumObj[grpKey][sumKey] += dtl[sumKey];
  537. sumObj[grpKey][sumKey] = parseFloat(parseFloat(sumObj[grpKey][sumKey]).toFixed(precision)) + parseFloat(parseFloat(dtl[sumKey]).toFixed(precision));
  538. }
  539. }
  540. }
  541. }
  542. replaceActDataArr(sourceData, rstArr);
  543. // fsUtil.writeObjToFile(sourceData.data, "D:/GitHome/temp/sumRst.jsp");
  544. }
  545. function filterData(sourceData, handleCfg, prjData) {
  546. let rstArr = [], tempRstArr = [];
  547. for (let item of getActDataArr(sourceData)) {
  548. if (item._doc) {
  549. tempRstArr.push(item._doc);
  550. } else {
  551. tempRstArr.push(item);
  552. }
  553. }
  554. let private_chkVal = function (src, compVal, compStr) {
  555. let rst = true;
  556. switch (compStr) {
  557. case "==" :
  558. rst = (src == compVal);
  559. break;
  560. case "===" :
  561. rst = (src === compVal);
  562. break;
  563. case ">" :
  564. rst = (src > compVal);
  565. break;
  566. case ">=" :
  567. rst = (src >= compVal);
  568. break;
  569. case "<" :
  570. rst = (src < compVal);
  571. break;
  572. case "<=" :
  573. rst = (src <= compVal);
  574. break;
  575. case "!=" :
  576. rst = (src != compVal);
  577. break;
  578. case "!==" :
  579. rst = (src !== compVal);
  580. break;
  581. case "in" :
  582. if (compVal instanceof Array) {
  583. rst = compVal.indexOf(src) >= 0;
  584. } else {
  585. //string,需要转类型
  586. let newInCv = JSON.parse(compVal);
  587. if (newInCv instanceof Array) {
  588. rst = newInCv.indexOf(src) >= 0;
  589. } else {
  590. rst = false;
  591. }
  592. }
  593. break;
  594. case "not in":
  595. if (compVal instanceof Array) {
  596. rst = compVal.indexOf(src) < 0;
  597. } else {
  598. //string,需要转类型
  599. let newNotInCv = JSON.parse(compVal);
  600. if (newNotInCv instanceof Array) {
  601. rst = (newNotInCv.indexOf(src) < 0);
  602. } else {
  603. rst = true;
  604. }
  605. }
  606. break;
  607. default:
  608. rst = true;
  609. }
  610. return rst;
  611. };
  612. let private_chkArrVal = function(arr, key, compVal, compStr){
  613. let rst = false;
  614. if (arr.length > 0) {
  615. for (let arrItem of arr) {
  616. if (arrItem[key] !== undefined) {
  617. // 可以为null值去判断
  618. rst = private_chkVal(arrItem[key], compVal, compStr);
  619. }
  620. if (rst) {
  621. break;
  622. }
  623. }
  624. } else {
  625. //在某些判断条件下(含有'非'判断),如arr没有数组项,默认结果反而是true
  626. switch (compStr) {
  627. case "!=" :
  628. case "!==" :
  629. case "not in":
  630. rst = true;
  631. break;
  632. default:
  633. break;
  634. }
  635. }
  636. return rst;
  637. };
  638. let private_filter_compare = function (item, filterCfg) {
  639. let compareObj = {};
  640. let compRst = true;
  641. let curComparePrjData = null;
  642. let startIdx = 0;
  643. let private_ref_join = function(refKey, targetDataKey, targetPropertyKey) {
  644. let rst = null, objDataArr = null;
  645. curComparePrjData = getModuleDataByKey(prjData, targetDataKey);
  646. try {
  647. if (curComparePrjData !== null) {
  648. objDataArr = getActDataArr(curComparePrjData);
  649. for (let dtl of objDataArr) {
  650. if (item[refKey] === dtl[targetPropertyKey]) {
  651. rst = dtl;
  652. break;
  653. }
  654. }
  655. }
  656. } finally {
  657. curComparePrjData = null;
  658. }
  659. return rst;
  660. };
  661. for (let cfg of filterCfg[JV.PROP_FILTER_KEYS]) {
  662. if (cfg[JV.PROP_FILTER_COMPARE_VAL]) {
  663. //比较key值
  664. let keys = cfg.key.split(".");
  665. if (keys.length > 1) {
  666. let lastObj = item;
  667. for (let i = 0; i < keys.length - 1; i++) {
  668. if (keys[i].indexOf("ref_join(") === 0) {
  669. let params = keys[i].slice(9, keys[i].length - 1).split(",");
  670. if (params.length === 3) {
  671. lastObj = private_ref_join(params[0], params[1], params[2]);
  672. }
  673. if (!(lastObj)) {
  674. compRst = false;
  675. break;
  676. }
  677. } else {
  678. lastObj = item[keys[i]];
  679. if (!(lastObj)) {
  680. compRst = false;
  681. break;
  682. }
  683. }
  684. }
  685. if (lastObj) {
  686. if (lastObj instanceof Array) {
  687. compRst = private_chkArrVal(lastObj, keys[keys.length - 1], cfg[JV.PROP_FILTER_COMPARE_VAL], cfg[JV.PROP_FILTER_CONDITION]);
  688. } else {
  689. compRst = private_chkVal(lastObj[keys[keys.length - 1]], cfg[JV.PROP_FILTER_COMPARE_VAL], cfg[JV.PROP_FILTER_CONDITION]);
  690. }
  691. }
  692. } else {
  693. compRst = private_chkVal(item[cfg.key], cfg[JV.PROP_FILTER_COMPARE_VAL], cfg[JV.PROP_FILTER_CONDITION]);
  694. }
  695. } else if (cfg[JV.PROP_FILTER_COMPARE_OBJ] && cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY]){
  696. //通过其他对象来过滤
  697. if (!curComparePrjData) {
  698. curComparePrjData = getModuleDataByKey(prjData, cfg[JV.PROP_FILTER_COMPARE_OBJ]);
  699. }
  700. if (cfg[JV.PROP_FILTER_CONDITION] === "in" || cfg[JV.PROP_FILTER_CONDITION] === "not in") {
  701. let compareArr = null;
  702. if (!compareObj.hasOwnProperty(cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY] + startIdx.toString())) {
  703. compareObj[cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY] + startIdx.toString()] = [];
  704. compareArr = compareObj[cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY] + startIdx.toString()];
  705. for (let data of getActDataArr(curComparePrjData)) {
  706. if (compareArr.indexOf(data[cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY]]) < 0) {
  707. compareArr.push(data[cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY]]);
  708. }
  709. }
  710. } else {
  711. compareArr = compareObj[cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY] + startIdx.toString()];
  712. }
  713. compRst = private_chkVal(item[cfg.key], compareArr, cfg[JV.PROP_FILTER_CONDITION]);
  714. } else {
  715. for (let data of getActDataArr(curComparePrjData)) {
  716. compRst = private_chkVal(item[cfg.key], data[cfg[JV.PROP_FILTER_COMPARE_OBJ_KEY]], cfg[JV.PROP_FILTER_CONDITION]);
  717. if (compRst) break;
  718. }
  719. }
  720. }
  721. startIdx++;
  722. if (!compRst) {
  723. break; //有不符合条件的数据则退出(这里的判断条件是and关系)
  724. }
  725. }
  726. return compRst;
  727. };
  728. let private_sub_filter_compare = function (dtlItem, subFilters) {
  729. let cmpRst = false;
  730. for (let dtlCfg of subFilters) {
  731. cmpRst = private_filter_compare(dtlItem, dtlCfg);
  732. if (cmpRst) {
  733. if (dtlCfg[JV.PROP_OTHER_SUB_FILTER] && dtlCfg[JV.PROP_OTHER_SUB_FILTER].length > 0) {
  734. cmpRst = private_sub_filter_compare(dtlItem, dtlCfg[JV.PROP_OTHER_SUB_FILTER]);
  735. if (cmpRst) break;
  736. } else {
  737. break;
  738. }
  739. }
  740. }
  741. return cmpRst;
  742. };
  743. for (let item of tempRstArr) {
  744. if (private_filter_compare(item, handleCfg)) {
  745. rstArr.push(item);
  746. }
  747. }
  748. if (handleCfg[JV.PROP_OTHER_SUB_FILTER] && handleCfg[JV.PROP_OTHER_SUB_FILTER].length > 0) {
  749. let newRstArr = [];
  750. for (let dtlItem of rstArr) {
  751. let cmpRst = private_sub_filter_compare(dtlItem, handleCfg[JV.PROP_OTHER_SUB_FILTER]);
  752. if (cmpRst) {
  753. newRstArr.push(dtlItem);
  754. }
  755. }
  756. rstArr = newRstArr;
  757. }
  758. replaceActDataArr(sourceData, rstArr);
  759. // fsUtil.writeObjToFile(sourceData.data, "D:/GitHome/temp/filteredRst.jsp");
  760. }
  761. function adjustData(sourceData, adjustCfg) {
  762. let rstArr = [];
  763. for (let item of getActDataArr(sourceData)) {
  764. if (item._doc) {
  765. rstArr.push(item._doc);
  766. } else {
  767. rstArr.push(item);
  768. }
  769. }
  770. for (let item of adjustCfg[JV.PROP_ADJUST_COLLECTION]) {
  771. for (let rec of rstArr) {
  772. if (item[JV.PROP_ADJUST_ACTION] === "prefix") {
  773. rec[item.key] = item[JV.PROP_ADJUST_ACTION_VAL] + rec[item.key];
  774. } else if (item[JV.PROP_ADJUST_ACTION] === "suffix") {
  775. rec[item.key] = rec[item.key] + item[JV.PROP_ADJUST_ACTION_VAL];
  776. }
  777. }
  778. }
  779. replaceActDataArr(sourceData, rstArr);
  780. }
  781. function componentReplacement(rawDataObj) {
  782. let rationGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION_GLJ),
  783. prjGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.PROJECTGLJ),
  784. gljAssistant = prjGljData.data.gljAssistant;
  785. let connectStrArr = [], dataArr = getActDataArr(rationGljData), rvRGljIds = [], replaceGljItems = [];
  786. for (let idx = 0; idx < dataArr.length; idx++) {
  787. let rationGljItem = dataArr[idx];
  788. if (rationGljItem.type === 301 || rationGljItem.type === 302) {
  789. connectStrArr[0] = rationGljItem.code;
  790. connectStrArr[1] = rationGljItem.name;
  791. connectStrArr[2] = rationGljItem.specs;
  792. connectStrArr[3] = rationGljItem.unit;
  793. connectStrArr[4] = rationGljItem.type;
  794. let mapData = prjGljData.data.mixRatioMap[connectStrArr.join('|-|')];
  795. if (mapData) {
  796. rvRGljIds.push(idx);
  797. let rgItems = [];
  798. replaceGljItems.push(rgItems);
  799. for (let mapItem of mapData) {
  800. let copyItem = {};
  801. rgItems.push(copyItem);
  802. copyItem.ID = `Replace_` + rationGljItem.ID;
  803. copyItem.projectID = rationGljItem.projectID;
  804. copyItem.GLJID = rationGljItem.GLJID;
  805. copyItem.rationID = rationGljItem.rationID;
  806. if (gljAssistant.componentGljIds[COMPONENT_GLJID_PRE + mapItem.glj_id]) {
  807. copyItem.projectGLJID = gljAssistant.componentGljIds[COMPONENT_GLJID_PRE + mapItem.glj_id].id; //关键key
  808. } else {
  809. copyItem.projectGLJID = mapItem.glj_id; //不应该走到这一步,否则就是错误!!!
  810. }
  811. copyItem.rationItemQuantity = rationGljItem.rationItemQuantity;
  812. // copyItem.quantity = rationGljItem.quantity;
  813. copyItem.quantity = rationGljItem.quantity * mapItem.consumption;
  814. copyItem.name = mapItem.name;
  815. copyItem.code = mapItem.code;
  816. copyItem.original_code = mapItem.code;
  817. copyItem.unit = mapItem.unit;
  818. copyItem.specs = mapItem.specs;
  819. copyItem.model = gljAssistant.gljIds['gljId_'+rationGljItem.projectGLJID].model;
  820. copyItem.shortName = mapItem.shortName;
  821. copyItem.billsItemID = rationGljItem.billsItemID;
  822. copyItem.type = mapItem.type; //关键key
  823. }
  824. }
  825. }
  826. }
  827. if (rvRGljIds.length > 0) {
  828. for (let lIdx = rvRGljIds.length - 1; lIdx >= 0; lIdx--) {
  829. dataArr.splice(rvRGljIds[lIdx],1);
  830. }
  831. for (let componentItems of replaceGljItems) {
  832. for (let compItem of componentItems) {
  833. dataArr.push(compItem);
  834. //gljAssistant[COMPONENT_GLJID_PRE + mapItem.glj_id]
  835. }
  836. }
  837. }
  838. }
  839. function moveRationData(rationData, rawDataObj) {
  840. if (rawDataObj) {
  841. // let rationData = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION);
  842. let rationGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION_GLJ);
  843. let prjGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.PROJECTGLJ);
  844. let tenderSetting = rawDataObj.prj.property.tenderSettin;
  845. let dummyCode = " ", dummyPRJID = 10101010;
  846. for (let rationItem of getActDataArr(rationData)) {
  847. if (rationItem.type === 2 || rationItem.type === 3) {
  848. //2: 量材(人工/材料/机械/主材/设备) 3:材料(材料/主材/设备)
  849. let copyItem = {};
  850. copyItem.ID = rationItem.ID;
  851. copyItem.projectID = rationItem.projectID;
  852. copyItem.GLJID = rationItem.GLJID;
  853. copyItem.rationID = rationItem.ID;
  854. copyItem.rationItemQuantity = 1;
  855. copyItem.quantity = 1;
  856. // copyItem.specialType_quantity = rationItem.quantity;
  857. copyItem.name = rationItem.name;
  858. if (rationItem.code) {
  859. copyItem.code = rationItem.ID + "_" + rationItem.code;
  860. } else {
  861. copyItem.code = dummyCode;
  862. dummyCode = dummyCode + " ";
  863. }
  864. copyItem.original_code = rationItem.original_code;
  865. copyItem.unit = rationItem.unit;
  866. copyItem.specs = rationItem.specs;
  867. copyItem.shortName = rationItem.shortName;
  868. copyItem.billsItemID = rationItem.billsItemID;
  869. copyItem.type = rationItem.subType;
  870. if (rationItem.projectGLJID) {
  871. copyItem.projectGLJID = rationItem.projectGLJID;
  872. } else {
  873. //add dummy project GLJ
  874. let dummyPrjItem = {};
  875. copyItem.projectGLJID = dummyPRJID;
  876. dummyPrjItem.id = dummyPRJID;
  877. dummyPRJID++;
  878. dummyPrjItem.name = rationItem.name;
  879. dummyPrjItem.unit_price = {};
  880. dummyPrjItem.unit_price.base_price = 0;
  881. dummyPrjItem.unit_price.market_price = (rationItem["marketUnitFee"])?rationItem["marketUnitFee"]:0;
  882. if (tenderSetting && tenderSetting.gljPriceTenderCoe) {
  883. dummyPrjItem.unit_price.market_price = dummyPrjItem.unit_price.market_price * parseFloat(tenderSetting.gljPriceTenderCoe);
  884. }
  885. dummyPrjItem.quantity = 1; //这里设置为1只是为了不被误过滤
  886. dummyPrjItem.is_evaluate = 0;
  887. prjGljData.data.gljList.push(dummyPrjItem);
  888. }
  889. rationGljData.data.push(copyItem);
  890. } else {
  891. //无
  892. }
  893. }
  894. // fsUtil.writeObjToFile(rationGljData.data, "D:/GitHome/temp/afterMoveGLJ.jsp");
  895. }
  896. }
  897. //有些项目工料机有组成物,有些表需要显示这些组成物,此函数把这些组成物抽出并归类到定额工料机下
  898. function moveRationComponentData(rationData, rawDataObj) {
  899. let rationGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION_GLJ);
  900. let prjGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.PROJECTGLJ);
  901. let newComponentItem = [];
  902. for (let rationGljItem of getActDataArr(rationGljData)) {
  903. for (let prjGljItem of prjGljData.data.gljList) {
  904. if (prjGljItem.id === rationGljItem.projectGLJID) {
  905. if (prjGljItem.ratio_data && prjGljItem.ratio_data.length > 0 && !gljUtil.isConcreteType(prjGljItem.type)) {
  906. //有组成物
  907. for (let comItem of prjGljItem.ratio_data) {
  908. let copyItem = {};
  909. copyItem.ID = comItem._id.toString();
  910. copyItem.projectID = rationGljItem.projectID;
  911. copyItem.rationID = rationGljItem.rationID;
  912. // copyItem.rationItemQuantity = rationGljItem.quantity;
  913. copyItem.quantity = parseFloat(rationGljItem.quantity) * parseFloat(comItem.consumption);
  914. copyItem.name = comItem.name;
  915. copyItem.code = comItem.code;
  916. copyItem.unit = comItem.unit;
  917. copyItem.specs = comItem.specs;
  918. // copyItem.shortName = comItem.shortName;
  919. copyItem.billsItemID = rationGljItem.billsItemID;
  920. copyItem.type = comItem.type;
  921. //其他属性,要根据工料机ID来查找
  922. for (let gljIdx = 0; gljIdx < prjGljData.data.gljList.length; gljIdx++) {
  923. if (prjGljData.data.gljList[gljIdx].code === comItem.code) {
  924. copyItem.projectGLJID = prjGljData.data.gljList[gljIdx].id;
  925. copyItem.original_code = prjGljData.data.gljList[gljIdx].original_code;
  926. copyItem.is_main_material = prjGljData.data.gljList[gljIdx].is_main_material;
  927. copyItem.is_adjust_price = prjGljData.data.gljList[gljIdx].is_adjust_price;
  928. copyItem.unit_price = {};
  929. copyItem.unit_price.base_price = prjGljData.data.gljList[gljIdx].unit_price.base_price;
  930. copyItem.unit_price.market_price = prjGljData.data.gljList[gljIdx].unit_price.market_price;
  931. break;
  932. }
  933. }
  934. newComponentItem.push(copyItem);
  935. }
  936. }
  937. break;
  938. }
  939. }
  940. }
  941. rationGljData.data = rationGljData.data.concat(newComponentItem);
  942. }
  943. function getDupGrpKeyVals(sourceData, segKeys) {
  944. let rst = [];
  945. function pushKeyVal(item) {
  946. let tr = {};
  947. for (let i = 0; i < segKeys.length; i++) {
  948. tr[segKeys[i]] = item[segKeys[i]];
  949. }
  950. rst.push(tr);
  951. }
  952. for (let idx = 0; idx < sourceData.length; idx++) {
  953. let itemRec = sourceData[idx];
  954. if (idx === 0) {
  955. pushKeyVal(itemRec);
  956. continue;
  957. }
  958. let hasDiff = false;
  959. for (let i = 0; i < segKeys.length; i++) {
  960. if (itemRec[segKeys[i]] !== sourceData[idx - 1][segKeys[i]]) {
  961. hasDiff = true;
  962. break;
  963. }
  964. }
  965. if (hasDiff) {
  966. pushKeyVal(itemRec);
  967. }
  968. }
  969. return rst;
  970. }
  971. function addDummyData(sourceData, addCfg) {
  972. let rstArr = [], tempRstArr = [];
  973. for (let item of getActDataArr(sourceData)) {
  974. if (item._doc) {
  975. tempRstArr.push(item._doc);
  976. } else {
  977. tempRstArr.push(item);
  978. }
  979. }
  980. for (let item of addCfg[JV.PROP_DUMMY_COLLECTION]) {
  981. let newRecStr = JSON.stringify(item[JV.PROP_DUMMY_VAL]), cacheGrpKeyRecs = null;
  982. if (item[JV.PROP_FREQUENCY] === "OncePerGrp") {
  983. if (!cacheGrpKeyRecs) {
  984. cacheGrpKeyRecs = {};
  985. }
  986. let cacheKey = "";
  987. for (let key of item[JV.PROP_GRP_KEYS]) {
  988. cacheKey += "_" + key;
  989. }
  990. if (!cacheGrpKeyRecs[cacheKey]) {
  991. cacheGrpKeyRecs[cacheKey] = getDupGrpKeyVals(tempRstArr, item[JV.PROP_GRP_KEYS]);
  992. }
  993. for (let kv of cacheGrpKeyRecs[cacheKey]) {
  994. let rec = JSON.parse(newRecStr);
  995. for (let key of item[JV.PROP_GRP_KEYS]) {
  996. rec[key] = kv[key];
  997. }
  998. rstArr.push(rec);
  999. }
  1000. } else if (item[JV.PROP_FREQUENCY] === "Once") {
  1001. rstArr.push(JSON.parse(newRecStr));
  1002. }
  1003. }
  1004. rstArr = rstArr.concat(tempRstArr);
  1005. replaceActDataArr(sourceData, rstArr);
  1006. }
  1007. function getGLJBizType2018(orgType, orgCode, orgName) {
  1008. let rst = orgType;
  1009. if (orgType === GLJ_TYPE.Labour) {
  1010. rst = 11;
  1011. if (orgCode === "000000") rst = 10;
  1012. } else if (orgType === GLJ_TYPE.Material || (orgType >= 200 && orgType < 300)) {
  1013. //材料
  1014. if (orgCode === "000000") {
  1015. rst = 200; //2.材料
  1016. } else if (orgCode === "000000_1") {
  1017. rst = 230; //(1) 计价材料
  1018. } else if (orgCode === "000000_2") {
  1019. rst = 240; //(2) 其他材料费
  1020. } else {
  1021. if (orgType === GLJ_TYPE.OTHER_MATERIAL) {
  1022. //其他材料
  1023. rst = 245;
  1024. } else {
  1025. //计价材料
  1026. rst = 235;
  1027. }
  1028. }
  1029. } else if (orgType === GLJ_TYPE.Machine || (orgType >= 300 && orgType < 400)) {
  1030. //机械
  1031. if (orgCode === "000000") {
  1032. rst = 300; //3.机械
  1033. } else if (orgCode === "000000_1") {
  1034. rst = 330; //(1) 机上人工
  1035. } else if (orgCode === "000000_2") {
  1036. rst = 340; //(2) 燃油动力费
  1037. } else if (orgCode === "000000_3") {
  1038. rst = 350; //(2) 施工机具摊销费
  1039. } else {
  1040. if (orgType === GLJ_TYPE.MACHINE_LABOUR) {
  1041. //机上人工
  1042. rst = 335;
  1043. } else if (orgType === GLJ_TYPE.FUEL_POWER_FEE) {
  1044. //燃油动力费
  1045. rst = 345;
  1046. } else if (oprMachines.indexOf(orgType) >= 0) {
  1047. //施工机具摊销费
  1048. rst = 355 + oprMachines.indexOf(orgType);
  1049. }
  1050. }
  1051. }
  1052. return rst;
  1053. }
  1054. function getGLJBizType(orgType, orgCode, orgName) {
  1055. let rst = orgType;
  1056. if (orgName.indexOf("其他材料费") >= 0) {
  1057. rst = 299;
  1058. } else if (orgType === GLJ_TYPE.Labour) {
  1059. rst = 11;
  1060. if (orgCode === "000000") rst = 10;
  1061. } else if (orgType === GLJ_TYPE.Main_Material || orgType === GLJ_TYPE.Equipment) {
  1062. //未计价材料(主材 + 设备)
  1063. rst = 30 + orgType;
  1064. } else if (orgType === GLJ_TYPE.Material || (orgType >= 200 && orgType < 300)) {
  1065. //材料
  1066. if (orgCode === "000000") {
  1067. rst = 20; //2.材料
  1068. } else if (orgCode === "000000_1") {
  1069. rst = 30; //(1) 未计价材料
  1070. } else if (orgCode === "000000_2") {
  1071. rst = 40; //(2) 辅助材料
  1072. } else if (orgCode === "000000_3") {
  1073. rst = 50; //(3) 其他材料费
  1074. } else {
  1075. rst = 45; //到这里就只有辅助材料没有预处理了
  1076. }
  1077. } else if (orgType === GLJ_TYPE.Machine || (orgType >= 300 && orgType < 400)) {
  1078. //机械
  1079. if (orgCode === "000000") {
  1080. rst = 300; //3.机械
  1081. } else if (orgType === GLJ_TYPE.Machine) {
  1082. rst = 300.5;
  1083. } else {
  1084. rst = orgType;
  1085. }
  1086. }
  1087. return rst;
  1088. }
  1089. function sortData(sourceData, sortCfg, prjData) {
  1090. let rst = getActDataArr(sourceData), tempRstArr = [];
  1091. let sortType = sortCfg[JV.PROP_SORT_TYPE];
  1092. let srcData = getActDataArr(sourceData);
  1093. for (let item of srcData) {
  1094. if (item._doc) {
  1095. tempRstArr.push(item._doc);
  1096. } else {
  1097. tempRstArr.push(item);
  1098. }
  1099. }
  1100. function private_normal_sort(destArr, sortKeys) {
  1101. destArr.sort(function(a, b){
  1102. let compRst = 0;
  1103. for (let comp of sortKeys) {
  1104. let reverse = (comp.order === 'ascend')?1:(-1);
  1105. //
  1106. if (a[comp.key] > b[comp.key]) {
  1107. compRst = reverse;
  1108. break;
  1109. } else if (a[comp.key] < b[comp.key]) {
  1110. compRst = -reverse;
  1111. break;
  1112. }
  1113. }
  1114. return compRst;
  1115. });
  1116. }
  1117. function private_parent_sort(parentArr, parentKeys, childArr, childKeys) {
  1118. let tmpRst = {}, rst = [];
  1119. for (let pItem of parentArr) {
  1120. let pKey = "key";
  1121. for (let key of parentKeys) {
  1122. pKey += "_" + pItem[key];
  1123. }
  1124. tmpRst[pKey] = [];
  1125. }
  1126. for (let cItem of childArr) {
  1127. let cKey = "key";
  1128. for (let key of childKeys) {
  1129. cKey += "_" + cItem[key];
  1130. }
  1131. if (tmpRst[cKey]) {
  1132. tmpRst[cKey].push(cItem);
  1133. } else {
  1134. //unknown child value! should be filtered!
  1135. }
  1136. }
  1137. // childArr.splice(0);
  1138. for (let pItem of parentArr) {
  1139. let pKey = "key";
  1140. for (let key of parentKeys) {
  1141. pKey += "_" + pItem[key];
  1142. }
  1143. rst.push(tmpRst[pKey]);
  1144. // for (let rItem of tmpRst[pKey]) {
  1145. // childArr.push(rItem);
  1146. // }
  1147. }
  1148. return rst;
  1149. }
  1150. switch (sortType) {
  1151. case "tree":
  1152. let addLevel = true;
  1153. rst = treeUtil.buildTreeNodeDirectly(tempRstArr, addLevel);
  1154. let newTopArr = [];
  1155. if ((sortCfg[JV.PROP_FILTER_TOP_BILLS_NODES] && sortCfg[JV.PROP_FILTER_TOP_BILLS_NODES].length > 0) ||
  1156. (sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES] && sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES].length > 0)) {
  1157. let local_check_bills = function(tItem) {
  1158. let chkDtl = false;
  1159. if (tItem.flags && tItem.flags.length > 0) {
  1160. for (let flagItem of tItem.flags) {
  1161. if (sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES].indexOf(flagItem.flag) >= 0) {
  1162. newTopArr.push(tItem);
  1163. chkDtl = true;
  1164. break;
  1165. }
  1166. }
  1167. }
  1168. if (!chkDtl && tItem.items && tItem.items.length > 0) {
  1169. for (let dtlItem of tItem.items) {
  1170. local_check_bills(dtlItem);
  1171. }
  1172. }
  1173. };
  1174. for (let topItem of rst) {
  1175. let chkTop = false;
  1176. if (topItem.flags && topItem.flags.length > 0) {
  1177. for (let flagItem of topItem.flags) {
  1178. if (sortCfg[JV.PROP_FILTER_TOP_BILLS_NODES].indexOf(flagItem.flag) >= 0) {
  1179. newTopArr.push(topItem);
  1180. chkTop = true;
  1181. break;
  1182. }
  1183. }
  1184. }
  1185. if (!chkTop && sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES] && sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES].length > 0) {
  1186. local_check_bills(topItem);
  1187. }
  1188. }
  1189. } else {
  1190. newTopArr = rst;
  1191. }
  1192. let destArr = [];
  1193. // fsUtil.writeObjToFile(newTopArr, "D:/GitHome/temp/sortedAndFlattedRstBefore.jsp");
  1194. treeUtil.getFlatArray(newTopArr, destArr, true);
  1195. // console.log(destArr);
  1196. replaceActDataArr(sourceData, destArr);
  1197. // fsUtil.writeObjToFile(sourceData.data, "D:/GitHome/temp/sortedAndFlattedRst.jsp");
  1198. break;
  1199. case "normal":
  1200. private_normal_sort(tempRstArr, sortCfg[JV.PROP_SORT_KEYS]);
  1201. replaceActDataArr(sourceData, tempRstArr);
  1202. // fsUtil.writeObjToFile(sourceData.data, "D:/GitHome/temp/normalSortedRst.jsp");
  1203. break;
  1204. case "accord_to_parent":
  1205. let pcKey = sortCfg[JV.PROP_PARENT_CHILD_SORT_KEY];
  1206. let parentSrcData = getModuleDataByKey(prjData, pcKey[JV.PROP_PARENT_DATA_KEY]);
  1207. if (parentSrcData) {
  1208. let tempParentArr = [];
  1209. for (let item of getActDataArr(parentSrcData)) {
  1210. if (item._doc) {
  1211. tempParentArr.push(item._doc);
  1212. } else {
  1213. tempParentArr.push(item);
  1214. }
  1215. }
  1216. let sortedRstArr = private_parent_sort(tempParentArr, pcKey[JV.PROP_PARENT_SORT_KEYS], tempRstArr, pcKey[JV.PROP_CHILD_SORT_KEYS]);
  1217. if (sortCfg[JV.PROP_OTHER_SUB_SORT] && sortCfg[JV.PROP_OTHER_SUB_SORT].length > 0) {
  1218. for (let sort of sortCfg[JV.PROP_OTHER_SUB_SORT]) {
  1219. if (sort[JV.PROP_SORT_TYPE] === 'normal') {
  1220. for (let subArr of sortedRstArr) {
  1221. private_normal_sort(subArr, sort[JV.PROP_SORT_KEYS]);
  1222. }
  1223. } else if (sort[JV.PROP_SORT_TYPE] === 'self_define') {
  1224. for (let subArr of sortedRstArr) {
  1225. // console.log(subArr);
  1226. let selfDefFunc = null;
  1227. eval('selfDefFunc = ' + sort[JV.PROP_SORT_TYPE_SELF_DEFINE_LOGIC]);
  1228. subArr.sort(selfDefFunc);
  1229. // console.log(subArr);
  1230. }
  1231. }
  1232. }
  1233. }
  1234. tempRstArr.splice(0);
  1235. for (let item of sortedRstArr) {
  1236. for (let subItem of item) {
  1237. tempRstArr.push(subItem);
  1238. }
  1239. }
  1240. }
  1241. replaceActDataArr(sourceData, tempRstArr);
  1242. break;
  1243. case "self_define":
  1244. if (sortCfg[JV.PROP_SORT_TYPE_SELF_DEFINE_LOGIC]) {
  1245. let selfDefFuncA = null;
  1246. eval('selfDefFuncA = ' + sortCfg[JV.PROP_SORT_TYPE_SELF_DEFINE_LOGIC]);
  1247. if (selfDefFuncA !== null) {
  1248. tempRstArr.sort(selfDefFuncA);
  1249. } else {
  1250. console.log('sorting function is null!!!');
  1251. }
  1252. }
  1253. replaceActDataArr(sourceData, tempRstArr);
  1254. break;
  1255. default:
  1256. //
  1257. }
  1258. return rst;
  1259. }
  1260. function setupMainFunc(obj, prop, ownRawObj) {
  1261. obj[prop] = {};
  1262. obj[prop]["myOwnRawDataObj"] = ownRawObj;
  1263. obj[prop].getProperty = ext_mainGetPropety;
  1264. obj[prop].getFee = ext_mainGetFee;
  1265. }
  1266. function setupFeeRate(feeRateData){
  1267. let cacheObj = {}, topArr = [], rstArr = [], id_pre = 'ID_';
  1268. const rateProperties = [];
  1269. for (let rate of feeRateData.rates) {
  1270. cacheObj[id_pre + rate._doc.ID] = {"obj": rate._doc, "items": []};
  1271. // cacheObj[id_pre + rate.ID].items = [];
  1272. if (rate._doc.ParentID === null || rate._doc.ParentID === undefined) {
  1273. topArr.push(cacheObj[id_pre + rate._doc.ID]);
  1274. }
  1275. }
  1276. for (let rate of feeRateData.rates) {
  1277. if (rate._doc.ParentID && cacheObj[id_pre + rate._doc.ParentID]) {
  1278. cacheObj[id_pre + rate._doc.ParentID].items.push(cacheObj[id_pre + rate._doc.ID]);
  1279. if (rateProperties.indexOf(rate._doc.name) < 0) {
  1280. rateProperties.push(rate._doc.name);
  1281. }
  1282. }
  1283. }
  1284. let pri_func_set_property_rate = function (orgRateItem, rstRateItem) {
  1285. rstRateItem[orgRateItem.obj.name] = orgRateItem.obj.rate;
  1286. for (let subOrgRateItem of orgRateItem.items) {
  1287. pri_func_set_property_rate(subOrgRateItem, rstRateItem);
  1288. }
  1289. };
  1290. for (let topRate of topArr) {
  1291. let rstItem = {"name": topRate.obj.name, "ID": topRate.obj.ID};
  1292. for (let property of rateProperties) {
  1293. rstItem[property] = 0;
  1294. }
  1295. for (let dtlRateItem of topRate.items) {
  1296. pri_func_set_property_rate(dtlRateItem, rstItem);
  1297. }
  1298. rstArr.push(rstItem);
  1299. }
  1300. return rstArr;
  1301. }
  1302. function setupFunc(obj, prop, ownRawObj) {
  1303. obj[prop] = {};
  1304. obj[prop]["myOwnRawDataObj"] = ownRawObj;
  1305. obj[prop]["myOwnOrgRawDataObj"] = ownRawObj.data;
  1306. obj[prop].getProperty = ext_getProperty;
  1307. obj[prop].getGljFreightProperty = ext_getGljFreightProperty;
  1308. obj[prop].getAdHocGljProperty = ext_getAdHocGljProperty;
  1309. obj[prop].getGljOriginalProperty = ext_getGljOriginalProperty;
  1310. obj[prop].getPropertyByRefId = ext_getPropertyByRefId;
  1311. obj[prop].getFee = ext_getFee;
  1312. obj[prop].getPropertyByForeignId = ext_getPropertyByForeignId;
  1313. obj[prop].getArrayValues = ext_getArrayValues;
  1314. obj[prop].getArrayItemByKey = ext_getArrayItemByKey;
  1315. obj[prop].getPropertyByFlag = ext_getPropertyByFlag;
  1316. obj[prop].getSubRateProperty = ext_getRateProperty;
  1317. obj[prop].getRateProperty = ext_getRateProperty;
  1318. obj[prop].getBlank = ext_getBlank;
  1319. obj[prop].getRatioDataProperty = ext_getRatioDataProperty;
  1320. obj[prop].getRatioDataParentProperty = ext_getRatioDataParentProperty;
  1321. obj[prop].getRatioDataPriceMapProperty = ext_getRatioDataPriceMapProperty;
  1322. if (prop === projectConst.CALC_PROGRAM) obj[prop].getCalcProperty = ext_getCalcProperty;
  1323. if (prop === projectConst.FEERATE) obj[prop].getFeeRate = ext_getFeeRate;
  1324. }
  1325. function assembleFields(fieldList, rstDataArr, $PROJECT) {
  1326. if (fieldList) {
  1327. for (let field of fieldList) {
  1328. shielded_exec_env($PROJECT, field, rstDataArr);
  1329. if ("Precision" in field) {
  1330. if (field["Precision"]["type"] === "fixed") {
  1331. let vrst = eval(field["Precision"]["fixedMapExpression"]);
  1332. if (vrst && vrst.length === 1) {
  1333. field.fixedPrecisionNum = vrst[0];
  1334. vrst.splice(0,1);
  1335. }
  1336. } else if (field["Precision"]["type"] === "flexible") {
  1337. let vrst = eval(field["Precision"]["flexibleMapExpression"]);
  1338. if (vrst && vrst.length === 1) {
  1339. field.flexiblePrecisionRefObj =vrst[0];
  1340. vrst.splice(0,1);
  1341. }
  1342. }
  1343. }
  1344. }
  1345. }
  1346. }
  1347. function shielded_exec_env($PROJECT, $ME, rptDataItemObj) {
  1348. if ($ME[JV.PROP_FIELD_EXP_MAP]) {
  1349. rptDataItemObj.push(eval($ME[JV.PROP_FIELD_EXP_MAP]));
  1350. }
  1351. }
  1352. function getActPropertyVal(firstPropKey, secPropKey, orgObj) {
  1353. let rst = null;
  1354. if (orgObj[firstPropKey]) {
  1355. rst = orgObj[firstPropKey];
  1356. } else if (orgObj[secPropKey]){
  1357. rst = orgObj[secPropKey];
  1358. }
  1359. return rst;
  1360. }
  1361. function getDeepProperty(propKey, orgObj, destArr) {
  1362. let keys = propKey.split(".");
  1363. let dftPropKey = "key", dftPropVal = "value", secDftPropVal = "items";
  1364. let parent = orgObj, lastVal = null;
  1365. for (let key of keys) {
  1366. if (parent instanceof Array) {
  1367. for (let item of parent) {
  1368. if (item[dftPropKey] === key) {
  1369. lastVal = getActPropertyVal(dftPropVal, secDftPropVal, item);
  1370. break;
  1371. }
  1372. }
  1373. } else {
  1374. lastVal = null;
  1375. if (parent[key] !== undefined) {
  1376. lastVal = parent[key];
  1377. } else if (parent[secDftPropVal]){
  1378. for (let item of parent[secDftPropVal]) {
  1379. if (item[dftPropKey] === key) {
  1380. // lastVal = item[dftPropVal];
  1381. lastVal = getActPropertyVal(dftPropVal, secDftPropVal, item);
  1382. break;
  1383. }
  1384. }
  1385. }
  1386. }
  1387. parent = lastVal;
  1388. if (parent === null) break;
  1389. }
  1390. if (destArr && destArr instanceof Array) {
  1391. destArr.push(lastVal);
  1392. }
  1393. }
  1394. function ext_mainGetPropety(propKey) {
  1395. let rst = [], parentObj = this;
  1396. let dtObj = parentObj["myOwnRawDataObj"];
  1397. if (propKey && dtObj) {
  1398. if (dtObj.hasOwnProperty("property")) {
  1399. if (!dtObj["property"][propKey] && dtObj[propKey]) {
  1400. rst.push(dtObj[propKey]);
  1401. } else {
  1402. getDeepProperty(propKey, dtObj["property"], rst);
  1403. }
  1404. } else {
  1405. // rst.push(dtObj[propKey]);
  1406. getDeepProperty(propKey, dtObj, rst);
  1407. }
  1408. }
  1409. return rst;
  1410. }
  1411. function ext_getRateProperty(propKey) {
  1412. let rst = [], parentObj = this;
  1413. let dtObj = parentObj["myOwnRawDataObj"];
  1414. if (propKey && dtObj) {
  1415. if (propKey instanceof Array) {
  1416. for (let pKey of propKey) {
  1417. for (let rate of dtObj.data._doc.rates) {
  1418. if (rate[pKey]) {
  1419. rst.push(rate[pKey]);
  1420. } else {
  1421. rst.push(0);
  1422. }
  1423. }
  1424. }
  1425. } else {
  1426. for (let rate of dtObj.data._doc.rates) {
  1427. rst.push(rate[propKey]);
  1428. }
  1429. }
  1430. }
  1431. return rst;
  1432. }
  1433. function ext_getRatioDataProperty(propKey) {
  1434. //获取工料机的组成物属性
  1435. let rst = [], parentObj = this;
  1436. let dtObj = parentObj["myOwnRawDataObj"];
  1437. if (propKey && dtObj) {
  1438. for (let dItem of getActDataArr(dtObj)) {
  1439. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1440. for (let ratioItem of doc.ratio_data) {
  1441. rst.push(ratioItem[propKey]);
  1442. }
  1443. }
  1444. }
  1445. return rst;
  1446. }
  1447. function pri_push_property(propKey, doc, rst) {
  1448. if (propKey instanceof Array) {
  1449. //备注:这里的key数组表示取value的优先级
  1450. for (let pi = 0; pi < propKey.length; pi++) {
  1451. if (doc.hasOwnProperty("property")) {
  1452. if (doc["property"].hasOwnProperty(propKey[pi])) {
  1453. rst.push(doc["property"][propKey[pi]]);
  1454. break;
  1455. }
  1456. } else if (doc.hasOwnProperty(propKey[pi])) {
  1457. rst.push(doc[propKey[pi]]);
  1458. break;
  1459. } else {
  1460. let lenBefore = rst.length;
  1461. getDeepProperty(propKey[pi], doc, rst);
  1462. if (rst.length === (lenBefore + 1)) {
  1463. if (rst[lenBefore] !== null && rst[lenBefore] !== undefined && rst[lenBefore] !== "") {
  1464. break;
  1465. } else {
  1466. rst.splice(-1, 1); //删除末尾一条数据,给后面留空间
  1467. }
  1468. }
  1469. }
  1470. if (pi === propKey.length - 1) rst.push('');
  1471. }
  1472. } else {
  1473. if (doc.hasOwnProperty("property") && doc["property"].hasOwnProperty(propKey)) {
  1474. rst.push(doc["property"][propKey]);
  1475. } else if (doc.hasOwnProperty(propKey)) {
  1476. rst.push(doc[propKey]);
  1477. } else {
  1478. getDeepProperty(propKey, doc, rst);
  1479. }
  1480. }
  1481. }
  1482. function ext_getRatioDataParentProperty(propKey) {
  1483. //获取组成物的父项属性
  1484. let rst = [], parentObj = this;
  1485. let dtObj = parentObj["myOwnRawDataObj"];
  1486. if (propKey && dtObj) {
  1487. for (let dItem of getActDataArr(dtObj)) {
  1488. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1489. for (let ratioItem of doc.ratio_data) {
  1490. pri_push_property(propKey, doc, rst);
  1491. }
  1492. }
  1493. }
  1494. return rst;
  1495. }
  1496. function ext_getRatioDataPriceMapProperty(propKey) {
  1497. //获取组成物的单价映射属性
  1498. let rst = [], parentObj = this;
  1499. let dtObj = parentObj["myOwnRawDataObj"];
  1500. if (propKey && dtObj) {
  1501. let unitPriceMap = dtObj.data.unitPriceMap;
  1502. let upmDoc = (unitPriceMap._doc === null || unitPriceMap._doc === undefined)?unitPriceMap:unitPriceMap._doc;
  1503. for (let dItem of getActDataArr(dtObj)) {
  1504. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1505. for (let ratioItem of doc.ratio_data) {
  1506. let connectionKeys = [];
  1507. connectionKeys.push(ratioItem.code);
  1508. connectionKeys.push(ratioItem.name);
  1509. connectionKeys.push((ratioItem.specs === "")?"null":ratioItem.specs);
  1510. connectionKeys.push(ratioItem.unit);
  1511. connectionKeys.push(ratioItem.type);
  1512. connectionKeys.join("|-|");
  1513. let strPK = connectionKeys.join("|-|");
  1514. let dtlDoc = (upmDoc[strPK]._doc)?upmDoc[strPK]._doc:upmDoc[strPK];
  1515. rst.push(dtlDoc[propKey]);
  1516. }
  1517. }
  1518. }
  1519. return rst;
  1520. }
  1521. function ext_getAdHocGljProperty(adhocDataKey, propKey) {
  1522. let rst = [], parentObj = this;
  1523. let dtObj = parentObj["myOwnRawDataObj"];
  1524. if (propKey && dtObj) {
  1525. for (let dItem of getActDataArr(dtObj, adhocDataKey)) {
  1526. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1527. pri_push_property(propKey, doc, rst);
  1528. }
  1529. }
  1530. return rst;
  1531. }
  1532. function ext_getGljFreightProperty(propKey) {
  1533. let rst = [], parentObj = this;
  1534. let dtObj = parentObj["myOwnRawDataObj"];
  1535. if (propKey && dtObj) {
  1536. for (let dItem of getActDataArr(dtObj, "freightList")) {
  1537. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1538. pri_push_property(propKey, doc, rst);
  1539. }
  1540. }
  1541. return rst;
  1542. }
  1543. function ext_getGljOriginalProperty(propKey) {
  1544. let rst = [], parentObj = this;
  1545. let dtObj = parentObj["myOwnRawDataObj"];
  1546. if (propKey && dtObj) {
  1547. for (let dItem of getActDataArr(dtObj, "originalList")) {
  1548. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1549. pri_push_property(propKey, doc, rst);
  1550. }
  1551. }
  1552. return rst;
  1553. }
  1554. function ext_getProperty(propKey) {
  1555. let rst = [], parentObj = this;
  1556. let dtObj = parentObj["myOwnRawDataObj"];
  1557. if (propKey && dtObj) {
  1558. for (let dItem of getActDataArr(dtObj)) {
  1559. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1560. pri_push_property(propKey, doc, rst);
  1561. }
  1562. }
  1563. return rst;
  1564. }
  1565. function ext_getPropertyByRefId(baseKey, refIDKey, propertyKey){
  1566. let rst = [], parentObj = this;
  1567. let dtObj = parentObj["myOwnRawDataObj"];
  1568. let orgDtObj = parentObj["myOwnOrgRawDataObj"];
  1569. if (baseKey && refIDKey && propertyKey && dtObj) {
  1570. for (let dItem of getActDataArr(dtObj)) {
  1571. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1572. let tmpRst = doc[baseKey];
  1573. if (typeof tmpRst === "string" && tmpRst[0] === "@") {
  1574. let refKey = tmpRst.slice(1);
  1575. let hasGetRef = false;
  1576. for (let orgDItem of orgDtObj) {
  1577. let oDoc = (orgDItem._doc === null || orgDItem._doc === undefined)?orgDItem:orgDItem._doc;
  1578. if (oDoc[refIDKey] === refKey) {
  1579. rst.push(oDoc[propertyKey]);
  1580. hasGetRef = true;
  1581. break;
  1582. }
  1583. }
  1584. if (!hasGetRef) {
  1585. rst.push(tmpRst);
  1586. }
  1587. } else {
  1588. rst.push(tmpRst);
  1589. }
  1590. }
  1591. }
  1592. return rst;
  1593. }
  1594. function ext_mainGetFee(feeKey, dtlFeeKey) {
  1595. let rst = [];
  1596. let parentObj = this;
  1597. let dtObj = parentObj["myOwnRawDataObj"];
  1598. if ((dtObj) && (feeKey)) {
  1599. if (dtObj.hasOwnProperty("fees")) {
  1600. for (let fee of dtObj["fees"]) {
  1601. if (fee["fieldName"] === feeKey) {
  1602. if (dtlFeeKey) {
  1603. rst.push(fee[dtlFeeKey]);
  1604. } else {
  1605. rst.push(fee["unitFee"]);
  1606. }
  1607. break;
  1608. }
  1609. }
  1610. } else if (dtObj.hasOwnProperty(feeKey)) {
  1611. rst.push(dtObj[feeKey]);
  1612. } else {
  1613. //
  1614. }
  1615. }
  1616. return rst;
  1617. }
  1618. function ext_getFee(feeKey, dtlFeeKey) {
  1619. let rst = [], parentObj = this;
  1620. let dtObj = parentObj["myOwnRawDataObj"];
  1621. if (feeKey && dtObj) {
  1622. for (let dItem of getActDataArr(dtObj)) {
  1623. rst.push(pri_getFee(dItem, feeKey, dtlFeeKey));
  1624. }
  1625. }
  1626. for (let i = 0; i < rst.length; i++) {
  1627. rst[i] = parseFloat(rst[i]);
  1628. }
  1629. return rst;
  1630. }
  1631. function pri_getFee(dItem, feeKey, dtlFeeKey) {
  1632. let rst = 0;
  1633. let hasValue = false;
  1634. if (dItem["fees"]) {
  1635. for (let fee of dItem["fees"]) {
  1636. if (fee["fieldName"] === feeKey) {
  1637. if (dtlFeeKey) {
  1638. rst = fee[dtlFeeKey];
  1639. } else {
  1640. rst = fee["unitFee"];
  1641. }
  1642. hasValue = true;
  1643. break;
  1644. }
  1645. }
  1646. } else if (dItem[feeKey]) {
  1647. hasValue = true;
  1648. rst = parseFloat(dItem[feeKey]);
  1649. } else {
  1650. hasValue = true;
  1651. rst = 0;
  1652. }
  1653. if (!hasValue) {
  1654. rst = 0;
  1655. }
  1656. return rst;
  1657. }
  1658. function ext_getCalcProperty(templateIDs, calcItemKey, calcItemKeyVal, calcItemRstKey){
  1659. let rst = [], parentObj = this; //this should be "calc_program" object
  1660. let dtObj = parentObj["myOwnRawDataObj"];
  1661. let optimizeObj = {};
  1662. let private_getProperty = function (cId) {
  1663. let calcTplObj = optimizeObj["calc_program_" + cId];
  1664. if (!calcTplObj) {
  1665. let templates = (dtObj.data._doc)?dtObj.data._doc.templates:dtObj.data.templates;
  1666. for (let tpl of templates) {
  1667. if (cId === tpl.ID) {
  1668. optimizeObj["calc_program_" + cId] = tpl;
  1669. calcTplObj = tpl;
  1670. break;
  1671. }
  1672. }
  1673. }
  1674. if (calcTplObj) {
  1675. for (let calcItem of calcTplObj.calcItems) {
  1676. if (calcItem[calcItemKey] === calcItemKeyVal) {
  1677. if (calcItem[calcItemRstKey] !== undefined && calcItem[calcItemRstKey] !== null) {
  1678. rst.push(calcItem[calcItemRstKey]);
  1679. } else {
  1680. rst.push(calcItem['feeRate']); //业务特点,如果上述key没有值的话,直接取‘feeRate’的value,省的去改指标定义了
  1681. }
  1682. break;
  1683. }
  1684. }
  1685. }
  1686. };
  1687. if (templateIDs instanceof Array) {
  1688. for (let tplId of templateIDs) {
  1689. private_getProperty(tplId);
  1690. }
  1691. } else {
  1692. private_getProperty(templateIDs);
  1693. }
  1694. optimizeObj = null;
  1695. return rst;
  1696. }
  1697. function ext_getFeeRate(fee_Ids, feeName){
  1698. let rst = [], parentObj = this; //this should be "feeRate" object
  1699. let dtObj = parentObj["myOwnRawDataObj"];
  1700. let optimizeObj = {};
  1701. let private_getFeeRate = function (fId) {
  1702. let feeRateItemObj = optimizeObj["fee_rates_" + fId];
  1703. if (!feeRateItemObj) {
  1704. let rates = (dtObj.data._doc)?dtObj.data._doc.rates:dtObj.data.rates;
  1705. for (let feeItem of rates) {
  1706. if (fId === feeItem.ID) {
  1707. optimizeObj["fee_rates_" + fId] = feeItem;
  1708. feeRateItemObj = feeItem;
  1709. break;
  1710. }
  1711. }
  1712. }
  1713. if (feeRateItemObj) {
  1714. //rst.push(feeRateItemObj.rate);
  1715. rst.push(feeRateItemObj[feeName]);
  1716. } else {
  1717. rst.push(0);
  1718. }
  1719. };
  1720. if (fee_Ids instanceof Array) {
  1721. for (let fId of fee_Ids) {
  1722. private_getFeeRate(fId);
  1723. }
  1724. } else {
  1725. private_getFeeRate(fee_Ids);
  1726. }
  1727. optimizeObj = null;
  1728. return rst;
  1729. }
  1730. function ext_getArrayValues(itemKey) {
  1731. let rst = [], parentObj = this;
  1732. let dtObj = parentObj["myOwnRawDataObj"];
  1733. let keysArr = itemKey.split(".");
  1734. for (let dataItem of getActDataArr(dtObj)) {
  1735. let itemArr = [];
  1736. if (keysArr.length <= 2) {
  1737. if (dataItem[keysArr[0]] instanceof Array) {
  1738. if (keysArr.length === 2) {
  1739. for (let item of dataItem[keysArr[0]]) {
  1740. itemArr.push(item[keysArr[1]]);
  1741. }
  1742. } else {
  1743. itemArr = itemArr.concat(dataItem[keysArr[0]]);
  1744. }
  1745. } else {
  1746. if (keysArr.length === 2) {
  1747. let subProperty = dataItem[keysArr[0]][keysArr[1]];
  1748. if (subProperty instanceof Array) {
  1749. itemArr = itemArr.concat(subProperty);
  1750. } else {
  1751. itemArr.push(subProperty);
  1752. }
  1753. } else {
  1754. itemArr.push(dataItem[keysArr[0]]);
  1755. }
  1756. }
  1757. }
  1758. rst.push(itemArr);
  1759. }
  1760. return rst;
  1761. }
  1762. function ext_getArrayItemByKey(arrayKey, itemKey, itemKeyValue, itemRstKey){
  1763. let rst = [], parentObj = this;
  1764. let dtObj = parentObj["myOwnRawDataObj"];
  1765. let private_getItemValue = function (arr, dtlItKV) {
  1766. for (let item of arr) {
  1767. if (item[itemKey] === dtlItKV) {
  1768. if (itemRstKey) {
  1769. rst.push(item[itemRstKey]);
  1770. } else {
  1771. rst.push(item);
  1772. }
  1773. break;
  1774. }
  1775. }
  1776. };
  1777. let arr = dtObj[arrayKey];
  1778. if (arr && arr instanceof Array) {
  1779. if (itemKeyValue instanceof Array) {
  1780. for (let dtlItemKeyVal of itemKeyValue) {
  1781. private_getItemValue(arr, dtlItemKeyVal);
  1782. }
  1783. } else {
  1784. private_getItemValue(arr, itemKeyValue);
  1785. }
  1786. }
  1787. }
  1788. function ext_getBlank(dftVal) {
  1789. let rst = [], parentObj = this;
  1790. let dtObj = parentObj["myOwnRawDataObj"];
  1791. if (dtObj) {
  1792. let dtData = getActDataArr(dtObj);
  1793. for (let i = 0; i < dtData.length; i++) {
  1794. if (dftVal !== null && dftVal !== undefined) {
  1795. rst.push(dftVal)
  1796. } else rst.push('');
  1797. }
  1798. }
  1799. return rst;
  1800. }
  1801. function ext_getPropertyByFlag(flagVal, rstKey, dftValIfEmpty) {
  1802. let rst = [], parentObj = this;
  1803. let dtObj = parentObj["myOwnRawDataObj"];
  1804. if (flagVal && rstKey && dtObj) {
  1805. let isArr = (flagVal instanceof Array);
  1806. for (let dItem of getActDataArr(dtObj)) {
  1807. let doc = (dItem._doc)?dItem._doc:dItem;
  1808. if (doc.hasOwnProperty("flags")) {
  1809. let bFlag = false;
  1810. for (let flagItem of doc.flags) {
  1811. if (isArr) {
  1812. bFlag = (flagVal.indexOf(flagItem.flag) >= 0);
  1813. } else {
  1814. if (flagItem.flag === flagVal) {
  1815. bFlag = true;
  1816. }
  1817. }
  1818. if (bFlag) break;
  1819. }
  1820. if (bFlag) {
  1821. let keys = rstKey.split(".");
  1822. if (keys[0] === "fees") {
  1823. rst.push(pri_getFee(doc, "common", keys[1]));
  1824. } else {
  1825. //其他,比如名称什么
  1826. }
  1827. break;
  1828. }
  1829. }
  1830. }
  1831. }
  1832. if (rst.length === 0 && dftValIfEmpty !== null) {
  1833. rst.push(dftValIfEmpty);
  1834. }
  1835. return rst;
  1836. }
  1837. function ext_getPropertyByForeignId(foreignIdVal, adHocIdKey, propKey, dftValIfNotFound) {
  1838. let rst = [], parentObj = this;
  1839. let IdKey = (adHocIdKey)?adHocIdKey:"ID";
  1840. let dtObj = parentObj["myOwnRawDataObj"];
  1841. let splitPKey = propKey.split(".");
  1842. if (foreignIdVal !== null && foreignIdVal !== undefined) {
  1843. let isFound = false;
  1844. if (foreignIdVal instanceof Array) {
  1845. for (let idVal of foreignIdVal) {
  1846. isFound = false;
  1847. let dataArr = getActDataArr(dtObj);
  1848. for (let i = 0; i < dataArr.length; i++) {
  1849. let item = (dataArr[i]._doc)?dataArr[i]._doc:dataArr[i];
  1850. if (item[IdKey] === idVal) {
  1851. if (splitPKey.length > 1) {
  1852. let rstP = null;
  1853. for (let i = 0; i < splitPKey.length; i++) {
  1854. if (i === 0) {
  1855. rstP = item[splitPKey[i]];
  1856. } else {
  1857. if (splitPKey[i].indexOf("[") === 0 && splitPKey[i].indexOf("]") === (splitPKey[i].length - 1)) {
  1858. //考虑数组情况^_^!!!
  1859. } else {
  1860. //
  1861. }
  1862. rstP = rstP[splitPKey[i]];
  1863. }
  1864. }
  1865. rst.push(rstP);
  1866. } else {
  1867. rst.push(item[propKey]);
  1868. }
  1869. isFound = true;
  1870. break;
  1871. }
  1872. }
  1873. if (!isFound) {
  1874. rst.push(dftValIfNotFound);
  1875. }
  1876. }
  1877. } else {
  1878. for (let item of getActDataArr(dtObj)) {
  1879. if (item[IdKey] === foreignIdVal) {
  1880. rst.push(item[propKey]);
  1881. isFound = true;
  1882. break;
  1883. }
  1884. }
  1885. if (!isFound) {
  1886. rst.push(dftValIfNotFound);
  1887. }
  1888. }
  1889. }
  1890. return rst;
  1891. }
  1892. function getActDataArr(dtObj, adhocKey) {
  1893. let rst = null;
  1894. if (dtObj) {
  1895. rst = dtObj.data;
  1896. if (dtObj.moduleName === "projectGLJ") {
  1897. if (adhocKey) {
  1898. // rst = dtObj.data[adhocKey];
  1899. let props = adhocKey.split(',');
  1900. let nextData = dtObj.data[props[0]];
  1901. if (nextData._doc) {
  1902. nextData = nextData._doc;
  1903. }
  1904. for (let idx = 1; idx < props.length; idx++) {
  1905. nextData = nextData[props[idx]];
  1906. if (nextData._doc) {
  1907. nextData = nextData._doc;
  1908. }
  1909. }
  1910. if (nextData instanceof Array) {
  1911. rst = nextData;
  1912. } else {
  1913. rst = [];
  1914. rst.push(nextData);
  1915. }
  1916. } else {
  1917. rst = dtObj.data.gljList;
  1918. }
  1919. }
  1920. if (dtObj.moduleName === "calc_program") {
  1921. rst = dtObj.data.templates;
  1922. }
  1923. }
  1924. return rst;
  1925. }
  1926. function replaceActDataArr(dtObj, newArr) {
  1927. if (dtObj.moduleName === "projectGLJ") {
  1928. delete dtObj.data.gljList;
  1929. dtObj.data.gljList = newArr;
  1930. } else {
  1931. delete dtObj.data;
  1932. dtObj.data = newArr;
  1933. }
  1934. }
  1935. module.exports = Rpt_Data_Extractor;