rpt_gather_memory.test.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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();
  31. const postData = {
  32. account: 'zengpeiwen',
  33. project: 'P1201',
  34. project_password: '123456',
  35. };
  36. ctx.session = {};
  37. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  38. // const select = {
  39. // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  40. // type: 'month',
  41. // month: '2020-01',
  42. // };
  43. // const select = {
  44. // tenders: [{tid: 2256}, {tid: 2257}],
  45. // type: 'ledger',
  46. // };
  47. // const define = {
  48. // enable: true,
  49. // setting: JSON.stringify({
  50. // title: '请选择汇总的标段',
  51. // type: 'month',
  52. // special: [
  53. // {"title": "批复概算", "key": "gs"}
  54. // ]
  55. // })
  56. // };
  57. const select = {
  58. tenders: [{tid: 2659}],
  59. type: 'final',
  60. };
  61. const define = {
  62. enable: true,
  63. setting: JSON.stringify({
  64. title: '请选择汇总的标段',
  65. type: 'final',
  66. hasPre: true
  67. })
  68. };
  69. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStageBills([], define, select);
  70. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_stage_bills.json'));
  71. // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  72. // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  73. // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  74. // cDefine: { gather_select: select },
  75. // tplDefine: {gather_select: define },
  76. // });
  77. // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  78. // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  79. });
  80. // 标段信息
  81. it('test getGatherTenderInfo - month', function* () {
  82. const ctx = app.mockContext(mockData);
  83. // const select = {
  84. // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  85. // type: 'month',
  86. // month: '2020-01',
  87. // };
  88. const select = {
  89. tenders: [{tid: 2256}, {tid: 2257}],
  90. type: 'ledger',
  91. };
  92. // const define = {
  93. // enable: true,
  94. // setting: JSON.stringify({
  95. // title: '请选择汇总的标段',
  96. // type: 'month',
  97. // special: [
  98. // {"title": "批复概算", "key": "gs"}
  99. // ]
  100. // })
  101. // };
  102. const define = {
  103. enable: true,
  104. setting: JSON.stringify({
  105. title: '请选择汇总的标段',
  106. type: 'ledger',
  107. })
  108. };
  109. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherTenderInfo([], define, select);
  110. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_tender_info.json'));
  111. // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  112. // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  113. // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  114. // cDefine: { gather_select: select },
  115. // tplDefine: {gather_select: define },
  116. // });
  117. // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  118. // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  119. }); // 标段信息
  120. it('test getGatherDealPay - final', function* () {
  121. const ctx = app.mockContext(mockData);
  122. // const select = {
  123. // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  124. // type: 'month',
  125. // month: '2020-01',
  126. // };
  127. const select = {
  128. tenders: [{tid: 2256}, {tid: 2257}],
  129. type: 'final',
  130. };
  131. // const define = {
  132. // enable: true,
  133. // setting: JSON.stringify({
  134. // title: '请选择汇总的标段',
  135. // type: 'month',
  136. // special: [
  137. // {"title": "批复概算", "key": "gs"}
  138. // ]
  139. // })
  140. // };
  141. const define = {
  142. enable: true,
  143. setting: JSON.stringify({
  144. title: '请选择汇总的标段',
  145. type: 'final',
  146. })
  147. };
  148. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStagePay([], define, select);
  149. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_pay.json'));
  150. // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  151. // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  152. // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  153. // cDefine: { gather_select: select },
  154. // tplDefine: {gather_select: define },
  155. // });
  156. // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  157. // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  158. });
  159. it('test getGatherDealBills - final', function* () {
  160. const ctx = app.mockContext(mockData);
  161. // const select = {
  162. // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  163. // type: 'month',
  164. // month: '2020-01',
  165. // };
  166. const select = {
  167. tenders: [{tid: 2256}, {tid: 2257}],
  168. type: 'final',
  169. };
  170. // const define = {
  171. // enable: true,
  172. // setting: JSON.stringify({
  173. // title: '请选择汇总的标段',
  174. // type: 'month',
  175. // special: [
  176. // {"title": "批复概算", "key": "gs"}
  177. // ]
  178. // })
  179. // };
  180. const define = {
  181. enable: true,
  182. setting: JSON.stringify({
  183. title: '请选择汇总的标段',
  184. type: 'final',
  185. })
  186. };
  187. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherDealBills([], define, select);
  188. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_pay.json'));
  189. // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  190. // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  191. // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  192. // cDefine: { gather_select: select },
  193. // tplDefine: {gather_select: define },
  194. // });
  195. // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  196. // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  197. });
  198. });