rpt_data_analysis.test.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const mockData = {};
  11. const path = require('path');
  12. const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  13. describe('test/app/service/report_memory.test.js', () => {
  14. // 准备测试数据
  15. before(function* () {
  16. const ctx = app.mockContext();
  17. // 模拟登录session
  18. // const postData = {
  19. // account: 'fuqingqing',
  20. // project: 'P0505',
  21. // project_password: '123456',
  22. // };
  23. const postData = {
  24. account: '734406061@qq.com',
  25. project: 'T201711273363',
  26. project_password: 'mai654321',
  27. };
  28. ctx.session = {};
  29. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  30. assert(loginResult);
  31. mockData.session = ctx.session;
  32. });
  33. // 数据
  34. it('test changeSort', function* () {
  35. const ctx = app.mockContext(mockData);
  36. // test12 - 第6期
  37. const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
  38. const params = {
  39. tender_id: stage.tid,
  40. stage_id: stage.id,
  41. };
  42. const filters = ['change', 'change_audit_list'];
  43. const data = yield ctx.service.report.getReportData(params, filters);
  44. reportDataAnalysis.analysisObj.changeSort.fun(ctx, data);
  45. assert(data.change[0].code === 'test7-BG-001');
  46. assert(data.change[2].code === 'test7-BG-003');
  47. const changeCid = ctx.helper._.map(data.change, 'cid');
  48. const changeBillsCid = ctx.helper._.uniq(ctx.helper._.map(data.change_audit_list, 'cid'));
  49. assert(changeCid.length === changeBillsCid.length);
  50. changeCid.forEach(function (a, i) {
  51. assert(a === changeBillsCid[i]);
  52. });
  53. });
  54. it('test gatherGcl && sortGcl', function* () {
  55. const ctx = app.mockContext(mockData);
  56. // test12 - 第6期
  57. const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
  58. const params = {
  59. tender_id: stage.tid,
  60. stage_id: stage.id,
  61. };
  62. const filters = ['mem_stage_bills'];
  63. const data = yield ctx.service.report.getReportData(params, filters, {
  64. mem_stage_bills: [
  65. 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
  66. 'code', 'b_code', 'name', 'unit', 'unit_price',
  67. 'deal_qty', 'deal_tp',
  68. 'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
  69. 'dgn_qty1', 'dgn_qty2',
  70. 'drawing_code', 'memo', 'node_type', 'is_tp',
  71. 'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil',
  72. 'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
  73. 'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp',
  74. 'final_tp', 'final_ratio',
  75. 'qc_bgl_code',
  76. 'chapter',
  77. ]
  78. });
  79. assert(data.mem_stage_bills.length === 216);
  80. reportDataAnalysis.analysisObj.gatherGcl.fun(ctx, data, [
  81. {field: 'b_code', table: 'mem_stage_bills'},
  82. {field: 'name', table: 'mem_stage_bills'},
  83. {field: 'unit', table: 'mem_stage_bills'},
  84. {field: 'unit_price', table: 'mem_stage_bills'},
  85. {field: 'is_leaf', table: 'mem_stage_bills'},
  86. ]);
  87. assert(data.mem_stage_bills.length === 43);
  88. reportDataAnalysis.analysisObj.sortGcl.fun(ctx, data, [
  89. {field: 'b_code', table: 'mem_stage_bills'},
  90. ]);
  91. const codeIndex = ctx.helper._.map(data.mem_stage_bills, 'b_code');
  92. const codeIndex100 = ['103-1', '103-2', '103-3-a', '103-3-b', '103-4', '104-1'];
  93. const codeIndex200 = [
  94. '203-1-a', '203-1-b', '203-1-d', '204-1-b', '204-1-g-4', '204-1-j', '205-1-o-1', '206-2',
  95. '207-1-b', '207-2-a', '207-3-a', '207-4-a', '208-1-a', '208-3-a', '208-3-c', '208-4-b-1', '209-1-a',
  96. ];
  97. const codeIndex400 = [
  98. '403-1-a', '403-1-b', '403-2-a', '403-2-b', '403-3-a', '403-3-b', '403-4-a', '403-4-b',
  99. '405-1-b-5', '405-1-b-6', '410-1-b', '410-1-c', '410-2-b', '410-2-c', '410-6-c',
  100. '411-5', '411-7-a', '411-8-a', '413-1-a', '417-5-a'
  101. ];
  102. let codeResult = codeIndex100.concat(codeIndex200, codeIndex400);
  103. codeIndex.forEach(function (a, i) {
  104. assert(a === codeResult[i]);
  105. });
  106. });
  107. it('test gatherChapter', function* () {
  108. const ctx = app.mockContext(mockData);
  109. // test12 - 第6期
  110. const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
  111. const params = {
  112. tender_id: stage.tid,
  113. stage_id: stage.id,
  114. };
  115. const filters = ['mem_stage_bills', 'tender_info'];
  116. const data = yield ctx.service.report.getReportData(params, filters, {
  117. mem_stage_bills: [
  118. 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
  119. 'code', 'b_code', 'name', 'unit', 'unit_price',
  120. 'deal_qty', 'deal_tp',
  121. 'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
  122. 'dgn_qty1', 'dgn_qty2',
  123. 'drawing_code', 'memo', 'node_type', 'is_tp',
  124. 'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil',
  125. 'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
  126. 'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp',
  127. 'final_tp', 'final_ratio',
  128. 'qc_bgl_code',
  129. 'chapter',
  130. ]
  131. });
  132. reportDataAnalysis.analysisObj.gatherChapter.fun(ctx, data, [
  133. {field: 'b_code', table: 'mem_stage_bills'},
  134. {field: 'is_leaf', table: 'mem_stage_bills'},
  135. ]);
  136. const chapter100 = ctx.helper._.find(data.mem_stage_bills, {code: '100'});
  137. assert(chapter100.total_price === 1045756);
  138. const chapter200 = ctx.helper._.find(data.mem_stage_bills, {code: '200'});
  139. assert(chapter200.total_price.toFixed(0) == 3813369);
  140. assert(chapter200.contract_tp == 700.5);
  141. const chapter400 = ctx.helper._.find(data.mem_stage_bills, {code: '400'});
  142. assert(chapter400.total_price.toFixed(0) == 1231018);
  143. });
  144. it('test gatherChapter', function* () {
  145. const ctx = app.mockContext(mockData);
  146. // test12 - 第6期
  147. const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
  148. const params = {
  149. tender_id: stage.tid,
  150. stage_id: stage.id,
  151. };
  152. const filters = ['mem_stage_bills', 'tender_info'];
  153. const data = yield ctx.service.report.getReportData(params, filters, {
  154. mem_stage_bills: [
  155. 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
  156. 'code', 'b_code', 'name', 'unit', 'unit_price',
  157. 'deal_qty', 'deal_tp',
  158. 'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
  159. 'dgn_qty1', 'dgn_qty2',
  160. 'drawing_code', 'memo', 'node_type', 'is_tp',
  161. 'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil',
  162. 'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
  163. 'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp',
  164. 'final_tp', 'final_ratio',
  165. 'qc_bgl_code',
  166. 'chapter',
  167. ]
  168. });
  169. reportDataAnalysis.analysisObj.gatherChapter.fun(ctx, data, [
  170. {field: 'b_code', table: 'mem_stage_bills'},
  171. {field: 'is_leaf', table: 'mem_stage_bills'},
  172. ]);
  173. const chapter100 = ctx.helper._.find(data.mem_stage_bills, {code: '100'});
  174. assert(chapter100.total_price === 1045756);
  175. const chapter200 = ctx.helper._.find(data.mem_stage_bills, {code: '200'});
  176. assert(chapter200.total_price.toFixed(0) == 3813369);
  177. assert(chapter200.contract_tp == 700.5);
  178. const chapter400 = ctx.helper._.find(data.mem_stage_bills, {code: '400'});
  179. assert(chapter400.total_price.toFixed(0) == 1231018);
  180. });
  181. it('test join', function* () {
  182. const ctx = app.mockContext(mockData);
  183. // test12 - 第6期
  184. const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
  185. const params = {
  186. tender_id: stage.tid,
  187. stage_id: stage.id,
  188. };
  189. const filters = ['mem_stage_bills', 'deal_bills'];
  190. const data = yield ctx.service.report.getReportData(params, filters, {
  191. mem_stage_bills: [
  192. 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
  193. 'code', 'b_code', 'name', 'unit', 'unit_price',
  194. 'deal_qty', 'deal_tp',
  195. 'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
  196. 'dgn_qty1', 'dgn_qty2',
  197. 'drawing_code', 'memo', 'node_type', 'is_tp',
  198. 'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil',
  199. 'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
  200. 'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp',
  201. 'final_tp', 'final_ratio',
  202. 'qc_bgl_code',
  203. 'chapter',
  204. ]
  205. });
  206. assert(data.mem_stage_bills.length === 216);
  207. reportDataAnalysis.analysisObj.gatherGcl.fun(ctx, data, [
  208. {field: 'b_code', table: 'mem_stage_bills'},
  209. {field: 'name', table: 'mem_stage_bills'},
  210. {field: 'unit', table: 'mem_stage_bills'},
  211. {field: 'unit_price', table: 'mem_stage_bills'},
  212. {field: 'is_leaf', table: 'mem_stage_bills'},
  213. ]);
  214. assert(data.mem_stage_bills.length === 43);
  215. const joinOptions = {
  216. main: 'mem_stage_bills',
  217. sub: 'deal_bills',
  218. keyFields: [
  219. {main: 'b_code', sub: 'code', type: 'string'},
  220. {main: 'name', sub: 'name',type: 'string'},
  221. {main: 'unit', sub: 'unit',type: 'string'},
  222. {main: 'unit_price', sub: 'unit_price',type: 'number'},
  223. ],
  224. importFields: [
  225. {main: 'ex_value1', sub: 'quantity', type: 'number'},
  226. {main: 'ex_value2', sub: 'total_price', type: 'number'}
  227. ],
  228. joinType: 'outer', //'outer', 'main', 'sub', 'inner'
  229. };
  230. yield ctx.helper.saveBufferFile(JSON.stringify(joinOptions, '', '\t'), ctx.app.baseDir + '/analysis_join_options.json');
  231. reportDataAnalysis.analysisObj.join.fun(ctx, data, [], joinOptions);
  232. assert(data.mem_stage_bills.length === 132);
  233. reportDataAnalysis.analysisObj.sortGcl.fun(ctx, data, [
  234. {field: 'b_code', table: 'mem_stage_bills'},
  235. ]);
  236. const codeIndex = ctx.helper._.map(data.mem_stage_bills, 'b_code');
  237. const codeIndex100 = ['101-1-b', '102-2', '102-3', '102-4', '102-5', '103-1', '103-2',
  238. '103-3', '103-3-a', '103-3-b', '103-4', '104-1', '123-1'];
  239. const codeIndex200 = [
  240. '203-1-a', '203-1-a', '203-1-b', '203-1-b', '203-1-d', '203-1-d', '204-1-b', '204-1-b',
  241. '204-1-c', '204-1-d',
  242. '204-1-g-4', '204-1-g-4', '204-1-j', '204-1-j', '205-1-o-1', '205-1-o-1', '206-2', '206-2',
  243. '207-1-b',
  244. '207-2-a', '207-2-a',
  245. '207-2-b', '207-2-c', '207-3-a',
  246. '207-4-a', '207-4-a',
  247. '207-4-c', '207-10-a',
  248. '208-1-a', '208-1-a', '208-3-a', '208-3-a',
  249. '208-3-b',
  250. '208-3-c', '208-3-c', '208-4-b-1', '208-4-b-1', '209-1-a', '209-1-a',
  251. '209-3', '209-3-b', '215-12', '215-12-a'
  252. ];
  253. let codeResult = codeIndex100.concat(codeIndex200);
  254. codeResult.forEach(function (a, i) {
  255. assert(a === codeIndex[i]);
  256. });
  257. });
  258. it('test filter', function* () {
  259. const ctx = app.mockContext(mockData);
  260. const orgData = {
  261. test: [
  262. {a: 'aaa', b: 0, c: true, order: 1},
  263. {a: 'aaa', b: 1, c: false, order: 2},
  264. {a: 'aaa', b: 2, c: false, order: 3},
  265. {a: 'bbb', b: 3, c: true, order: 4},
  266. {a: 'bbb', b: null, c: true, order: 5},
  267. {a: 'ccc', b: 0, c: false, order: 6},
  268. {a: 'ccc', b: -1, c: false, order: 7},
  269. {a: 'ddd', b: 8, c: true, order: 8},
  270. ]
  271. };
  272. let data, result;
  273. // test boolean;
  274. const b1 = {
  275. table: 'test',
  276. condition: [{ field: "c", type: "bool", value: 'false'}]
  277. };
  278. data = JSON.parse(JSON.stringify(orgData));
  279. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], b1);
  280. result = ctx.helper._.map(data.test, 'order');
  281. assert(ctx.helper._.isEqual(result, [2, 3, 6, 7]));
  282. const b2 = {
  283. table: 'test',
  284. condition: [{ field: "c", type: "bool", value: 'true'}]
  285. };
  286. data = JSON.parse(JSON.stringify(orgData));
  287. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], b2);
  288. result = ctx.helper._.map(data.test, 'order');
  289. assert(ctx.helper._.isEqual(result, [1, 4, 5, 8]));
  290. // test number
  291. const n1 = {
  292. table: 'test',
  293. condition: [{ field: "b", type: "num", operate: 'non-zero'}]
  294. };
  295. data = JSON.parse(JSON.stringify(orgData));
  296. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], n1);
  297. result = ctx.helper._.map(data.test, 'order');
  298. assert(ctx.helper._.isEqual(result, [2, 3, 4, 7, 8]));
  299. const n2 = {
  300. table: 'test',
  301. condition: [{ field: "b", type: "num", operate: '=', value: 1}]
  302. };
  303. data = JSON.parse(JSON.stringify(orgData));
  304. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], n2);
  305. result = ctx.helper._.map(data.test, 'order');
  306. assert(ctx.helper._.isEqual(result, [2]));
  307. const n3 = {
  308. table: 'test',
  309. condition: [{ field: "b", type: "num", operate: '>', value: 1}]
  310. };
  311. data = JSON.parse(JSON.stringify(orgData));
  312. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], n3);
  313. result = ctx.helper._.map(data.test, 'order');
  314. assert(ctx.helper._.isEqual(result, [3, 4, 8]));
  315. const n4 = {
  316. table: 'test',
  317. condition: [{ field: "b", type: "num", operate: '>=', value: 1}]
  318. };
  319. data = JSON.parse(JSON.stringify(orgData));
  320. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], n4);
  321. result = ctx.helper._.map(data.test, 'order');
  322. assert(ctx.helper._.isEqual(result, [2, 3, 4, 8]));
  323. const n5 = {
  324. table: 'test',
  325. condition: [{ field: "b", type: "num", operate: '<', value: 1}]
  326. };
  327. data = JSON.parse(JSON.stringify(orgData));
  328. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], n5);
  329. result = ctx.helper._.map(data.test, 'order');
  330. assert(ctx.helper._.isEqual(result, [1, 6, 7]));
  331. const n6 = {
  332. table: 'test',
  333. condition: [{ field: "b", type: "num", operate: '<=', value: 1}]
  334. };
  335. data = JSON.parse(JSON.stringify(orgData));
  336. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], n6);
  337. result = ctx.helper._.map(data.test, 'order');
  338. assert(ctx.helper._.isEqual(result, [1, 2, 6, 7]));
  339. // string
  340. const s1 = {
  341. table: 'test',
  342. condition: [{ field: "a", type: "str", operate: '=', value: 'aaa'}]
  343. };
  344. data = JSON.parse(JSON.stringify(orgData));
  345. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], s1);
  346. result = ctx.helper._.map(data.test, 'order');
  347. assert(ctx.helper._.isEqual(result, [1, 2, 3]));
  348. const s2 = {
  349. table: 'test',
  350. condition: [{ field: "a", type: "str", operate: 'part', value: 'b'}]
  351. };
  352. data = JSON.parse(JSON.stringify(orgData));
  353. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], s2);
  354. result = ctx.helper._.map(data.test, 'order');
  355. assert(ctx.helper._.isEqual(result, [4, 5]));
  356. const s3 = {
  357. table: 'test',
  358. condition: [{ field: "a", type: "str", operate: 'enum', value: ['ccc', 'ddd']}]
  359. };
  360. data = JSON.parse(JSON.stringify(orgData));
  361. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], s3);
  362. result = ctx.helper._.map(data.test, 'order');
  363. assert(ctx.helper._.isEqual(result, [6, 7, 8]));
  364. // mix
  365. const m1 = {
  366. table: 'test',
  367. condition: [
  368. { field: "c", type: "bool", value: 'true'},
  369. { field: "b", type: "num", operate: 'non-zero'},
  370. { field: "a", type: "str", operate: 'enum', value: ['aaa', 'ddd']},
  371. ]
  372. };
  373. data = JSON.parse(JSON.stringify(orgData));
  374. reportDataAnalysis.analysisObj.filter.fun(ctx, data, [], m1);
  375. result = ctx.helper._.map(data.test, 'order');
  376. assert(ctx.helper._.isEqual(result, [8]));
  377. });
  378. // it('test gatherChapter custom', function* () {
  379. // const ctx = app.mockContext(mockData);
  380. //
  381. // const params = {tender_id: 2072};
  382. // const filters = ['mem_stage_bills', 'tender_info'];
  383. // const data = yield ctx.service.report.getReportData(params, filters, {
  384. // mem_stage_bills: [
  385. // 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
  386. // 'code', 'b_code', 'name', 'unit', 'unit_price',
  387. // 'deal_qty', 'deal_tp',
  388. // 'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
  389. // 'dgn_qty1', 'dgn_qty2',
  390. // 'drawing_code', 'memo', 'node_type', 'is_tp',
  391. // 'qc_bgl_code',
  392. // 'chapter',
  393. // ]
  394. // });
  395. // reportDataAnalysis.analysisObj.gatherChapter.fun(ctx, data, [
  396. // {field: 'b_code', table: 'mem_stage_bills'},
  397. // {field: 'is_leaf', table: 'mem_stage_bills'},
  398. // ], {
  399. // count: 7,
  400. // gclSum: {
  401. // name: '第100章至700章清单合计',
  402. // order: 1,
  403. // },
  404. // custom: [
  405. // {name: '已包含在清单合计中的材料、工程设备、专业工程暂估价', order: 2},
  406. // {name: '清单合计减去材料、工程设备、专业工程暂估价(即8-9=10)', order_calc: 'o1-o2', order: 3},
  407. // {name: '计日工合计', node_type: '计日工', order: 4},
  408. // {name: '暂列金额(不含计日工总额)(即10×暂列金额比列)', node_type: '暂列金额', order: 5},
  409. // {name: '投标报价、台账价(8+11+12)=13', order_calc: 'o1+o4+o5', order: 6},
  410. // ],
  411. // });
  412. // const chapter100 = ctx.helper._.find(data.mem_stage_bills, {code: '100'});
  413. // assert(ctx.helper.checkZero(chapter100.total_price));
  414. // const chapter200 = ctx.helper._.find(data.mem_stage_bills, {code: '200'});
  415. // assert(chapter200.total_price === 33211);
  416. // const chapterGclSum = ctx.helper._.find(data.mem_stage_bills, {cType: 11});
  417. // assert(chapterGclSum.total_price == 33211);
  418. // const chapterJRG = ctx.helper._.find(data.mem_stage_bills, {name: '计日工合计'});
  419. // assert(chapterJRG.total_price === 1076);
  420. // const chapterSumWithoutZGJ = ctx.helper._.find(data.mem_stage_bills, {serialNo: 11});
  421. // assert(chapterSumWithoutZGJ.total_price === 33211);
  422. // const chapterZL = ctx.helper._.find(data.mem_stage_bills, {serialNo: 13});
  423. // assert(chapterZL.total_price === 500000);
  424. // const chapterSum = ctx.helper._.find(data.mem_stage_bills, {serialNo: 14});
  425. // assert(chapterSum.total_price === 534287);
  426. // });
  427. it('test analysisDefine', function() {
  428. const ctx = app.mockContext(mockData);
  429. const define = reportDataAnalysis.analysisDefine;
  430. assert(define.length === 7);
  431. assert(define[0].key === 'changeSort');
  432. assert(define[0].name === reportDataAnalysis.analysisObj.changeSort.name);
  433. assert(define[0].hint === reportDataAnalysis.analysisObj.changeSort.hint);
  434. assert(define[1].key === 'gatherGcl');
  435. assert(define[1].name === reportDataAnalysis.analysisObj.gatherGcl.name);
  436. assert(define[1].hint === reportDataAnalysis.analysisObj.gatherGcl.hint);
  437. assert(define[2].key === 'sortGcl');
  438. assert(define[2].name === reportDataAnalysis.analysisObj.sortGcl.name);
  439. assert(define[2].hint === reportDataAnalysis.analysisObj.sortGcl.hint);
  440. // const x = {
  441. // count: 7,
  442. // gclSum: {
  443. // name: '第100章至700章清单合计',
  444. // order: 1,
  445. // },
  446. // custom: [
  447. // {name: '已包含在清单合计中的材料、工程设备、专业工程暂估价', order: 2},
  448. // {name: '清单合计减去材料、工程设备、专业工程暂估价(即8-9=10)', order_calc: 'o1-o2', order: 3},
  449. // {name: '计日工合计', node_type: '计日工', order: 4},
  450. // {name: '暂列金额(不含计日工总额)(即10×暂列金额比列)', node_type: '暂列金额', order: 5},
  451. // {name: '投标报价、台账价(8+11+12)=13', order_calc: 'o1+o4+o5', order: 6},
  452. // ],
  453. // };
  454. // ctx.helper.saveBufferFile(JSON.stringify(x, "", "\t"), ctx.app.baseDir + '/mem_stage_pos.json');
  455. });
  456. });