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