report_memory_temp.test.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const path = require('path');
  11. let savePath;
  12. const mockData = {};
  13. const testSetting1 = {
  14. postData: {
  15. account: 'fuqingqing',
  16. project: 'P0505',
  17. project_password: '123456',
  18. },
  19. define: {
  20. enable: true,
  21. setting: JSON.stringify({
  22. title: '请选择汇总的标段',
  23. type: 'final',
  24. })
  25. },
  26. select: {
  27. tenders: [{tid: 2283}, {tid: 2281}],
  28. type: 'final',
  29. }
  30. };
  31. const testSetting2 = {
  32. postData: {
  33. account: 'zengpeiwen',
  34. project: 'P1201',
  35. project_password: '123456',
  36. },
  37. define: {
  38. enable: true,
  39. setting: JSON.stringify({
  40. title: '请选择汇总的标段',
  41. type: 'final',
  42. })
  43. },
  44. select: {
  45. tenders: [{tid: 2046}, {tid: 1942}, {tid: 2217}],
  46. type: 'final',
  47. }
  48. };
  49. const testSetting3 = {
  50. postData: {
  51. account: 'zengpeiwen',
  52. project: 'P1201',
  53. project_password: '123456',
  54. },
  55. define: {
  56. enable: true,
  57. setting: JSON.stringify({
  58. "title": "请选择汇总的标段",
  59. "type": "final",
  60. "nameColWidth": 180,
  61. "special": [
  62. {"title": "估算", "key": "gu", "width": 60},
  63. {"title": "概算", "key": "gai", "width": 60},
  64. {"title": "预算", "key": "yu", "width": 60}
  65. ]
  66. })
  67. },
  68. select: JSON.parse('{"tenders":[{"tid":1942},{"tid":2217},{"tid":2046},{"tid":2172,"gu":true},{"tid":2324,"gai":true},{"tid":2326,"yu":true}],"type":"final"}')
  69. };
  70. const testSetting4 = {
  71. postData: {
  72. account: 'zengpeiwen',
  73. project: 'P1201',
  74. project_password: '123456',
  75. },
  76. tenderId: 2436,
  77. sorder: 1,
  78. };
  79. const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  80. describe('test/app/service/report_memory.test.js', () => {
  81. // 准备测试数据
  82. before(function* () {
  83. const ctx = app.mockContext();
  84. savePath = path.join(ctx.app.baseDir,'report_temp');
  85. // const postData = {
  86. // account: '734406061@qq.com',
  87. // project: 'T201711273363',
  88. // project_password: 'mai654321',
  89. // };
  90. ctx.session = {};
  91. mockData.session = ctx.session;
  92. });
  93. // 汇总合同支付
  94. it('test getGatherStagePay', function* () {
  95. const ctx = app.mockContext();
  96. const postData = {
  97. account: 'fuqingqing',
  98. project: 'P0505',
  99. project_password: '123456',
  100. };
  101. ctx.session = {};
  102. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  103. assert(loginResult);
  104. const select = {
  105. tenders: [{tid: 2283}, {tid: 2281}],
  106. type: 'final',
  107. };
  108. const define = {
  109. enable: true,
  110. setting: JSON.stringify({
  111. title: '请选择汇总的标段',
  112. type: 'final',
  113. })
  114. };
  115. const data = {};
  116. data.mem_gather_stage_pay = yield ctx.service.rptGatherMemory.getGatherStagePay([], define, select);
  117. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_stage_pay, "", "\t"), path.join(savePath, 'mem_gather_stage_pay.json'));
  118. reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, data, [], {table: ['mem_gather_stage_pay']}, {
  119. tplDefine: {gather_select: define}, cDefine: {gather_select: select}});
  120. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_stage_pay, "", "\t"), path.join(savePath, 'mem_gather_stage_pay_converse.json'));
  121. });
  122. // 汇总签约清单
  123. it('test getGatherDealBills', function* () {
  124. const ctx = app.mockContext();
  125. const testSetting = testSetting3;
  126. ctx.session = {};
  127. const loginResult = yield ctx.service.projectAccount.accountLogin(testSetting.postData, 2);
  128. assert(loginResult);
  129. const data = {};
  130. data.mem_gather_deal_bills = yield ctx.service.rptGatherMemory.getGatherDealBills([], testSetting.define, testSetting.select);
  131. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_deal_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_bills.json'));
  132. });
  133. it('test getStageImTzData && getStageImTzBillsData', function* () {
  134. const ctx = app.mockContext();
  135. const testSetting = testSetting4;
  136. ctx.session = {};
  137. const loginResult = yield ctx.service.projectAccount.accountLogin(testSetting.postData, 2);
  138. assert(loginResult);
  139. const data = {};
  140. const stage = yield ctx.service.stage.getDataByCondition({tid: testSetting.tenderId, order: testSetting.sorder});
  141. data.mem_stage_im_tz = yield ctx.service.reportMemory.getStageImTzData(stage.tid, stage.id, [], false);
  142. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_stage_im_tz, "", "\t"), path.join(savePath, 'mem_stage_im_tz.json'));
  143. data.mem_stage_im_tz_bills = yield ctx.service.reportMemory.getStageImTzBillsData(stage.tid, stage.id, [], false);
  144. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_stage_im_tz_bills, "", "\t"), path.join(savePath, 'mem_stage_im_tz_bills.json'));
  145. });
  146. });