report_memory_temp.test.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  14. describe('test/app/service/report_memory.test.js', () => {
  15. // 准备测试数据
  16. before(function* () {
  17. const ctx = app.mockContext();
  18. savePath = path.join(ctx.app.baseDir,'report_temp');
  19. // const postData = {
  20. // account: '734406061@qq.com',
  21. // project: 'T201711273363',
  22. // project_password: 'mai654321',
  23. // };
  24. ctx.session = {};
  25. mockData.session = ctx.session;
  26. });
  27. // 汇总合同支付
  28. it('test getGatherStagePay', function* () {
  29. const ctx = app.mockContext();
  30. const postData = {
  31. account: 'fuqingqing',
  32. project: 'P0505',
  33. project_password: '123456',
  34. };
  35. ctx.session = {};
  36. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  37. assert(loginResult);
  38. const select = {
  39. tenders: [{tid: 2283}, {tid: 2281}],
  40. type: 'final',
  41. };
  42. const define = {
  43. enable: true,
  44. setting: JSON.stringify({
  45. title: '请选择汇总的标段',
  46. type: 'final',
  47. })
  48. };
  49. const data = {};
  50. data.mem_gather_stage_pay = yield ctx.service.rptGatherMemory.getGatherStagePay([], define, select);
  51. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_stage_pay, "", "\t"), path.join(savePath, 'mem_gather_stage_pay.json'));
  52. reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, data, [], {table: ['mem_gather_stage_pay']}, {
  53. tplDefine: {gather_select: define}, cDefine: {gather_select: select}});
  54. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_stage_pay, "", "\t"), path.join(savePath, 'mem_gather_stage_pay_converse.json'));
  55. });
  56. // 汇总签约清单
  57. it('test getGatherStagePay', function* () {
  58. const ctx = app.mockContext();
  59. const postData = {
  60. account: 'zengpeiwen',
  61. project: 'P1201',
  62. project_password: '123456',
  63. };
  64. ctx.session = {};
  65. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  66. assert(loginResult);
  67. const select = {
  68. tenders: [{tid: 2046}, {tid: 1942}, {tid: 2217}],
  69. type: 'final',
  70. };
  71. const define = {
  72. enable: true,
  73. setting: JSON.stringify({
  74. title: '请选择汇总的标段',
  75. type: 'final',
  76. })
  77. };
  78. const data = {};
  79. data.mem_gather_deal_bills = yield ctx.service.rptGatherMemory.getGatherDealBills([], define, select);
  80. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_deal_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_bills.json'));
  81. });
  82. });