report_memory.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const _ = require('lodash');
  10. const StageIm = require('../lib/stage_im');
  11. const imType = require('../const/tender').imType;
  12. const audit = require('../const/audit');
  13. // const path = require('path');
  14. // const fs = require('fs');
  15. const stageImTz = 'mem_stage_im_tz';
  16. const stageImTzBills = 'mem_stage_im_tz_bills';
  17. const stageImZl = 'mem_stage_im_zl';
  18. const stageImVersion = '1.0';
  19. const Ledger = require('../lib/ledger');
  20. const curFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil'];
  21. const preFields = ['pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp'];
  22. const endFields = ['end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp'];
  23. const finalFields = ['final_tp', 'final_ratio'];
  24. const stageFields = curFields.concat(preFields, endFields, finalFields);
  25. const stageEndFields = preFields.concat(endFields, finalFields);
  26. const bglFields = ['qc_bgl_code'];
  27. module.exports = app => {
  28. class ReportMemory extends app.BaseService {
  29. /**
  30. * 构造函数
  31. *
  32. * @param {Object} ctx - egg全局context
  33. * @return {void}
  34. */
  35. constructor(ctx) {
  36. super(ctx);
  37. const self = this;
  38. this.tableName = 'report_memory';
  39. // 基础数据类
  40. // mainData
  41. this.billsTree = new Ledger.billsTree(this.ctx, {
  42. id: 'ledger_id',
  43. pid: 'ledger_pid',
  44. order: 'order',
  45. level: 'level',
  46. rootId: -1,
  47. keys: ['id', 'tender_id', 'ledger_id'],
  48. stageId: 'id',
  49. calcFields: ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp'],
  50. calc: function (node) {
  51. if (node.children && node.children.length === 0) {
  52. node.pre_gather_qty = self.ctx.helper.add(node.pre_contract_qty, node.pre_qc_qty);
  53. node.gather_qty = self.ctx.helper.add(node.contract_qty, node.qc_qty);
  54. node.end_contract_qty = self.ctx.helper.add(node.pre_contract_qty, node.contract_qty);
  55. node.end_qc_qty = self.ctx.helper.add(node.pre_qc_qty, node.qc_qty);
  56. node.end_gather_qty = self.ctx.helper.add(node.pre_gather_qty, node.gather_qty);
  57. }
  58. node.pre_gather_tp = self.ctx.helper.add(node.pre_contract_tp, node.pre_qc_tp);
  59. node.gather_tp = self.ctx.helper.add(node.contract_tp, node.qc_tp);
  60. node.end_contract_tp = self.ctx.helper.add(node.pre_contract_tp, node.contract_tp);
  61. node.end_qc_tp = self.ctx.helper.add(node.pre_qc_tp, node.qc_tp);
  62. node.end_gather_tp = self.ctx.helper.add(node.pre_gather_tp, node.gather_tp);
  63. node.final_tp = self.ctx.helper.add(node.total_price, node.end_qc_tp);
  64. node.final_ratio = self.ctx.helper.mul(self.ctx.helper.div(node.end_gather_tp, node.final_tp, 4), 100);
  65. }
  66. });
  67. this.pos = new Ledger.pos({
  68. id: 'id', ledgerId: 'lid',
  69. updateFields: ['contract_qty', 'qc_qty', 'postil'],
  70. calc: function (p) {
  71. p.pre_gather_qty = ctx.helper.add(p.pre_contract_qty, p.pre_qc_qty);
  72. p.gather_qty = ctx.helper.add(p.contract_qty, p.qc_qty);
  73. p.end_contract_qty = self.ctx.helper.add(p.pre_contract_qty, p.contract_qty);
  74. p.end_qc_qty = self.ctx.helper.add(p.pre_qc_qty, p.qc_qty);
  75. p.end_gather_qty = self.ctx.helper.add(p.pre_gather_qty, p.gather_qty);
  76. }
  77. });
  78. // 需要缓存的数据
  79. this.stageImData = null;
  80. }
  81. _checkFieldsExist(source, check) {
  82. for (const s of source) {
  83. if (check.indexOf(s)) return true;
  84. }
  85. return false;
  86. }
  87. // build-time: 162-384ms, redis-cache: 0-41ms, mysql + IO: 116-146ms
  88. // 一定程度上算是大Value缓存,数据多了以后:
  89. // 1. 达到redis内存阈值时,数据会swap到磁盘,此时将消耗IO时间
  90. // 2. redis单独服务器
  91. // 3. redis集群
  92. async _getReportMemoryCache(name, tid, sid, time, version = '') {
  93. // redis
  94. const cacheKey = name + '-t' + tid + (sid ? '-s' + sid : '') + (time ? '-' + time : '') + version;
  95. const data = await this.cache.get(cacheKey);
  96. if (data) {
  97. return eval(data);
  98. } else {
  99. return null;
  100. }
  101. // mysql + IO
  102. // const rm = await this.getDataByCondition({
  103. // tid: tid, sid: sid, name: name, time: time
  104. // });
  105. // if (rm && rm.file) {
  106. // const file = path.join(this.ctx.app.config.filePath, 'report', 'cache', rm.file);
  107. // if (fs.existsSync(file)) {
  108. // const data = await fs.readFileSync(file, 'utf8');
  109. // return eval(data);
  110. // } else {
  111. // return null;
  112. // }
  113. // }
  114. }
  115. async _setReportMemoryCache(name, tid, sid, time, data, version = '') {
  116. // redis
  117. const cacheKey = name + '-t' + tid + (sid ? '-s' + sid : '') + (time ? '-' + time : '') + version;
  118. this.cache.set(cacheKey, JSON.stringify(data), 'EX', this.ctx.app.config.cacheTime);
  119. // mysql + IO
  120. // const file = path.join('report', 'cache', 'rm' + (new Date()).getTime() + '.json');
  121. // await this.ctx.helper.saveBufferFile(JSON.stringify(data), path.join(this.ctx.app.config.filePath, file));
  122. // const rm = await this.getDataByCondition({
  123. // tid: tid, sid: sid, name: name, time: time
  124. // });
  125. // if (rm) {
  126. // await this.db.update(this.tableName, {id: rm.id, file: file});
  127. // } else {
  128. // await this.db.insert(this.tableName, {tid: tid, sid: sid, name: name, time: time, file: file});
  129. // }
  130. }
  131. async _generateStageIm(tid, sid, isTz = true) {
  132. if (isTz && this.ctx.stage.im_type !== imType.tz.value) {
  133. throw '您查看的报表跟设置不符,请查看“总量控制”的报表';
  134. } else if (!isTz && this.ctx.stage.im_type === imType.tz.value) {
  135. throw '您查看的报表跟设置不符,请查看“0号台账”的报表';
  136. }
  137. const stageIm = new StageIm(this.ctx);
  138. await stageIm.buildImData();
  139. this.stageImData.main = stageIm.ImData;
  140. if (isTz) {
  141. this.stageImData.bills = stageIm.ImBillsData;
  142. await this._setReportMemoryCache(stageImTz, tid, sid, this.ctx.stage.cacheTime, this.stageImData.main, stageImVersion);
  143. await this._setReportMemoryCache(stageImTzBills, tid, sid, this.ctx.stage.cacheTime, this.stageImData.bills, stageImVersion);
  144. } else {
  145. await this._setReportMemoryCache(stageImZl, tid, sid, this.ctx.stage.cacheTime, this.stageImData.main, stageImVersion);
  146. }
  147. }
  148. async getStageImTzNoReturn(tid, sid) {
  149. // 备注:单独拎出以下几行代码一个是为了提高效率(跟getStageImTzDataDirectlyByKey方法协作使用)
  150. // 二是如果出现并行查询(台账及台账清单)情况下,会出现干扰(已验证过),导致数据丢失
  151. if (!this.stageImData) {
  152. this.stageImData = {};
  153. }
  154. try {
  155. await this._generateStageIm(tid, sid);
  156. } catch (err) {
  157. this.stageImData.main = [];
  158. this.stageImData.bills = [];
  159. }
  160. }
  161. getStageImTzDataDirectlyByKey(key) {
  162. let rst = [];
  163. if (key === 'mem_stage_im_tz') {
  164. rst = this.stageImData.main;
  165. } else {
  166. rst = this.stageImData.bills;
  167. }
  168. return rst;
  169. }
  170. async getStageImTzData(tid, sid, fields) {
  171. await this.ctx.service.tender.checkTender(tid);
  172. await this.ctx.service.stage.checkStage(sid);
  173. const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
  174. if (cache) {
  175. // console.log('cache');
  176. return cache;
  177. }
  178. // console.log('build');
  179. if (!this.stageImData) {
  180. this.stageImData = {};
  181. try {
  182. await this._generateStageIm(tid, sid);
  183. } catch (err) {
  184. if (err.statck) {
  185. this.ctx.logger.error(err);
  186. }
  187. this.stageImData.main = err.statck ? '数据错误' : err;
  188. this.stageImData.bills = this.stageImData.main;
  189. }
  190. }
  191. return this.stageImData.main;
  192. }
  193. async getStageImTzBillsData(tid, sid, fields) {
  194. await this.ctx.service.tender.checkTender(tid);
  195. await this.ctx.service.stage.checkStage(sid);
  196. const cache = await this._getReportMemoryCache('mem_stage_im_tz_bills', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
  197. if (cache) return cache;
  198. if (!this.stageImData) {
  199. this.stageImData = {};
  200. try {
  201. await this._generateStageIm(tid, sid);
  202. } catch (err) {
  203. if (err.statck) {
  204. this.ctx.logger.error(err);
  205. }
  206. this.stageImData.main = err.statck ? '数据错误' : err;
  207. this.stageImData.bills = this.stageImData.main;
  208. }
  209. }
  210. return this.stageImData.bills;
  211. }
  212. async getStageImZlData(tid, sid, fields) {
  213. await this.ctx.service.tender.checkTender(tid);
  214. await this.ctx.service.stage.checkStage(sid);
  215. const cache = await this._getReportMemoryCache('mem_stage_im_zl', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
  216. if (cache) return cache;
  217. this.stageImData = {};
  218. try {
  219. await this._generateStageIm(tid, sid, false);
  220. } catch (err) {
  221. if (err.statck) {
  222. this.ctx.logger.error(err);
  223. }
  224. this.stageImData.main = err.statck ? '数据错误' : err;
  225. }
  226. return this.stageImData.main;
  227. }
  228. async getMonthProgress(tid, fields) {
  229. const helper = this.ctx.helper;
  230. await this.ctx.service.tender.checkTender(tid);
  231. const tender = this.ctx.tender;
  232. const stages = await this.ctx.service.stage.getValidStages(tender.id);
  233. const lastStage = stages.length > 0 ? stages[0] : null;
  234. if (lastStage) {
  235. await this.ctx.service.stage.checkStageGatherData(lastStage);
  236. tender.gather_tp = helper.add(lastStage.contract_tp, lastStage.qc_tp);
  237. tender.end_contract_tp = helper.add(lastStage.contract_tp, lastStage.pre_contract_tp);
  238. tender.end_qc_tp = helper.add(lastStage.qc_tp, lastStage.pre_qc_tp);
  239. tender.end_gather_tp = helper.add(tender.end_contract_tp, tender.end_qc_tp);
  240. tender.pre_gather_tp = helper.add(lastStage.pre_contract_tp, lastStage.pre_qc_tp);
  241. tender.yf_tp = lastStage.yf_tp;
  242. tender.qc_ratio = helper.mul(helper.div(tender.end_qc_tp, tender.info.deal_param.contractPrice, 2), 100);
  243. tender.sum = helper.add(tender.total_price, tender.end_qc_tp);
  244. tender.pre_ratio = helper.mul(helper.div(tender.pre_gather_tp, tender.sum, 2), 100);
  245. tender.cur_ratio = helper.mul(helper.div(tender.gather_tp, tender.sum, 2), 100);
  246. tender.other_tp = helper.sub(helper.sub(tender.sum, tender.pre_gather_tp), tender.gather_tp);
  247. tender.other_ratio = Math.max(0, 100 - tender.pre_ratio - tender.cur_ratio);
  248. }
  249. const monthProgress = [];
  250. for (const s of stages) {
  251. if (s.s_time) {
  252. let progress = monthProgress.find(function (x) {
  253. return x.month === s.s_time;
  254. });
  255. if (!progress) {
  256. progress = {month: s.s_time};
  257. monthProgress.push(progress);
  258. }
  259. progress.tp = helper.add(helper.add(progress.tp, s.contract_tp), s.qc_tp);
  260. }
  261. }
  262. monthProgress.sort(function (x, y) {
  263. return Date.parse(x.month) - Date.parse(y.month);
  264. });
  265. let sum = 0;
  266. for (const p of monthProgress) {
  267. p.ratio = helper.mul(helper.div(p.tp, tender.sum, 4), 100);
  268. sum = helper.add(sum, p.tp);
  269. p.end_tp = sum;
  270. p.end_ratio = helper.mul(helper.div(p.end_tp, tender.sum, 4), 100);
  271. }
  272. return monthProgress;
  273. }
  274. async _calcBillsBgl() {
  275. const helper = this.ctx.helper;
  276. const tender = this.ctx.tender;
  277. const stage = this.ctx.stage;
  278. const bglData = this.ctx.stage.readOnly
  279. ? await this.ctx.service.stageChange.getAuditorAllStageData(tender.id, stage.id, stage.curTimes, stage.curOrder)
  280. : await this.ctx.service.stageChange.getLastestAllStageData(tender.id, stage.id);
  281. for (const node of this.billsTree.nodes) {
  282. node.qc_bgl_code = '';
  283. if (node.children && node.children.length > 0) continue;
  284. const nodeBgl = helper._.filter(bglData, {lid: node.id});
  285. if (nodeBgl.length === 0) continue;
  286. helper._.pullAll(bglData, nodeBgl);
  287. const validBgl = helper._.filter(nodeBgl, function (x) {
  288. return !helper.checkZero(x.qty);
  289. });
  290. node.qc_bgl_code = helper._.uniq(helper._.map(validBgl, 'c_code')).join(';');
  291. }
  292. }
  293. async getStageBillsData(tid, sid, fields) {
  294. await this.ctx.service.tender.checkTender(tid);
  295. await this.ctx.service.stage.checkStage(sid);
  296. const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
  297. if (this._checkFieldsExist(fields, stageFields)) {
  298. if (this.ctx.stage.readOnly) {
  299. const curStage = await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id,
  300. this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder);
  301. this.ctx.helper.assignRelaData(billsData, [
  302. {data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid'}
  303. ]);
  304. } else {
  305. const curStage = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id);
  306. this.ctx.helper.assignRelaData(billsData, [
  307. {data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid'}
  308. ]);
  309. }
  310. }
  311. if (this._checkFieldsExist(fields, preFields)) {
  312. const preStage = this.ctx.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
  313. this.ctx.helper.assignRelaData(billsData, [
  314. {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
  315. ]);
  316. }
  317. this.billsTree.loadDatas(billsData);
  318. this.billsTree.calculateAll();
  319. if (this._checkFieldsExist(fields, bglFields)) {
  320. await this._calcBillsBgl();
  321. }
  322. return this.billsTree.getDatas([
  323. 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
  324. 'code', 'b_code', 'name', 'unit', 'unit_price',
  325. 'deal_qty', 'deal_tp',
  326. 'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
  327. 'dgn_qty1', 'dgn_qty2',
  328. 'drawing_code', 'memo', 'node_type', 'is_tp',
  329. 'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil',
  330. 'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
  331. 'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp',
  332. 'final_tp', 'final_ratio',
  333. 'qc_bgl_code',
  334. 'chapter',
  335. ]);
  336. }
  337. async getStagePosData(tid, sid, fields) {
  338. await this.ctx.service.tender.checkTender(tid);
  339. await this.ctx.service.stage.checkStage(sid);
  340. const posData = await this.ctx.service.pos.getAllDataByCondition({ where: {tid: this.ctx.tender.id }});
  341. if (this.ctx.stage.readOnly) {
  342. const curPosStage = await this.ctx.service.stagePos.getAuditorStageData2(this.ctx.tender.id,
  343. this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder);
  344. this.ctx.helper.assignRelaData(posData, [
  345. {data: curPosStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid'}
  346. ]);
  347. } else {
  348. const curPosStage = await this.ctx.service.stagePos.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
  349. this.ctx.helper.assignRelaData(posData, [
  350. {data: curPosStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid'}
  351. ]);
  352. }
  353. const prePosStage = this.ctx.stage.order > 1 ? await this.ctx.service.stagePosFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
  354. this.ctx.helper.assignRelaData(posData, [
  355. {data: prePosStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
  356. ]);
  357. this.pos.loadDatas(posData);
  358. this.pos.calculateAll();
  359. return this.pos.getDatas();
  360. }
  361. _getStageValidRole () {
  362. if (!this.ctx.stage) throw '期数据错误,请重试';
  363. const result = [{dataOrder: 0, flowOrder: 0, uid: this.ctx.stage.user_id}];
  364. for (const auditor of this.ctx.stage.auditors) {
  365. if (auditor.status === audit.stage.status.checked ||
  366. (auditor.status === audit.stage.status.checking && !this.ctx.stage.readOnly)) {
  367. const role = result.find(function (r) {
  368. return r.uid === auditor.aid;
  369. });
  370. if (role) {
  371. role.dataOrder = auditor.order;
  372. } else {
  373. result.push({
  374. dataOrder: auditor.order,
  375. flowOrder: result.length,
  376. uid: auditor.aid
  377. })
  378. }
  379. }
  380. }
  381. return result;
  382. };
  383. async getStageBillsCompareData(tid, sid, fields) {
  384. await this.ctx.service.tender.checkTender(tid);
  385. await this.ctx.service.stage.checkStage(sid);
  386. const stage = this.ctx.stage, helper = this.ctx.helper;
  387. const validRole = this._getStageValidRole();
  388. const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
  389. const allStageBills = await this.ctx.service.stageBills.getAllDataByCondition({where: {sid: sid}});
  390. const stageBillsIndex = {}, timesLen = 100;
  391. for (const role of validRole) {
  392. const stageBills = this.ctx.helper._.filter(allStageBills, function (x) {
  393. return x.times < stage.curTimes || (x.times === stage.curTimes && x.order <= role.dataOrder);
  394. });
  395. this.ctx.helper._.pullAll(allStageBills, stageBills);
  396. for (const sb of stageBills) {
  397. const key = 'sb-' + sb.lid;
  398. const sbi = stageBillsIndex[key];
  399. if (sbi) {
  400. if ((sbi.times * timesLen + sbi.order) < (sb.times * timesLen + sb.order)) stageBillsIndex[key] = sb;
  401. } else {
  402. stageBillsIndex[key] = sb;
  403. }
  404. }
  405. const filterStageBills = [];
  406. for (const prop in stageBillsIndex) {
  407. filterStageBills.push(stageBillsIndex[prop]);
  408. }
  409. this.ctx.helper.assignRelaData(billsData, [
  410. {data: filterStageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'r' + role.flowOrder + '_', relaId: 'lid'}
  411. ]);
  412. }
  413. if (this._checkFieldsExist(fields, preFields)) {
  414. const preStage = this.ctx.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
  415. this.ctx.helper.assignRelaData(billsData, [
  416. {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
  417. ]);
  418. }
  419. this.billsTree.loadDatas(billsData);
  420. this.billsTree.setting.calcFields = ['deal_tp', 'total_price', 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp'];
  421. for (const role of validRole) {
  422. const prefix = 'r' + role.flowOrder + '_';
  423. this.billsTree.setting.calcFields.push(prefix + 'contract_tp', prefix + 'qc_tp', prefix + 'gather_tp');
  424. }
  425. this.billsTree.calculateAll(function(node) {
  426. let prefix = '';
  427. if (node.children && node.children.length === 0) {
  428. node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
  429. for (const role of validRole) {
  430. prefix = 'r' + role.flowOrder + '_';
  431. node[prefix + 'gather_qty'] = helper.add(node[prefix + 'contract_qty'], node[prefix + 'qc_qty']);
  432. }
  433. }
  434. node.pre_gather_tp = helper.add(node.pre_contract_tp, node.pre_qc_tp);
  435. for (const role of validRole) {
  436. prefix = 'r' + role.flowOrder + '_';
  437. node[prefix + 'gather_tp'] = helper.add(node[prefix + 'contract_tp'], node[prefix + 'qc_tp']);
  438. }
  439. });
  440. return this.billsTree.getDefaultDatas();
  441. // return this.billsTree.getDatas([
  442. // 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf', //8
  443. // 'code', 'b_code', 'name', 'unit', 'unit_price', //5
  444. // 'deal_qty', 'deal_tp', 'quantity', 'total_price', 'dgn_qty1', 'dgn_qty2', //6
  445. // 'drawing_code', 'memo', 'node_type', 'is_tp', //4
  446. // 'r0_contract_qty', 'r0_contract_tp', 'r0_qc_qty', 'r0_qc_tp', 'r0_gather_qty', 'r0_gather_tp', //6
  447. // 'r1_contract_qty', 'r1_contract_tp', 'r1_qc_qty', 'r1_qc_tp', 'r1_gather_qty', 'r1_gather_tp',
  448. // 'r2_contract_qty', 'r2_contract_tp', 'r2_qc_qty', 'r2_qc_tp', 'r2_gather_qty', 'r2_gather_tp',
  449. // 'r3_contract_qty', 'r3_contract_tp', 'r3_qc_qty', 'r3_qc_tp', 'r3_gather_qty', 'r3_gather_tp',
  450. // 'r4_contract_qty', 'r4_contract_tp', 'r4_qc_qty', 'r4_qc_tp', 'r4_gather_qty', 'r4_gather_tp',
  451. // 'r5_contract_qty', 'r5_contract_tp', 'r5_qc_qty', 'r5_qc_tp', 'r5_gather_qty', 'r5_gather_tp',
  452. // 'r6_contract_qty', 'r6_contract_tp', 'r6_qc_qty', 'r6_qc_tp', 'r6_gather_qty', 'r6_gather_tp',
  453. // 'r7_contract_qty', 'r7_contract_tp', 'r7_qc_qty', 'r7_qc_tp', 'r7_gather_qty', 'r7_gather_tp',
  454. // 'r8_contract_qty', 'r8_contract_tp', 'r8_qc_qty', 'r8_qc_tp', 'r8_gather_qty', 'r8_gather_tp',
  455. // 'r9_contract_qty', 'r9_contract_tp', 'r9_qc_qty', 'r9_qc_tp', 'r9_gather_qty', 'r9_gather_tp',
  456. // 'r10_contract_qty', 'r10_contract_tp', 'r10_qc_qty', 'r10_qc_tp', 'r10_gather_qty', 'r10_gather_tp',
  457. // 'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
  458. // 'chapter', //1
  459. // ]);
  460. }
  461. }
  462. return ReportMemory;
  463. };