rpt_yanghu_data_util.js 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990
  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 dummyCode = " ", dummyPRJID = 10101010;
  845. for (let rationItem of getActDataArr(rationData)) {
  846. if (rationItem.type === 2 || rationItem.type === 3) {
  847. //2: 量材(人工/材料/机械/主材/设备) 3:材料(材料/主材/设备)
  848. let copyItem = {};
  849. copyItem.ID = rationItem.ID;
  850. copyItem.projectID = rationItem.projectID;
  851. copyItem.GLJID = rationItem.GLJID;
  852. copyItem.rationID = rationItem.ID;
  853. copyItem.rationItemQuantity = 1;
  854. copyItem.quantity = 1;
  855. // copyItem.specialType_quantity = rationItem.quantity;
  856. copyItem.name = rationItem.name;
  857. if (rationItem.code) {
  858. copyItem.code = rationItem.ID + "_" + rationItem.code;
  859. } else {
  860. copyItem.code = dummyCode;
  861. dummyCode = dummyCode + " ";
  862. }
  863. copyItem.original_code = rationItem.original_code;
  864. copyItem.unit = rationItem.unit;
  865. copyItem.specs = rationItem.specs;
  866. copyItem.shortName = rationItem.shortName;
  867. copyItem.billsItemID = rationItem.billsItemID;
  868. copyItem.type = rationItem.subType;
  869. if (rationItem.projectGLJID) {
  870. copyItem.projectGLJID = rationItem.projectGLJID;
  871. } else {
  872. //add dummy project GLJ
  873. let dummyPrjItem = {};
  874. copyItem.projectGLJID = dummyPRJID;
  875. dummyPrjItem.id = dummyPRJID;
  876. dummyPRJID++;
  877. dummyPrjItem.name = rationItem.name;
  878. dummyPrjItem.unit_price = {};
  879. dummyPrjItem.unit_price.base_price = 0;
  880. dummyPrjItem.unit_price.market_price = (rationItem["marketUnitFee"])?rationItem["marketUnitFee"]:0;
  881. dummyPrjItem.quantity = 1; //这里设置为1只是为了不被误过滤
  882. dummyPrjItem.is_evaluate = 0;
  883. prjGljData.data.gljList.push(dummyPrjItem);
  884. }
  885. rationGljData.data.push(copyItem);
  886. } else {
  887. //无
  888. }
  889. }
  890. // fsUtil.writeObjToFile(rationGljData.data, "D:/GitHome/temp/afterMoveGLJ.jsp");
  891. }
  892. }
  893. //有些项目工料机有组成物,有些表需要显示这些组成物,此函数把这些组成物抽出并归类到定额工料机下
  894. function moveRationComponentData(rationData, rawDataObj) {
  895. let rationGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION_GLJ);
  896. let prjGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.PROJECTGLJ);
  897. let newComponentItem = [];
  898. for (let rationGljItem of getActDataArr(rationGljData)) {
  899. for (let prjGljItem of prjGljData.data.gljList) {
  900. if (prjGljItem.id === rationGljItem.projectGLJID) {
  901. if (prjGljItem.ratio_data && prjGljItem.ratio_data.length > 0 && !gljUtil.isConcreteType(prjGljItem.type)) {
  902. //有组成物
  903. for (let comItem of prjGljItem.ratio_data) {
  904. let copyItem = {};
  905. copyItem.ID = comItem._id.toString();
  906. copyItem.projectID = rationGljItem.projectID;
  907. copyItem.rationID = rationGljItem.rationID;
  908. // copyItem.rationItemQuantity = rationGljItem.quantity;
  909. copyItem.quantity = parseFloat(rationGljItem.quantity) * parseFloat(comItem.consumption);
  910. copyItem.name = comItem.name;
  911. copyItem.code = comItem.code;
  912. copyItem.unit = comItem.unit;
  913. copyItem.specs = comItem.specs;
  914. // copyItem.shortName = comItem.shortName;
  915. copyItem.billsItemID = rationGljItem.billsItemID;
  916. copyItem.type = comItem.type;
  917. //其他属性,要根据工料机ID来查找
  918. for (let gljIdx = 0; gljIdx < prjGljData.data.gljList.length; gljIdx++) {
  919. if (prjGljData.data.gljList[gljIdx].code === comItem.code) {
  920. copyItem.projectGLJID = prjGljData.data.gljList[gljIdx].id;
  921. copyItem.original_code = prjGljData.data.gljList[gljIdx].original_code;
  922. copyItem.is_main_material = prjGljData.data.gljList[gljIdx].is_main_material;
  923. copyItem.is_adjust_price = prjGljData.data.gljList[gljIdx].is_adjust_price;
  924. copyItem.unit_price = {};
  925. copyItem.unit_price.base_price = prjGljData.data.gljList[gljIdx].unit_price.base_price;
  926. copyItem.unit_price.market_price = prjGljData.data.gljList[gljIdx].unit_price.market_price;
  927. break;
  928. }
  929. }
  930. newComponentItem.push(copyItem);
  931. }
  932. }
  933. break;
  934. }
  935. }
  936. }
  937. rationGljData.data = rationGljData.data.concat(newComponentItem);
  938. }
  939. function getDupGrpKeyVals(sourceData, segKeys) {
  940. let rst = [];
  941. function pushKeyVal(item) {
  942. let tr = {};
  943. for (let i = 0; i < segKeys.length; i++) {
  944. tr[segKeys[i]] = item[segKeys[i]];
  945. }
  946. rst.push(tr);
  947. }
  948. for (let idx = 0; idx < sourceData.length; idx++) {
  949. let itemRec = sourceData[idx];
  950. if (idx === 0) {
  951. pushKeyVal(itemRec);
  952. continue;
  953. }
  954. let hasDiff = false;
  955. for (let i = 0; i < segKeys.length; i++) {
  956. if (itemRec[segKeys[i]] !== sourceData[idx - 1][segKeys[i]]) {
  957. hasDiff = true;
  958. break;
  959. }
  960. }
  961. if (hasDiff) {
  962. pushKeyVal(itemRec);
  963. }
  964. }
  965. return rst;
  966. }
  967. function addDummyData(sourceData, addCfg) {
  968. let rstArr = [], tempRstArr = [];
  969. for (let item of getActDataArr(sourceData)) {
  970. if (item._doc) {
  971. tempRstArr.push(item._doc);
  972. } else {
  973. tempRstArr.push(item);
  974. }
  975. }
  976. for (let item of addCfg[JV.PROP_DUMMY_COLLECTION]) {
  977. let newRecStr = JSON.stringify(item[JV.PROP_DUMMY_VAL]), cacheGrpKeyRecs = null;
  978. if (item[JV.PROP_FREQUENCY] === "OncePerGrp") {
  979. if (!cacheGrpKeyRecs) {
  980. cacheGrpKeyRecs = {};
  981. }
  982. let cacheKey = "";
  983. for (let key of item[JV.PROP_GRP_KEYS]) {
  984. cacheKey += "_" + key;
  985. }
  986. if (!cacheGrpKeyRecs[cacheKey]) {
  987. cacheGrpKeyRecs[cacheKey] = getDupGrpKeyVals(tempRstArr, item[JV.PROP_GRP_KEYS]);
  988. }
  989. for (let kv of cacheGrpKeyRecs[cacheKey]) {
  990. let rec = JSON.parse(newRecStr);
  991. for (let key of item[JV.PROP_GRP_KEYS]) {
  992. rec[key] = kv[key];
  993. }
  994. rstArr.push(rec);
  995. }
  996. } else if (item[JV.PROP_FREQUENCY] === "Once") {
  997. rstArr.push(JSON.parse(newRecStr));
  998. }
  999. }
  1000. rstArr = rstArr.concat(tempRstArr);
  1001. replaceActDataArr(sourceData, rstArr);
  1002. }
  1003. function getGLJBizType2018(orgType, orgCode, orgName) {
  1004. let rst = orgType;
  1005. if (orgType === GLJ_TYPE.Labour) {
  1006. rst = 11;
  1007. if (orgCode === "000000") rst = 10;
  1008. } else if (orgType === GLJ_TYPE.Material || (orgType >= 200 && orgType < 300)) {
  1009. //材料
  1010. if (orgCode === "000000") {
  1011. rst = 200; //2.材料
  1012. } else if (orgCode === "000000_1") {
  1013. rst = 230; //(1) 计价材料
  1014. } else if (orgCode === "000000_2") {
  1015. rst = 240; //(2) 其他材料费
  1016. } else {
  1017. if (orgType === GLJ_TYPE.OTHER_MATERIAL) {
  1018. //其他材料
  1019. rst = 245;
  1020. } else {
  1021. //计价材料
  1022. rst = 235;
  1023. }
  1024. }
  1025. } else if (orgType === GLJ_TYPE.Machine || (orgType >= 300 && orgType < 400)) {
  1026. //机械
  1027. if (orgCode === "000000") {
  1028. rst = 300; //3.机械
  1029. } else if (orgCode === "000000_1") {
  1030. rst = 330; //(1) 机上人工
  1031. } else if (orgCode === "000000_2") {
  1032. rst = 340; //(2) 燃油动力费
  1033. } else if (orgCode === "000000_3") {
  1034. rst = 350; //(2) 施工机具摊销费
  1035. } else {
  1036. if (orgType === GLJ_TYPE.MACHINE_LABOUR) {
  1037. //机上人工
  1038. rst = 335;
  1039. } else if (orgType === GLJ_TYPE.FUEL_POWER_FEE) {
  1040. //燃油动力费
  1041. rst = 345;
  1042. } else if (oprMachines.indexOf(orgType) >= 0) {
  1043. //施工机具摊销费
  1044. rst = 355 + oprMachines.indexOf(orgType);
  1045. }
  1046. }
  1047. }
  1048. return rst;
  1049. }
  1050. function getGLJBizType(orgType, orgCode, orgName) {
  1051. let rst = orgType;
  1052. if (orgName.indexOf("其他材料费") >= 0) {
  1053. rst = 299;
  1054. } else if (orgType === GLJ_TYPE.Labour) {
  1055. rst = 11;
  1056. if (orgCode === "000000") rst = 10;
  1057. } else if (orgType === GLJ_TYPE.Main_Material || orgType === GLJ_TYPE.Equipment) {
  1058. //未计价材料(主材 + 设备)
  1059. rst = 30 + orgType;
  1060. } else if (orgType === GLJ_TYPE.Material || (orgType >= 200 && orgType < 300)) {
  1061. //材料
  1062. if (orgCode === "000000") {
  1063. rst = 20; //2.材料
  1064. } else if (orgCode === "000000_1") {
  1065. rst = 30; //(1) 未计价材料
  1066. } else if (orgCode === "000000_2") {
  1067. rst = 40; //(2) 辅助材料
  1068. } else if (orgCode === "000000_3") {
  1069. rst = 50; //(3) 其他材料费
  1070. } else {
  1071. rst = 45; //到这里就只有辅助材料没有预处理了
  1072. }
  1073. } else if (orgType === GLJ_TYPE.Machine || (orgType >= 300 && orgType < 400)) {
  1074. //机械
  1075. if (orgCode === "000000") {
  1076. rst = 300; //3.机械
  1077. } else if (orgType === GLJ_TYPE.Machine) {
  1078. rst = 300.5;
  1079. } else {
  1080. rst = orgType;
  1081. }
  1082. }
  1083. return rst;
  1084. }
  1085. function sortData(sourceData, sortCfg, prjData) {
  1086. let rst = getActDataArr(sourceData), tempRstArr = [];
  1087. let sortType = sortCfg[JV.PROP_SORT_TYPE];
  1088. let srcData = getActDataArr(sourceData);
  1089. for (let item of srcData) {
  1090. if (item._doc) {
  1091. tempRstArr.push(item._doc);
  1092. } else {
  1093. tempRstArr.push(item);
  1094. }
  1095. }
  1096. function private_normal_sort(destArr, sortKeys) {
  1097. destArr.sort(function(a, b){
  1098. let compRst = 0;
  1099. for (let comp of sortKeys) {
  1100. let reverse = (comp.order === 'ascend')?1:(-1);
  1101. //
  1102. if (a[comp.key] > b[comp.key]) {
  1103. compRst = reverse;
  1104. break;
  1105. } else if (a[comp.key] < b[comp.key]) {
  1106. compRst = -reverse;
  1107. break;
  1108. }
  1109. }
  1110. return compRst;
  1111. });
  1112. }
  1113. function private_parent_sort(parentArr, parentKeys, childArr, childKeys) {
  1114. let tmpRst = {}, rst = [];
  1115. for (let pItem of parentArr) {
  1116. let pKey = "key";
  1117. for (let key of parentKeys) {
  1118. pKey += "_" + pItem[key];
  1119. }
  1120. tmpRst[pKey] = [];
  1121. }
  1122. for (let cItem of childArr) {
  1123. let cKey = "key";
  1124. for (let key of childKeys) {
  1125. cKey += "_" + cItem[key];
  1126. }
  1127. if (tmpRst[cKey]) {
  1128. tmpRst[cKey].push(cItem);
  1129. } else {
  1130. //unknown child value! should be filtered!
  1131. }
  1132. }
  1133. // childArr.splice(0);
  1134. for (let pItem of parentArr) {
  1135. let pKey = "key";
  1136. for (let key of parentKeys) {
  1137. pKey += "_" + pItem[key];
  1138. }
  1139. rst.push(tmpRst[pKey]);
  1140. // for (let rItem of tmpRst[pKey]) {
  1141. // childArr.push(rItem);
  1142. // }
  1143. }
  1144. return rst;
  1145. }
  1146. switch (sortType) {
  1147. case "tree":
  1148. let addLevel = true;
  1149. rst = treeUtil.buildTreeNodeDirectly(tempRstArr, addLevel);
  1150. let newTopArr = [];
  1151. if ((sortCfg[JV.PROP_FILTER_TOP_BILLS_NODES] && sortCfg[JV.PROP_FILTER_TOP_BILLS_NODES].length > 0) ||
  1152. (sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES] && sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES].length > 0)) {
  1153. let local_check_bills = function(tItem) {
  1154. let chkDtl = false;
  1155. if (tItem.flags && tItem.flags.length > 0) {
  1156. for (let flagItem of tItem.flags) {
  1157. if (sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES].indexOf(flagItem.flag) >= 0) {
  1158. newTopArr.push(tItem);
  1159. chkDtl = true;
  1160. break;
  1161. }
  1162. }
  1163. }
  1164. if (!chkDtl && tItem.items && tItem.items.length > 0) {
  1165. for (let dtlItem of tItem.items) {
  1166. local_check_bills(dtlItem);
  1167. }
  1168. }
  1169. };
  1170. for (let topItem of rst) {
  1171. let chkTop = false;
  1172. if (topItem.flags && topItem.flags.length > 0) {
  1173. for (let flagItem of topItem.flags) {
  1174. if (sortCfg[JV.PROP_FILTER_TOP_BILLS_NODES].indexOf(flagItem.flag) >= 0) {
  1175. newTopArr.push(topItem);
  1176. chkTop = true;
  1177. break;
  1178. }
  1179. }
  1180. }
  1181. if (!chkTop && sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES] && sortCfg[JV.PROP_FILTER_OTHER_BILLS_NODES].length > 0) {
  1182. local_check_bills(topItem);
  1183. }
  1184. }
  1185. } else {
  1186. newTopArr = rst;
  1187. }
  1188. let destArr = [];
  1189. // fsUtil.writeObjToFile(newTopArr, "D:/GitHome/temp/sortedAndFlattedRstBefore.jsp");
  1190. treeUtil.getFlatArray(newTopArr, destArr, true);
  1191. // console.log(destArr);
  1192. replaceActDataArr(sourceData, destArr);
  1193. // fsUtil.writeObjToFile(sourceData.data, "D:/GitHome/temp/sortedAndFlattedRst.jsp");
  1194. break;
  1195. case "normal":
  1196. private_normal_sort(tempRstArr, sortCfg[JV.PROP_SORT_KEYS]);
  1197. replaceActDataArr(sourceData, tempRstArr);
  1198. // fsUtil.writeObjToFile(sourceData.data, "D:/GitHome/temp/normalSortedRst.jsp");
  1199. break;
  1200. case "accord_to_parent":
  1201. let pcKey = sortCfg[JV.PROP_PARENT_CHILD_SORT_KEY];
  1202. let parentSrcData = getModuleDataByKey(prjData, pcKey[JV.PROP_PARENT_DATA_KEY]);
  1203. if (parentSrcData) {
  1204. let tempParentArr = [];
  1205. for (let item of getActDataArr(parentSrcData)) {
  1206. if (item._doc) {
  1207. tempParentArr.push(item._doc);
  1208. } else {
  1209. tempParentArr.push(item);
  1210. }
  1211. }
  1212. let sortedRstArr = private_parent_sort(tempParentArr, pcKey[JV.PROP_PARENT_SORT_KEYS], tempRstArr, pcKey[JV.PROP_CHILD_SORT_KEYS]);
  1213. if (sortCfg[JV.PROP_OTHER_SUB_SORT] && sortCfg[JV.PROP_OTHER_SUB_SORT].length > 0) {
  1214. for (let sort of sortCfg[JV.PROP_OTHER_SUB_SORT]) {
  1215. if (sort[JV.PROP_SORT_TYPE] === 'normal') {
  1216. for (let subArr of sortedRstArr) {
  1217. private_normal_sort(subArr, sort[JV.PROP_SORT_KEYS]);
  1218. }
  1219. } else if (sort[JV.PROP_SORT_TYPE] === 'self_define') {
  1220. for (let subArr of sortedRstArr) {
  1221. // console.log(subArr);
  1222. let selfDefFunc = null;
  1223. eval('selfDefFunc = ' + sort[JV.PROP_SORT_TYPE_SELF_DEFINE_LOGIC]);
  1224. subArr.sort(selfDefFunc);
  1225. // console.log(subArr);
  1226. }
  1227. }
  1228. }
  1229. }
  1230. tempRstArr.splice(0);
  1231. for (let item of sortedRstArr) {
  1232. for (let subItem of item) {
  1233. tempRstArr.push(subItem);
  1234. }
  1235. }
  1236. }
  1237. replaceActDataArr(sourceData, tempRstArr);
  1238. break;
  1239. case "self_define":
  1240. if (sortCfg[JV.PROP_SORT_TYPE_SELF_DEFINE_LOGIC]) {
  1241. let selfDefFuncA = null;
  1242. eval('selfDefFuncA = ' + sortCfg[JV.PROP_SORT_TYPE_SELF_DEFINE_LOGIC]);
  1243. if (selfDefFuncA !== null) {
  1244. tempRstArr.sort(selfDefFuncA);
  1245. } else {
  1246. console.log('sorting function is null!!!');
  1247. }
  1248. }
  1249. replaceActDataArr(sourceData, tempRstArr);
  1250. break;
  1251. default:
  1252. //
  1253. }
  1254. return rst;
  1255. }
  1256. function setupMainFunc(obj, prop, ownRawObj) {
  1257. obj[prop] = {};
  1258. obj[prop]["myOwnRawDataObj"] = ownRawObj;
  1259. obj[prop].getProperty = ext_mainGetPropety;
  1260. obj[prop].getFee = ext_mainGetFee;
  1261. }
  1262. function setupFeeRate(feeRateData){
  1263. let cacheObj = {}, topArr = [], rstArr = [], id_pre = 'ID_';
  1264. const rateProperties = [];
  1265. for (let rate of feeRateData.rates) {
  1266. cacheObj[id_pre + rate._doc.ID] = {"obj": rate._doc, "items": []};
  1267. // cacheObj[id_pre + rate.ID].items = [];
  1268. if (rate._doc.ParentID === null || rate._doc.ParentID === undefined) {
  1269. topArr.push(cacheObj[id_pre + rate._doc.ID]);
  1270. }
  1271. }
  1272. for (let rate of feeRateData.rates) {
  1273. if (rate._doc.ParentID && cacheObj[id_pre + rate._doc.ParentID]) {
  1274. cacheObj[id_pre + rate._doc.ParentID].items.push(cacheObj[id_pre + rate._doc.ID]);
  1275. if (rateProperties.indexOf(rate._doc.name) < 0) {
  1276. rateProperties.push(rate._doc.name);
  1277. }
  1278. }
  1279. }
  1280. let pri_func_set_property_rate = function (orgRateItem, rstRateItem) {
  1281. rstRateItem[orgRateItem.obj.name] = orgRateItem.obj.rate;
  1282. for (let subOrgRateItem of orgRateItem.items) {
  1283. pri_func_set_property_rate(subOrgRateItem, rstRateItem);
  1284. }
  1285. };
  1286. for (let topRate of topArr) {
  1287. let rstItem = {"name": topRate.obj.name, "ID": topRate.obj.ID};
  1288. for (let property of rateProperties) {
  1289. rstItem[property] = 0;
  1290. }
  1291. for (let dtlRateItem of topRate.items) {
  1292. pri_func_set_property_rate(dtlRateItem, rstItem);
  1293. }
  1294. rstArr.push(rstItem);
  1295. }
  1296. return rstArr;
  1297. }
  1298. function setupFunc(obj, prop, ownRawObj) {
  1299. obj[prop] = {};
  1300. obj[prop]["myOwnRawDataObj"] = ownRawObj;
  1301. obj[prop]["myOwnOrgRawDataObj"] = ownRawObj.data;
  1302. obj[prop].getProperty = ext_getProperty;
  1303. obj[prop].getGljFreightProperty = ext_getGljFreightProperty;
  1304. obj[prop].getAdHocGljProperty = ext_getAdHocGljProperty;
  1305. obj[prop].getGljOriginalProperty = ext_getGljOriginalProperty;
  1306. obj[prop].getPropertyByRefId = ext_getPropertyByRefId;
  1307. obj[prop].getFee = ext_getFee;
  1308. obj[prop].getPropertyByForeignId = ext_getPropertyByForeignId;
  1309. obj[prop].getArrayValues = ext_getArrayValues;
  1310. obj[prop].getArrayItemByKey = ext_getArrayItemByKey;
  1311. obj[prop].getPropertyByFlag = ext_getPropertyByFlag;
  1312. obj[prop].getSubRateProperty = ext_getRateProperty;
  1313. obj[prop].getRateProperty = ext_getRateProperty;
  1314. obj[prop].getBlank = ext_getBlank;
  1315. obj[prop].getRatioDataProperty = ext_getRatioDataProperty;
  1316. obj[prop].getRatioDataParentProperty = ext_getRatioDataParentProperty;
  1317. obj[prop].getRatioDataPriceMapProperty = ext_getRatioDataPriceMapProperty;
  1318. if (prop === projectConst.CALC_PROGRAM) obj[prop].getCalcProperty = ext_getCalcProperty;
  1319. if (prop === projectConst.FEERATE) obj[prop].getFeeRate = ext_getFeeRate;
  1320. }
  1321. function assembleFields(fieldList, rstDataArr, $PROJECT) {
  1322. if (fieldList) {
  1323. for (let field of fieldList) {
  1324. shielded_exec_env($PROJECT, field, rstDataArr);
  1325. if ("Precision" in field) {
  1326. if (field["Precision"]["type"] === "fixed") {
  1327. let vrst = eval(field["Precision"]["fixedMapExpression"]);
  1328. if (vrst && vrst.length === 1) {
  1329. field.fixedPrecisionNum = vrst[0];
  1330. vrst.splice(0,1);
  1331. }
  1332. } else if (field["Precision"]["type"] === "flexible") {
  1333. let vrst = eval(field["Precision"]["flexibleMapExpression"]);
  1334. if (vrst && vrst.length === 1) {
  1335. field.flexiblePrecisionRefObj =vrst[0];
  1336. vrst.splice(0,1);
  1337. }
  1338. }
  1339. }
  1340. }
  1341. }
  1342. }
  1343. function shielded_exec_env($PROJECT, $ME, rptDataItemObj) {
  1344. if ($ME[JV.PROP_FIELD_EXP_MAP]) {
  1345. rptDataItemObj.push(eval($ME[JV.PROP_FIELD_EXP_MAP]));
  1346. }
  1347. }
  1348. function getActPropertyVal(firstPropKey, secPropKey, orgObj) {
  1349. let rst = null;
  1350. if (orgObj[firstPropKey]) {
  1351. rst = orgObj[firstPropKey];
  1352. } else if (orgObj[secPropKey]){
  1353. rst = orgObj[secPropKey];
  1354. }
  1355. return rst;
  1356. }
  1357. function getDeepProperty(propKey, orgObj, destArr) {
  1358. let keys = propKey.split(".");
  1359. let dftPropKey = "key", dftPropVal = "value", secDftPropVal = "items";
  1360. let parent = orgObj, lastVal = null;
  1361. for (let key of keys) {
  1362. if (parent instanceof Array) {
  1363. for (let item of parent) {
  1364. if (item[dftPropKey] === key) {
  1365. lastVal = getActPropertyVal(dftPropVal, secDftPropVal, item);
  1366. break;
  1367. }
  1368. }
  1369. } else {
  1370. lastVal = null;
  1371. if (parent[key] !== undefined) {
  1372. lastVal = parent[key];
  1373. } else if (parent[secDftPropVal]){
  1374. for (let item of parent[secDftPropVal]) {
  1375. if (item[dftPropKey] === key) {
  1376. // lastVal = item[dftPropVal];
  1377. lastVal = getActPropertyVal(dftPropVal, secDftPropVal, item);
  1378. break;
  1379. }
  1380. }
  1381. }
  1382. }
  1383. parent = lastVal;
  1384. if (parent === null) break;
  1385. }
  1386. if (destArr && destArr instanceof Array) {
  1387. destArr.push(lastVal);
  1388. }
  1389. }
  1390. function ext_mainGetPropety(propKey) {
  1391. let rst = [], parentObj = this;
  1392. let dtObj = parentObj["myOwnRawDataObj"];
  1393. if (propKey && dtObj) {
  1394. if (dtObj.hasOwnProperty("property")) {
  1395. if (!dtObj["property"][propKey] && dtObj[propKey]) {
  1396. rst.push(dtObj[propKey]);
  1397. } else {
  1398. getDeepProperty(propKey, dtObj["property"], rst);
  1399. }
  1400. } else {
  1401. // rst.push(dtObj[propKey]);
  1402. getDeepProperty(propKey, dtObj, rst);
  1403. }
  1404. }
  1405. return rst;
  1406. }
  1407. function ext_getRateProperty(propKey) {
  1408. let rst = [], parentObj = this;
  1409. let dtObj = parentObj["myOwnRawDataObj"];
  1410. if (propKey && dtObj) {
  1411. if (propKey instanceof Array) {
  1412. for (let pKey of propKey) {
  1413. for (let rate of dtObj.data._doc.rates) {
  1414. if (rate[pKey]) {
  1415. rst.push(rate[pKey]);
  1416. } else {
  1417. rst.push(0);
  1418. }
  1419. }
  1420. }
  1421. } else {
  1422. for (let rate of dtObj.data._doc.rates) {
  1423. rst.push(rate[propKey]);
  1424. }
  1425. }
  1426. }
  1427. return rst;
  1428. }
  1429. function ext_getRatioDataProperty(propKey) {
  1430. //获取工料机的组成物属性
  1431. let rst = [], parentObj = this;
  1432. let dtObj = parentObj["myOwnRawDataObj"];
  1433. if (propKey && dtObj) {
  1434. for (let dItem of getActDataArr(dtObj)) {
  1435. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1436. for (let ratioItem of doc.ratio_data) {
  1437. rst.push(ratioItem[propKey]);
  1438. }
  1439. }
  1440. }
  1441. return rst;
  1442. }
  1443. function pri_push_property(propKey, doc, rst) {
  1444. if (propKey instanceof Array) {
  1445. //备注:这里的key数组表示取value的优先级
  1446. for (let pi = 0; pi < propKey.length; pi++) {
  1447. if (doc.hasOwnProperty("property")) {
  1448. if (doc["property"].hasOwnProperty(propKey[pi])) {
  1449. rst.push(doc["property"][propKey[pi]]);
  1450. break;
  1451. }
  1452. } else if (doc.hasOwnProperty(propKey[pi])) {
  1453. rst.push(doc[propKey[pi]]);
  1454. break;
  1455. } else {
  1456. let lenBefore = rst.length;
  1457. getDeepProperty(propKey[pi], doc, rst);
  1458. if (rst.length === (lenBefore + 1)) {
  1459. if (rst[lenBefore] !== null && rst[lenBefore] !== undefined && rst[lenBefore] !== "") {
  1460. break;
  1461. } else {
  1462. rst.splice(-1, 1); //删除末尾一条数据,给后面留空间
  1463. }
  1464. }
  1465. }
  1466. if (pi === propKey.length - 1) rst.push('');
  1467. }
  1468. } else {
  1469. if (doc.hasOwnProperty("property") && doc["property"].hasOwnProperty(propKey)) {
  1470. rst.push(doc["property"][propKey]);
  1471. } else if (doc.hasOwnProperty(propKey)) {
  1472. rst.push(doc[propKey]);
  1473. } else {
  1474. getDeepProperty(propKey, doc, rst);
  1475. }
  1476. }
  1477. }
  1478. function ext_getRatioDataParentProperty(propKey) {
  1479. //获取组成物的父项属性
  1480. let rst = [], parentObj = this;
  1481. let dtObj = parentObj["myOwnRawDataObj"];
  1482. if (propKey && dtObj) {
  1483. for (let dItem of getActDataArr(dtObj)) {
  1484. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1485. for (let ratioItem of doc.ratio_data) {
  1486. pri_push_property(propKey, doc, rst);
  1487. }
  1488. }
  1489. }
  1490. return rst;
  1491. }
  1492. function ext_getRatioDataPriceMapProperty(propKey) {
  1493. //获取组成物的单价映射属性
  1494. let rst = [], parentObj = this;
  1495. let dtObj = parentObj["myOwnRawDataObj"];
  1496. if (propKey && dtObj) {
  1497. let unitPriceMap = dtObj.data.unitPriceMap;
  1498. let upmDoc = (unitPriceMap._doc === null || unitPriceMap._doc === undefined)?unitPriceMap:unitPriceMap._doc;
  1499. for (let dItem of getActDataArr(dtObj)) {
  1500. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1501. for (let ratioItem of doc.ratio_data) {
  1502. let connectionKeys = [];
  1503. connectionKeys.push(ratioItem.code);
  1504. connectionKeys.push(ratioItem.name);
  1505. connectionKeys.push((ratioItem.specs === "")?"null":ratioItem.specs);
  1506. connectionKeys.push(ratioItem.unit);
  1507. connectionKeys.push(ratioItem.type);
  1508. connectionKeys.join("|-|");
  1509. let strPK = connectionKeys.join("|-|");
  1510. let dtlDoc = (upmDoc[strPK]._doc)?upmDoc[strPK]._doc:upmDoc[strPK];
  1511. rst.push(dtlDoc[propKey]);
  1512. }
  1513. }
  1514. }
  1515. return rst;
  1516. }
  1517. function ext_getAdHocGljProperty(adhocDataKey, propKey) {
  1518. let rst = [], parentObj = this;
  1519. let dtObj = parentObj["myOwnRawDataObj"];
  1520. if (propKey && dtObj) {
  1521. for (let dItem of getActDataArr(dtObj, adhocDataKey)) {
  1522. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1523. pri_push_property(propKey, doc, rst);
  1524. }
  1525. }
  1526. return rst;
  1527. }
  1528. function ext_getGljFreightProperty(propKey) {
  1529. let rst = [], parentObj = this;
  1530. let dtObj = parentObj["myOwnRawDataObj"];
  1531. if (propKey && dtObj) {
  1532. for (let dItem of getActDataArr(dtObj, "freightList")) {
  1533. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1534. pri_push_property(propKey, doc, rst);
  1535. }
  1536. }
  1537. return rst;
  1538. }
  1539. function ext_getGljOriginalProperty(propKey) {
  1540. let rst = [], parentObj = this;
  1541. let dtObj = parentObj["myOwnRawDataObj"];
  1542. if (propKey && dtObj) {
  1543. for (let dItem of getActDataArr(dtObj, "originalList")) {
  1544. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1545. pri_push_property(propKey, doc, rst);
  1546. }
  1547. }
  1548. return rst;
  1549. }
  1550. function ext_getProperty(propKey) {
  1551. let rst = [], parentObj = this;
  1552. let dtObj = parentObj["myOwnRawDataObj"];
  1553. if (propKey && dtObj) {
  1554. for (let dItem of getActDataArr(dtObj)) {
  1555. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1556. pri_push_property(propKey, doc, rst);
  1557. }
  1558. }
  1559. return rst;
  1560. }
  1561. function ext_getPropertyByRefId(baseKey, refIDKey, propertyKey){
  1562. let rst = [], parentObj = this;
  1563. let dtObj = parentObj["myOwnRawDataObj"];
  1564. let orgDtObj = parentObj["myOwnOrgRawDataObj"];
  1565. if (baseKey && refIDKey && propertyKey && dtObj) {
  1566. for (let dItem of getActDataArr(dtObj)) {
  1567. let doc = (dItem._doc === null || dItem._doc === undefined)?dItem:dItem._doc;
  1568. let tmpRst = doc[baseKey];
  1569. if (typeof tmpRst === "string" && tmpRst[0] === "@") {
  1570. let refKey = tmpRst.slice(1);
  1571. let hasGetRef = false;
  1572. for (let orgDItem of orgDtObj) {
  1573. let oDoc = (orgDItem._doc === null || orgDItem._doc === undefined)?orgDItem:orgDItem._doc;
  1574. if (oDoc[refIDKey] === refKey) {
  1575. rst.push(oDoc[propertyKey]);
  1576. hasGetRef = true;
  1577. break;
  1578. }
  1579. }
  1580. if (!hasGetRef) {
  1581. rst.push(tmpRst);
  1582. }
  1583. } else {
  1584. rst.push(tmpRst);
  1585. }
  1586. }
  1587. }
  1588. return rst;
  1589. }
  1590. function ext_mainGetFee(feeKey, dtlFeeKey) {
  1591. let rst = [];
  1592. let parentObj = this;
  1593. let dtObj = parentObj["myOwnRawDataObj"];
  1594. if ((dtObj) && (feeKey)) {
  1595. if (dtObj.hasOwnProperty("fees")) {
  1596. for (let fee of dtObj["fees"]) {
  1597. if (fee["fieldName"] === feeKey) {
  1598. if (dtlFeeKey) {
  1599. rst.push(fee[dtlFeeKey]);
  1600. } else {
  1601. rst.push(fee["unitFee"]);
  1602. }
  1603. break;
  1604. }
  1605. }
  1606. } else if (dtObj.hasOwnProperty(feeKey)) {
  1607. rst.push(dtObj[feeKey]);
  1608. } else {
  1609. //
  1610. }
  1611. }
  1612. return rst;
  1613. }
  1614. function ext_getFee(feeKey, dtlFeeKey) {
  1615. let rst = [], parentObj = this;
  1616. let dtObj = parentObj["myOwnRawDataObj"];
  1617. if (feeKey && dtObj) {
  1618. for (let dItem of getActDataArr(dtObj)) {
  1619. rst.push(pri_getFee(dItem, feeKey, dtlFeeKey));
  1620. }
  1621. }
  1622. for (let i = 0; i < rst.length; i++) {
  1623. rst[i] = parseFloat(rst[i]);
  1624. }
  1625. return rst;
  1626. }
  1627. function pri_getFee(dItem, feeKey, dtlFeeKey) {
  1628. let rst = 0;
  1629. let hasValue = false;
  1630. if (dItem["fees"]) {
  1631. for (let fee of dItem["fees"]) {
  1632. if (fee["fieldName"] === feeKey) {
  1633. if (dtlFeeKey) {
  1634. rst = fee[dtlFeeKey];
  1635. } else {
  1636. rst = fee["unitFee"];
  1637. }
  1638. hasValue = true;
  1639. break;
  1640. }
  1641. }
  1642. } else if (dItem[feeKey]) {
  1643. hasValue = true;
  1644. rst = parseFloat(dItem[feeKey]);
  1645. } else {
  1646. hasValue = true;
  1647. rst = 0;
  1648. }
  1649. if (!hasValue) {
  1650. rst = 0;
  1651. }
  1652. return rst;
  1653. }
  1654. function ext_getCalcProperty(templateIDs, calcItemKey, calcItemKeyVal, calcItemRstKey){
  1655. let rst = [], parentObj = this; //this should be "calc_program" object
  1656. let dtObj = parentObj["myOwnRawDataObj"];
  1657. let optimizeObj = {};
  1658. let private_getProperty = function (cId) {
  1659. let calcTplObj = optimizeObj["calc_program_" + cId];
  1660. if (!calcTplObj) {
  1661. let templates = (dtObj.data._doc)?dtObj.data._doc.templates:dtObj.data.templates;
  1662. for (let tpl of templates) {
  1663. if (cId === tpl.ID) {
  1664. optimizeObj["calc_program_" + cId] = tpl;
  1665. calcTplObj = tpl;
  1666. break;
  1667. }
  1668. }
  1669. }
  1670. if (calcTplObj) {
  1671. for (let calcItem of calcTplObj.calcItems) {
  1672. if (calcItem[calcItemKey] === calcItemKeyVal) {
  1673. if (calcItem[calcItemRstKey] !== undefined && calcItem[calcItemRstKey] !== null) {
  1674. rst.push(calcItem[calcItemRstKey]);
  1675. } else {
  1676. rst.push(calcItem['feeRate']); //业务特点,如果上述key没有值的话,直接取‘feeRate’的value,省的去改指标定义了
  1677. }
  1678. break;
  1679. }
  1680. }
  1681. }
  1682. };
  1683. if (templateIDs instanceof Array) {
  1684. for (let tplId of templateIDs) {
  1685. private_getProperty(tplId);
  1686. }
  1687. } else {
  1688. private_getProperty(templateIDs);
  1689. }
  1690. optimizeObj = null;
  1691. return rst;
  1692. }
  1693. function ext_getFeeRate(fee_Ids, feeName){
  1694. let rst = [], parentObj = this; //this should be "feeRate" object
  1695. let dtObj = parentObj["myOwnRawDataObj"];
  1696. let optimizeObj = {};
  1697. let private_getFeeRate = function (fId) {
  1698. let feeRateItemObj = optimizeObj["fee_rates_" + fId];
  1699. if (!feeRateItemObj) {
  1700. let rates = (dtObj.data._doc)?dtObj.data._doc.rates:dtObj.data.rates;
  1701. for (let feeItem of rates) {
  1702. if (fId === feeItem.ID) {
  1703. optimizeObj["fee_rates_" + fId] = feeItem;
  1704. feeRateItemObj = feeItem;
  1705. break;
  1706. }
  1707. }
  1708. }
  1709. if (feeRateItemObj) {
  1710. //rst.push(feeRateItemObj.rate);
  1711. rst.push(feeRateItemObj[feeName]);
  1712. } else {
  1713. rst.push(0);
  1714. }
  1715. };
  1716. if (fee_Ids instanceof Array) {
  1717. for (let fId of fee_Ids) {
  1718. private_getFeeRate(fId);
  1719. }
  1720. } else {
  1721. private_getFeeRate(fee_Ids);
  1722. }
  1723. optimizeObj = null;
  1724. return rst;
  1725. }
  1726. function ext_getArrayValues(itemKey) {
  1727. let rst = [], parentObj = this;
  1728. let dtObj = parentObj["myOwnRawDataObj"];
  1729. let keysArr = itemKey.split(".");
  1730. for (let dataItem of getActDataArr(dtObj)) {
  1731. let itemArr = [];
  1732. if (keysArr.length <= 2) {
  1733. if (dataItem[keysArr[0]] instanceof Array) {
  1734. if (keysArr.length === 2) {
  1735. for (let item of dataItem[keysArr[0]]) {
  1736. itemArr.push(item[keysArr[1]]);
  1737. }
  1738. } else {
  1739. itemArr = itemArr.concat(dataItem[keysArr[0]]);
  1740. }
  1741. } else {
  1742. if (keysArr.length === 2) {
  1743. let subProperty = dataItem[keysArr[0]][keysArr[1]];
  1744. if (subProperty instanceof Array) {
  1745. itemArr = itemArr.concat(subProperty);
  1746. } else {
  1747. itemArr.push(subProperty);
  1748. }
  1749. } else {
  1750. itemArr.push(dataItem[keysArr[0]]);
  1751. }
  1752. }
  1753. }
  1754. rst.push(itemArr);
  1755. }
  1756. return rst;
  1757. }
  1758. function ext_getArrayItemByKey(arrayKey, itemKey, itemKeyValue, itemRstKey){
  1759. let rst = [], parentObj = this;
  1760. let dtObj = parentObj["myOwnRawDataObj"];
  1761. let private_getItemValue = function (arr, dtlItKV) {
  1762. for (let item of arr) {
  1763. if (item[itemKey] === dtlItKV) {
  1764. if (itemRstKey) {
  1765. rst.push(item[itemRstKey]);
  1766. } else {
  1767. rst.push(item);
  1768. }
  1769. break;
  1770. }
  1771. }
  1772. };
  1773. let arr = dtObj[arrayKey];
  1774. if (arr && arr instanceof Array) {
  1775. if (itemKeyValue instanceof Array) {
  1776. for (let dtlItemKeyVal of itemKeyValue) {
  1777. private_getItemValue(arr, dtlItemKeyVal);
  1778. }
  1779. } else {
  1780. private_getItemValue(arr, itemKeyValue);
  1781. }
  1782. }
  1783. }
  1784. function ext_getBlank(dftVal) {
  1785. let rst = [], parentObj = this;
  1786. let dtObj = parentObj["myOwnRawDataObj"];
  1787. if (dtObj) {
  1788. let dtData = getActDataArr(dtObj);
  1789. for (let i = 0; i < dtData.length; i++) {
  1790. if (dftVal !== null && dftVal !== undefined) {
  1791. rst.push(dftVal)
  1792. } else rst.push('');
  1793. }
  1794. }
  1795. return rst;
  1796. }
  1797. function ext_getPropertyByFlag(flagVal, rstKey, dftValIfEmpty) {
  1798. let rst = [], parentObj = this;
  1799. let dtObj = parentObj["myOwnRawDataObj"];
  1800. if (flagVal && rstKey && dtObj) {
  1801. let isArr = (flagVal instanceof Array);
  1802. for (let dItem of getActDataArr(dtObj)) {
  1803. let doc = (dItem._doc)?dItem._doc:dItem;
  1804. if (doc.hasOwnProperty("flags")) {
  1805. let bFlag = false;
  1806. for (let flagItem of doc.flags) {
  1807. if (isArr) {
  1808. bFlag = (flagVal.indexOf(flagItem.flag) >= 0);
  1809. } else {
  1810. if (flagItem.flag === flagVal) {
  1811. bFlag = true;
  1812. }
  1813. }
  1814. if (bFlag) break;
  1815. }
  1816. if (bFlag) {
  1817. let keys = rstKey.split(".");
  1818. if (keys[0] === "fees") {
  1819. rst.push(pri_getFee(doc, "common", keys[1]));
  1820. } else {
  1821. //其他,比如名称什么
  1822. }
  1823. break;
  1824. }
  1825. }
  1826. }
  1827. }
  1828. if (rst.length === 0 && dftValIfEmpty !== null) {
  1829. rst.push(dftValIfEmpty);
  1830. }
  1831. return rst;
  1832. }
  1833. function ext_getPropertyByForeignId(foreignIdVal, adHocIdKey, propKey, dftValIfNotFound) {
  1834. let rst = [], parentObj = this;
  1835. let IdKey = (adHocIdKey)?adHocIdKey:"ID";
  1836. let dtObj = parentObj["myOwnRawDataObj"];
  1837. let splitPKey = propKey.split(".");
  1838. if (foreignIdVal !== null && foreignIdVal !== undefined) {
  1839. let isFound = false;
  1840. if (foreignIdVal instanceof Array) {
  1841. for (let idVal of foreignIdVal) {
  1842. isFound = false;
  1843. let dataArr = getActDataArr(dtObj);
  1844. for (let i = 0; i < dataArr.length; i++) {
  1845. let item = (dataArr[i]._doc)?dataArr[i]._doc:dataArr[i];
  1846. if (item[IdKey] === idVal) {
  1847. if (splitPKey.length > 1) {
  1848. let rstP = null;
  1849. for (let i = 0; i < splitPKey.length; i++) {
  1850. if (i === 0) {
  1851. rstP = item[splitPKey[i]];
  1852. } else {
  1853. if (splitPKey[i].indexOf("[") === 0 && splitPKey[i].indexOf("]") === (splitPKey[i].length - 1)) {
  1854. //考虑数组情况^_^!!!
  1855. } else {
  1856. //
  1857. }
  1858. rstP = rstP[splitPKey[i]];
  1859. }
  1860. }
  1861. rst.push(rstP);
  1862. } else {
  1863. rst.push(item[propKey]);
  1864. }
  1865. isFound = true;
  1866. break;
  1867. }
  1868. }
  1869. if (!isFound) {
  1870. rst.push(dftValIfNotFound);
  1871. }
  1872. }
  1873. } else {
  1874. for (let item of getActDataArr(dtObj)) {
  1875. if (item[IdKey] === foreignIdVal) {
  1876. rst.push(item[propKey]);
  1877. isFound = true;
  1878. break;
  1879. }
  1880. }
  1881. if (!isFound) {
  1882. rst.push(dftValIfNotFound);
  1883. }
  1884. }
  1885. }
  1886. return rst;
  1887. }
  1888. function getActDataArr(dtObj, adhocKey) {
  1889. let rst = null;
  1890. if (dtObj) {
  1891. rst = dtObj.data;
  1892. if (dtObj.moduleName === "projectGLJ") {
  1893. if (adhocKey) {
  1894. // rst = dtObj.data[adhocKey];
  1895. let props = adhocKey.split(',');
  1896. let nextData = dtObj.data[props[0]];
  1897. if (nextData._doc) {
  1898. nextData = nextData._doc;
  1899. }
  1900. for (let idx = 1; idx < props.length; idx++) {
  1901. nextData = nextData[props[idx]];
  1902. if (nextData._doc) {
  1903. nextData = nextData._doc;
  1904. }
  1905. }
  1906. if (nextData instanceof Array) {
  1907. rst = nextData;
  1908. } else {
  1909. rst = [];
  1910. rst.push(nextData);
  1911. }
  1912. } else {
  1913. rst = dtObj.data.gljList;
  1914. }
  1915. }
  1916. if (dtObj.moduleName === "calc_program") {
  1917. rst = dtObj.data.templates;
  1918. }
  1919. }
  1920. return rst;
  1921. }
  1922. function replaceActDataArr(dtObj, newArr) {
  1923. if (dtObj.moduleName === "projectGLJ") {
  1924. delete dtObj.data.gljList;
  1925. dtObj.data.gljList = newArr;
  1926. } else {
  1927. delete dtObj.data;
  1928. dtObj.data = newArr;
  1929. }
  1930. }
  1931. module.exports = Rpt_Data_Extractor;