rpt_yanghu_data_util.js 82 KB

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