rpt_gather_memory.test.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2020/4/17
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const path = require('path');
  11. let savePath;
  12. const mockData = {};
  13. describe('test/app/service/rpt_gather_memory.test.js', () => {
  14. // 准备测试数据
  15. before(function* () {
  16. const ctx = app.mockContext();
  17. savePath = path.join(ctx.app.baseDir,'report_temp');
  18. const postData = {
  19. account: '734406061@qq.com',
  20. project: 'T201711273363',
  21. project_password: 'mai654321',
  22. };
  23. ctx.session = {};
  24. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  25. assert(loginResult);
  26. mockData.session = ctx.session;
  27. });
  28. // 台账数据
  29. it('test getGatherStageBills - month', function* () {
  30. const ctx = app.mockContext(mockData);
  31. // const select = {
  32. // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  33. // type: 'month',
  34. // month: '2020-01',
  35. // };
  36. const select = {
  37. tenders: [{tid: 2256}, {tid: 2257}],
  38. type: 'ledger',
  39. };
  40. // const define = {
  41. // enable: true,
  42. // setting: JSON.stringify({
  43. // title: '请选择汇总的标段',
  44. // type: 'month',
  45. // special: [
  46. // {"title": "批复概算", "key": "gs"}
  47. // ]
  48. // })
  49. // };
  50. const define = {
  51. enable: true,
  52. setting: JSON.stringify({
  53. title: '请选择汇总的标段',
  54. type: 'ledger',
  55. })
  56. };
  57. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStageBills([], define, select);
  58. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_stage_bills.json'));
  59. // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  60. // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  61. // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  62. // cDefine: { gather_select: select },
  63. // tplDefine: {gather_select: define },
  64. // });
  65. // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  66. // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  67. });
  68. // 标段信息
  69. it('test getGatherTenderInfo - month', function* () {
  70. const ctx = app.mockContext(mockData);
  71. // const select = {
  72. // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  73. // type: 'month',
  74. // month: '2020-01',
  75. // };
  76. const select = {
  77. tenders: [{tid: 2256}, {tid: 2257}],
  78. type: 'ledger',
  79. };
  80. // const define = {
  81. // enable: true,
  82. // setting: JSON.stringify({
  83. // title: '请选择汇总的标段',
  84. // type: 'month',
  85. // special: [
  86. // {"title": "批复概算", "key": "gs"}
  87. // ]
  88. // })
  89. // };
  90. const define = {
  91. enable: true,
  92. setting: JSON.stringify({
  93. title: '请选择汇总的标段',
  94. type: 'ledger',
  95. })
  96. };
  97. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherTenderInfo([], define, select);
  98. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_tender_info.json'));
  99. // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  100. // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  101. // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  102. // cDefine: { gather_select: select },
  103. // tplDefine: {gather_select: define },
  104. // });
  105. // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  106. // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  107. }); // 标段信息
  108. it('test getGatherDealPay - final', function* () {
  109. const ctx = app.mockContext(mockData);
  110. // const select = {
  111. // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  112. // type: 'month',
  113. // month: '2020-01',
  114. // };
  115. const select = {
  116. tenders: [{tid: 2256}, {tid: 2257}],
  117. type: 'final',
  118. };
  119. // const define = {
  120. // enable: true,
  121. // setting: JSON.stringify({
  122. // title: '请选择汇总的标段',
  123. // type: 'month',
  124. // special: [
  125. // {"title": "批复概算", "key": "gs"}
  126. // ]
  127. // })
  128. // };
  129. const define = {
  130. enable: true,
  131. setting: JSON.stringify({
  132. title: '请选择汇总的标段',
  133. type: 'final',
  134. })
  135. };
  136. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStagePay([], define, select);
  137. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_pay.json'));
  138. // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  139. // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  140. // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  141. // cDefine: { gather_select: select },
  142. // tplDefine: {gather_select: define },
  143. // });
  144. // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  145. // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  146. });
  147. it('test getGatherDealBills - final', function* () {
  148. const ctx = app.mockContext(mockData);
  149. // const select = {
  150. // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  151. // type: 'month',
  152. // month: '2020-01',
  153. // };
  154. const select = {
  155. tenders: [{tid: 2256}, {tid: 2257}],
  156. type: 'final',
  157. };
  158. // const define = {
  159. // enable: true,
  160. // setting: JSON.stringify({
  161. // title: '请选择汇总的标段',
  162. // type: 'month',
  163. // special: [
  164. // {"title": "批复概算", "key": "gs"}
  165. // ]
  166. // })
  167. // };
  168. const define = {
  169. enable: true,
  170. setting: JSON.stringify({
  171. title: '请选择汇总的标段',
  172. type: 'final',
  173. })
  174. };
  175. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherDealBills([], define, select);
  176. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_pay.json'));
  177. // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  178. // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  179. // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  180. // cDefine: { gather_select: select },
  181. // tplDefine: {gather_select: define },
  182. // });
  183. // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  184. // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  185. });
  186. });