report_memory_temp.test.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  71. describe('test/app/service/report_memory.test.js', () => {
  72. // 准备测试数据
  73. before(function* () {
  74. const ctx = app.mockContext();
  75. savePath = path.join(ctx.app.baseDir,'report_temp');
  76. // const postData = {
  77. // account: '734406061@qq.com',
  78. // project: 'T201711273363',
  79. // project_password: 'mai654321',
  80. // };
  81. ctx.session = {};
  82. mockData.session = ctx.session;
  83. });
  84. // 汇总合同支付
  85. it('test getGatherStagePay', function* () {
  86. const ctx = app.mockContext();
  87. const postData = {
  88. account: 'fuqingqing',
  89. project: 'P0505',
  90. project_password: '123456',
  91. };
  92. ctx.session = {};
  93. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  94. assert(loginResult);
  95. const select = {
  96. tenders: [{tid: 2283}, {tid: 2281}],
  97. type: 'final',
  98. };
  99. const define = {
  100. enable: true,
  101. setting: JSON.stringify({
  102. title: '请选择汇总的标段',
  103. type: 'final',
  104. })
  105. };
  106. const data = {};
  107. data.mem_gather_stage_pay = yield ctx.service.rptGatherMemory.getGatherStagePay([], define, select);
  108. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_stage_pay, "", "\t"), path.join(savePath, 'mem_gather_stage_pay.json'));
  109. reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, data, [], {table: ['mem_gather_stage_pay']}, {
  110. tplDefine: {gather_select: define}, cDefine: {gather_select: select}});
  111. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_stage_pay, "", "\t"), path.join(savePath, 'mem_gather_stage_pay_converse.json'));
  112. });
  113. // 汇总签约清单
  114. it('test getGatherDealBills', function* () {
  115. const ctx = app.mockContext();
  116. const testSetting = testSetting3;
  117. ctx.session = {};
  118. const loginResult = yield ctx.service.projectAccount.accountLogin(testSetting.postData, 2);
  119. assert(loginResult);
  120. const data = {};
  121. data.mem_gather_deal_bills = yield ctx.service.rptGatherMemory.getGatherDealBills([], testSetting.define, testSetting.select);
  122. yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_deal_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_bills.json'));
  123. });
  124. });