gcl_gather.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. 'use strict';
  2. /**
  3. *
  4. * 清单汇总
  5. *
  6. * @author Mai
  7. * @date
  8. * @version
  9. */
  10. const mergeChar = ';';
  11. const Ledger = require('./ledger');
  12. const gclGatherModel = class {
  13. /**
  14. * 构造函数
  15. *
  16. * @param {Object} ctx - egg 全局变量
  17. */
  18. constructor(ctx) {
  19. this.ctx = ctx;
  20. this._ = ctx.helper._;
  21. // mainData
  22. this.billsTree = new Ledger.billsTree(this.ctx, {
  23. id: 'ledger_id',
  24. pid: 'ledger_pid',
  25. order: 'order',
  26. level: 'level',
  27. rootId: -1,
  28. keys: ['id', 'tender_id', 'ledger_id'],
  29. });
  30. this.pos = new Ledger.pos({
  31. id: 'id', ledgerId: 'lid', order: 'order'
  32. });
  33. }
  34. /**
  35. * 根据node新增工程量清单
  36. *
  37. * @param {Object}} node
  38. * @returns {Object}
  39. */
  40. newGclNode(node) {
  41. const gcl = {
  42. id: this.gclList.length + 1,
  43. b_code: node.b_code,
  44. name: node.name,
  45. unit: node.unit,
  46. unit_price: node.unit_price,
  47. leafXmjs: [],
  48. };
  49. this.gclList.push(gcl);
  50. return gcl;
  51. }
  52. /**
  53. * 获取node对应的工程量清单
  54. *
  55. * @param {Object} node
  56. * @returns {Object}
  57. */
  58. getGclNode(node) {
  59. const helper = this.ctx.helper;
  60. const gcl = this.gclList.find(function (g) {
  61. return g.b_code === node.b_code &&
  62. (g.name || node.name ? g.name === node.name : true) &&
  63. (g.unit || node.unit ? g.unit === node.unit : true) &&
  64. helper.checkZero(helper.sub(g.unit_price, node.unit_price));
  65. });
  66. if (gcl) {
  67. return gcl;
  68. } else {
  69. return this.newGclNode(node);
  70. }
  71. }
  72. /**
  73. * 检查 text 是否是Peg
  74. * e.g. K123+000(true) Kab+123(false) K123.234+234(false) K12+324.234(true)
  75. *
  76. * @param text
  77. * @returns {*}
  78. * @constructor
  79. */
  80. CheckPeg(text) {
  81. const pegReg = /[a-zA-Z]*[kK][0-9]+[++][0-9]{3}([.][0-9]+)?/;
  82. return pegReg.test(text);
  83. }
  84. /**
  85. * 基于node向上查找桩号节点(特别的,对于路基工程等,桩号节点应该在计量单元中)
  86. *
  87. * @param {Object} node - 清单树节点
  88. */
  89. getPegNode(node) {
  90. if (node) {
  91. if (this.CheckPeg(node.name)) {
  92. return node;
  93. } else {
  94. const parent = this.billsTree.getParent(node);
  95. return parent ? this.getPegNode(parent) : null;
  96. }
  97. }
  98. }
  99. /**
  100. * 获取节点的第N层父节点
  101. *
  102. * @param node - 节点(检索起点)
  103. * @param level - 第N层
  104. * @returns {*}
  105. */
  106. getNodeByLevel(node, level) {
  107. let cur = node;
  108. while (cur && cur.level > level) {
  109. cur = this.billsTree.getParent(cur);
  110. }
  111. return cur;
  112. }
  113. /**
  114. * 获取 单位工程
  115. *
  116. * @param xmj - 计量单元(最底层项目节)
  117. * @returns {string}
  118. */
  119. getDwgc(peg, xmj) {
  120. if (peg) {
  121. return peg.name;
  122. } else {
  123. const node = this.getNodeByLevel(xmj, 2);
  124. return node ? node.name : '';
  125. }
  126. }
  127. /**
  128. * 获取 分部工程
  129. *
  130. * @param peg - 桩号节点
  131. * @param xmj - 计量单元(最底层项目节)
  132. * @returns {string}
  133. */
  134. getFbgc(peg, xmj) {
  135. if (peg && peg.id !== xmj.id) {
  136. const node = this.getNodeByLevel(xmj, peg.level + 1);
  137. return node ? node.name : '';
  138. } else {
  139. const node = this.getNodeByLevel(xmj, 3);
  140. return node ? node.name : '';
  141. }
  142. }
  143. /**
  144. * 获取 分项工程
  145. *
  146. * @param peg - 桩号节点
  147. * @param xmj - 计量单元(最底层项目节)
  148. * @returns {string}
  149. */
  150. getFxgc (peg, xmj) {
  151. if (!peg) {
  152. const node = this.getNodeByLevel(xmj, 4);
  153. return node ? node.name : '';
  154. } else if (peg.id === xmj.id) {
  155. if (xmj.level > 4) {
  156. let value = '';
  157. for (let level = 4; level < xmj.level; level++) {
  158. const node = this.getNodeByLevel(xmj, level);
  159. value = value === '' ? node.name : value + mergeChar + node.name;
  160. }
  161. return value;
  162. } else {
  163. return '';
  164. }
  165. } else {
  166. if (peg.level + 2 < xmj.level) {
  167. let value = '';
  168. for (let level = peg.level + 2; level < xmj.level; level++) {
  169. const node = this.getNodeByLevel(xmj, level);
  170. value = value === '' ? node.name : value + mergeChar + node.name;
  171. }
  172. return value;
  173. } else {
  174. return '';
  175. }
  176. }
  177. }
  178. /**
  179. * 生成缓存数据(缓存仅为了不用每次都运算分部工程等)
  180. *
  181. * @param {Object}} leafXmj - 清单树节点
  182. * @returns {Object} 最底层项目节缓存数据
  183. */
  184. newCacheLeafXmj(leafXmj) {
  185. const peg = this.getPegNode(leafXmj);
  186. const cacheLX = {
  187. id: leafXmj.id,
  188. code: leafXmj.code,
  189. jldy: leafXmj.name,
  190. fbgc: this.getFbgc(peg, leafXmj),
  191. fxgc: this.getFxgc(peg, leafXmj),
  192. dwgc: this.getDwgc(peg, leafXmj),
  193. drawing_code: leafXmj.drawing_code,
  194. };
  195. this.leafXmjs.push(cacheLX);
  196. return cacheLX;
  197. }
  198. /**
  199. * 获取缓存数据(有缓存则直接读取,无则生成缓存)
  200. *
  201. * @param {Object} leafXmj - 最底层项目节
  202. * @returns {Object} 最底层项目缓存数据
  203. */
  204. getCacheLeafXmj(leafXmj) {
  205. const cacheLX = this.leafXmjs.find(lx => { return lx.id === leafXmj.id; });
  206. if (!cacheLX) {
  207. return this.newCacheLeafXmj(leafXmj);
  208. } else {
  209. return cacheLX;
  210. }
  211. }
  212. /**
  213. * 汇总工程量清单数据
  214. *
  215. * @param {Object} node 最底层工程量清单树节点
  216. * @param {*} leafXmj node所属的最底层项目节
  217. */
  218. loadGatherGclNode(node, leafXmj) {
  219. const helper = this.ctx.helper;
  220. const gcl = this.getGclNode(node);
  221. for (const prop in node) {
  222. if (prop === 'quantity' || prop === 'total_price' || prop.indexOf('qty') >= 0 || prop.indexOf('tp') >= 0) {
  223. gcl[prop] = this.ctx.helper.add(gcl[prop], node[prop]);
  224. }
  225. }
  226. const cacheLeafXmj = this.getCacheLeafXmj(leafXmj);
  227. const posRange = this.pos.getLedgerPos(node.id);
  228. const loadLeafXmj = function (detail, calcSource) {
  229. const dx = helper._.assign({}, cacheLeafXmj);
  230. dx.gcl_id = gcl.id;
  231. dx.org_gcl_id = node.id;
  232. if (detail.name !== node.name) {
  233. dx.bwmx = detail.name;
  234. dx.mx_id = detail.id;
  235. }
  236. if (detail.drawing_code) {
  237. dx.drawing_code = detail.drawing_code;
  238. }
  239. for (const prop in calcSource) {
  240. if (prop === 'quantity' || prop.indexOf('qty') > 0) dx[prop] = calcSource[prop];
  241. }
  242. gcl.leafXmjs.push(dx);
  243. };
  244. if (posRange && posRange.length > 0) {
  245. for (const pr of posRange) {
  246. loadLeafXmj(pr, pr);
  247. }
  248. } else {
  249. loadLeafXmj(leafXmj, node);
  250. }
  251. }
  252. /**
  253. * 递归生成工程量清单汇总数据
  254. *
  255. * @param {Array<Object>} nodes 清单子节点
  256. * @param {Object} leafXmj 最底层项目节
  257. */
  258. recursiveGatherGclData(nodes, leafXmj) {
  259. for (const node of nodes) {
  260. if (node.b_code) {
  261. if (node.children.length > 0) {
  262. this.recursiveGatherGclData(node.children, leafXmj);
  263. } else {
  264. this.loadGatherGclNode(node, leafXmj);
  265. }
  266. } else if (node.children.length > 0) {
  267. this.recursiveGatherGclData(node.children, node);
  268. }
  269. }
  270. }
  271. gatherDealBillsData(deal) {
  272. if (deal && deal.length > 0) {
  273. for (const node of deal) {
  274. node.b_code = node.code;
  275. const gcl = this.getGclNode(node);
  276. if (!node.quantity || !node.unit_price) continue;
  277. gcl.deal_bills_qty = node.quantity;
  278. gcl.deal_bills_tp = node.total_price;
  279. }
  280. }
  281. }
  282. convertResultData() {
  283. this.leafXmjs = [];
  284. for (const gcl of this.gclList) {
  285. if (gcl.leafXmjs.length === 0) return;
  286. for (const lx of gcl.leafXmjs) {
  287. this.leafXmjs.push(lx);
  288. }
  289. }
  290. }
  291. /**
  292. * 汇总
  293. *
  294. * @param {Array<Object>} bills 清单数据
  295. * @param {Array<Object>} pos 计量单元数据
  296. */
  297. gather(bills, pos, deal) {
  298. const helper = this.ctx.helper;
  299. this.billsTree.loadDatas(bills);
  300. this.pos.loadDatas(pos);
  301. this.gclList = [];
  302. this.leafXmjs = [];
  303. this.recursiveGatherGclData(this.billsTree.children, null);
  304. this.gatherDealBillsData(deal);
  305. this.gclList.sort(function (a, b) {
  306. return helper.compareCode(a.b_code, b.b_code);
  307. });
  308. this.convertResultData();
  309. return [this.gclList, this.leafXmjs];
  310. }
  311. gatherObj(bills, pos, deal) {
  312. const helper = this.ctx.helper;
  313. this.billsTree = bills;
  314. this.pos = pos;
  315. this.gclList = [];
  316. this.leafXmjs = [];
  317. this.recursiveGatherGclData(this.billsTree.children, null);
  318. this.gatherDealBillsData(deal);
  319. this.gclList.sort(function (a, b) {
  320. return helper.compareCode(a.b_code, b.b_code);
  321. });
  322. this.convertResultData();
  323. return [this.gclList, this.leafXmjs];
  324. }
  325. };
  326. const gclCompareGatherModal = class {
  327. /**
  328. * 构造函数
  329. *
  330. * @param {Object} ctx - egg 全局变量
  331. */
  332. constructor(ctx) {
  333. this.ctx = ctx;
  334. this._ = ctx.helper._;
  335. this.defaultSetting = {
  336. tree: {
  337. id: 'ledger_id',
  338. pid: 'ledger_pid',
  339. order: 'order',
  340. level: 'level',
  341. rootId: -1,
  342. isLeaf: 'is_leaf',
  343. keys: ['id', 'tender_id', 'ledger_id'],
  344. stageId: 'id',
  345. },
  346. pos: { id: 'id', ledgerId: 'lid' },
  347. billsFields: ['quantity', 'total_price'],
  348. posFields: ['quantity'],
  349. chapterFields: ['total_price'],
  350. };
  351. this.leafXmjs = [];
  352. this.gsTree = null;
  353. this.gsPos = null;
  354. }
  355. _getCalcChapter(chapter, option) {
  356. this.gclChapter = [];
  357. this.otherChapter = [];
  358. this.gclChapterFilter = [];
  359. let serialNo = 1;
  360. for (const c of chapter) {
  361. const cc = { code: c.code, name: c.name, cType: 1 };
  362. cc.serialNo = serialNo++;
  363. cc.filter = '^[^0-9]*([0-9]{0,2}-)?' + c.code.substr(0, c.code.length - 2) + '[0-9]{2}(-|$)';
  364. this.gclChapter.push(cc);
  365. }
  366. this.gclChapter.push({ name: '未计入章节清单合计', cType: 21, serialNo: serialNo+1 });
  367. this.otherChapter.hj = { name: '合计(C=A+B+Z)', cType: 41, serialNo: serialNo+5, deal_bills_tp: option.zlj.deal_bills_tp };
  368. this.gclChapterFilter.push({node_type: option.jrg.value});
  369. this.gclChapterFilter.push({field: 'name', part: option.jrg.text});
  370. const zlChapter = {
  371. name: '暂列金额(Z)', cType: 32, serialNo: serialNo+4,
  372. deal_bills_tp: option.zlj.deal_bills_tp, match: [], matchPath: []
  373. };
  374. zlChapter.match.push({node_type: option.zlj.value});
  375. zlChapter.match.push({field: 'name', part: option.zlj.text});
  376. this.otherChapter.zlj = zlChapter;
  377. this.otherChapter.qd = { name: '清单小计(A)', cType: 11, serialNo: serialNo+2 };
  378. this.otherChapter.fqd = { name: '非清单项费用(B)', cType: 31, serialNo: serialNo+3 };
  379. }
  380. init (chapter, option) {
  381. this.gclList = [];
  382. this._getCalcChapter(chapter, option);
  383. }
  384. newGclNode(node) {
  385. const gcl = {
  386. b_code: node.b_code,
  387. name: node.name,
  388. unit: node.unit,
  389. unit_price: node.unit_price,
  390. leafXmjs: [],
  391. };
  392. this.gclList.push(gcl);
  393. return gcl;
  394. }
  395. getGclNode(node) {
  396. const helper = this.ctx.helper;
  397. const gcl = this.gclList.find(function (g) {
  398. return g.b_code === node.b_code &&
  399. (g.name || node.name ? g.name === node.name : true) &&
  400. (g.unit || node.unit ? g.unit === node.unit : true) &&
  401. helper.checkZero(helper.sub(g.unit_price, node.unit_price));
  402. });
  403. if (gcl) {
  404. return gcl
  405. } else {
  406. return this.newGclNode(node);
  407. }
  408. }
  409. gatherfields(obj, src, fields, prefix = '') {
  410. if (obj && src) {
  411. for (const f of fields) {
  412. obj[prefix + f] = this.ctx.helper.add(obj[prefix + f], src[f]);
  413. }
  414. }
  415. }
  416. CheckPeg(text) {
  417. const pegReg = /[a-zA-Z]*[kK][0-9]+[++][0-9]{3}([.][0-9]+)?/;
  418. return pegReg.test(text);
  419. }
  420. getPegNode (node) {
  421. if (node) {
  422. if (this.CheckPeg(node.name)) {
  423. return node;
  424. } else {
  425. const parent = this.gsTree.getParent(node);
  426. return parent ? this.getPegNode(parent) : null;
  427. }
  428. }
  429. }
  430. getPegNode (node) {
  431. if (node) {
  432. if (this.CheckPeg(node.name)) {
  433. return node;
  434. } else {
  435. const parent = this.gsTree.getParent(node);
  436. return parent ? this.getPegNode(parent) : null;
  437. }
  438. }
  439. }
  440. getNodeByLevel(node, level) {
  441. let cur = node;
  442. while (cur && cur.level > level) {
  443. cur = this.gsTree.getParent(cur);
  444. }
  445. return cur;
  446. }
  447. getDwgc(peg, xmj) {
  448. if (peg) {
  449. return peg.name;
  450. } else {
  451. const node = this.getNodeByLevel(xmj, 2);
  452. return node ? node.name : '';
  453. }
  454. }
  455. getFbgc(peg, xmj) {
  456. if (peg && peg.id !== xmj.id) {
  457. const node = this.getNodeByLevel(xmj, peg.level + 1);
  458. return node ? node.name : '';
  459. } else {
  460. const node = this.getNodeByLevel(xmj, 3);
  461. return node ? node.name : '';
  462. }
  463. }
  464. getFxgc(peg, xmj) {
  465. if (!peg) {
  466. const node = this.getNodeByLevel(xmj, 4);
  467. return node ? node.name : '';
  468. } else if (peg.id === xmj.id) {
  469. if (xmj.level > 4) {
  470. let value = '';
  471. for (let level = 4; level < xmj.level; level++) {
  472. const node = this.getNodeByLevel(xmj, level);
  473. value = value === '' ? node.name : value + mergeChar + node.name;
  474. }
  475. return value;
  476. } else {
  477. return '';
  478. }
  479. } else {
  480. if (peg.level + 2 < xmj.level) {
  481. let value = '';
  482. for (let level = peg.level + 2; level < xmj.level; level++) {
  483. const node = this.getNodeByLevel(xmj, level);
  484. value = value === '' ? node.name : value + mergeChar + node.name;
  485. }
  486. return value;
  487. } else {
  488. return '';
  489. }
  490. }
  491. }
  492. newCacheLeafXmj(leafXmj) {
  493. const peg = this.getPegNode(leafXmj);
  494. const cacheLX = {
  495. id: leafXmj.id,
  496. code: leafXmj.code,
  497. jldy: leafXmj.name,
  498. fbgc: this.getFbgc(peg, leafXmj),
  499. fxgc: this.getFxgc(peg, leafXmj),
  500. dwgc: this.getDwgc(peg, leafXmj),
  501. drawing_code: leafXmj.drawing_code,
  502. };
  503. this.leafXmjs.push(cacheLX);
  504. return cacheLX;
  505. }
  506. getCacheLeafXmj(leafXmj) {
  507. const cacheLX = this.leafXmjs.find(function (lx) {
  508. return lx.id === leafXmj.id;
  509. });
  510. if (!cacheLX) {
  511. return this.newCacheLeafXmj(leafXmj);
  512. } else {
  513. return cacheLX;
  514. }
  515. }
  516. loadGatherGclNode(node, leafXmj, gsPos) {
  517. const gcl = this.getGclNode(node);
  518. this.gatherfields(gcl, node, this.ledgerSetting.billsFields, this.ledgerSetting.prefix);
  519. const cacheLeafXmj = this.getCacheLeafXmj(leafXmj);
  520. const posRange = gsPos.getLedgerPos(node.id);
  521. const detail = posRange && posRange.length > 0 ? posRange : [node];
  522. for (const d of detail) {
  523. const lx = gcl.leafXmjs.find(x => {return x.id === leafXmj.id && (x.mx_id === d.id || x.gcl_id === d.id)});
  524. if (lx) {
  525. this.gatherfields(lx, d, this.ledgerSetting.posFields, this.ledgerSetting.prefix);
  526. } else {
  527. const dx = this._.assign({}, cacheLeafXmj);
  528. this.gatherfields(dx, d, this.ledgerSetting.posFields, this.ledgerSetting.prefix);
  529. dx.gcl_id = node.id;
  530. if (d.name !== node.name) {
  531. dx.bwmx = d.name;
  532. dx.mx_id = d.id;
  533. }
  534. if (d.drawing_code) {
  535. dx.drawing_code = d.drawing_code;
  536. }
  537. gcl.leafXmjs.push(dx);
  538. }
  539. }
  540. }
  541. recursiveGatherGclData(nodes, leafXmj, gsPos) {
  542. for (const node of nodes) {
  543. if (node.b_code) {
  544. if (node.children.length > 0) {
  545. this.recursiveGatherGclData(node.children, leafXmj, gsPos);
  546. } else {
  547. this.loadGatherGclNode(node, leafXmj, gsPos);
  548. }
  549. } else if (node.children.length > 0) {
  550. this.recursiveGatherGclData(node.children, node, gsPos);
  551. }
  552. }
  553. }
  554. _getGclChapter(chapter, data) {
  555. for (const c of chapter) {
  556. if (c.filter) {
  557. const reg = new RegExp(c.filter);
  558. if (reg.test(data.b_code)) {
  559. return c;
  560. }
  561. } else {
  562. return c;
  563. }
  564. }
  565. }
  566. _checkFilter(d, filter) {
  567. for (const f of filter) {
  568. if (f.node_type && f.node_type === d.node_type) return true;
  569. if (f.field) {
  570. if (f.part && d[f.field] && d[f.field].indexOf(f.part) >= 0) return true;
  571. if (f.all && d[f.all] && d[f.all] === f.all) return true;
  572. }
  573. }
  574. return false;
  575. }
  576. _gatherChapter() {
  577. const chapterFilterPath = [];
  578. const checkFilterPath = function (data, filterPath) {
  579. for (const fp of filterPath) {
  580. if (data.full_path.indexOf(fp + '-') === 0 || data.full_path === fp) return true;
  581. }
  582. return false;
  583. };
  584. for (const d of this.gsTree.nodes) {
  585. if (this._checkFilter(d, this.gclChapterFilter)) chapterFilterPath.push(d.full_path);
  586. if (this._checkFilter(d, this.otherChapter.zlj.match)) this.otherChapter.zlj.matchPath.push(d.full_path);
  587. if (d.children && d.children.length > 0) continue;
  588. if (checkFilterPath(d, this.otherChapter.zlj.matchPath)) {
  589. this.gatherfields(this.otherChapter.zlj, d, this.ledgerSetting.chapterFields, this.ledgerSetting.prefix);
  590. this.gatherfields(this.otherChapter.hj, d, this.ledgerSetting.chapterFields, this.ledgerSetting.prefix);
  591. } else {
  592. this.gatherfields(this.otherChapter.hj, d, this.ledgerSetting.chapterFields, this.ledgerSetting.prefix);
  593. if (d.b_code) {
  594. this.gatherfields(this.otherChapter.qd, d, this.ledgerSetting.chapterFields, this.ledgerSetting.prefix);
  595. } else {
  596. this.gatherfields(this.otherChapter.fqd, d, this.ledgerSetting.chapterFields, this.ledgerSetting.prefix);
  597. }
  598. if (d.b_code) {
  599. const c = checkFilterPath(d, chapterFilterPath)
  600. ? this.gclChapter.find(x => { return x.cType === 21})
  601. : this._getGclChapter(this.gclChapter, d);
  602. this.gatherfields(c, d, this.ledgerSetting.chapterFields, this.ledgerSetting.prefix);
  603. }
  604. }
  605. }
  606. }
  607. gatherLedgerData (bills, pos, setting) {
  608. this.ledgerSetting = this._.assign(setting, this.defaultSetting);
  609. try {
  610. if (this.leafXmjs.length > 0) this.leafXmjs.length = 0;
  611. this.gsTree = new Ledger.billsTree(this.ctx, this.ledgerSetting.tree);
  612. this.gsTree.loadDatas(bills);
  613. this.gsPos = new Ledger.pos(this.ledgerSetting.pos);
  614. this.gsPos.loadDatas(pos);
  615. this.recursiveGatherGclData(this.gsTree.children, null, this.gsPos);
  616. this._gatherChapter();
  617. } catch(err) {
  618. this.ctx.log(err);
  619. }
  620. this.ledgerSetting = null;
  621. }
  622. gatherReviseLedgerData(bills, pos, setting, price, decimal) {
  623. this.ledgerSetting = this._.assign(setting, this.defaultSetting);
  624. try {
  625. if (this.leafXmjs.length > 0) this.leafXmjs.length = 0;
  626. this.gsTree = new Ledger.reviseTree(this.ctx, this.ledgerSetting.tree);
  627. this.gsTree.loadRevisePrice(price, decimal);
  628. this.gsTree.loadDatas(bills);
  629. this.gsPos = new Ledger.pos(this.ledgerSetting.pos);
  630. this.gsPos.loadDatas(pos);
  631. this.recursiveGatherGclData(this.gsTree.children, null, this.gsPos);
  632. this._gatherChapter();
  633. } catch(err) {
  634. this.ctx.log(err);
  635. }
  636. this.ledgerSetting = null;
  637. }
  638. chapterData () {
  639. return this.gclChapter.concat([this.otherChapter.qd, this.otherChapter.fqd, this.otherChapter.zlj, this.otherChapter.hj]);
  640. }
  641. };
  642. module.exports = {
  643. gclGather: gclGatherModel,
  644. gclCompareGather: gclCompareGatherModal,
  645. };