123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date 2020/4/17
- * @version
- */
- const { app, assert } = require('egg-mock/bootstrap');
- const path = require('path');
- let savePath;
- const mockData = {};
- describe('test/app/service/rpt_gather_memory.test.js', () => {
- // 准备测试数据
- before(function* () {
- const ctx = app.mockContext();
- savePath = path.join(ctx.app.baseDir,'report_temp');
- const postData = {
- account: '734406061@qq.com',
- project: 'T201711273363',
- project_password: 'mai654321',
- };
- ctx.session = {};
- const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
- assert(loginResult);
- mockData.session = ctx.session;
- });
- // 台账数据
- it('test getGatherStageBills - month', function* () {
- const ctx = app.mockContext();
- const postData = {
- account: 'zengpeiwen',
- project: 'P1201',
- project_password: '123456',
- };
- ctx.session = {};
- const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
- // const select = {
- // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
- // type: 'month',
- // month: '2020-01',
- // };
- // const select = {
- // tenders: [{tid: 2256}, {tid: 2257}],
- // type: 'ledger',
- // };
- // const define = {
- // enable: true,
- // setting: JSON.stringify({
- // title: '请选择汇总的标段',
- // type: 'month',
- // special: [
- // {"title": "批复概算", "key": "gs"}
- // ]
- // })
- // };
- const select = {
- tenders: [{tid: 2659}],
- type: 'final',
- };
- const define = {
- enable: true,
- setting: JSON.stringify({
- title: '请选择汇总的标段',
- type: 'final',
- hasPre: true
- })
- };
- const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStageBills([], define, select);
- yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_stage_bills.json'));
- // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
- // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
- // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
- // cDefine: { gather_select: select },
- // tplDefine: {gather_select: define },
- // });
- // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
- // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
- });
- // 标段信息
- it('test getGatherTenderInfo - month', function* () {
- const ctx = app.mockContext(mockData);
- // const select = {
- // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
- // type: 'month',
- // month: '2020-01',
- // };
- const select = {
- tenders: [{tid: 2256}, {tid: 2257}],
- type: 'ledger',
- };
- // const define = {
- // enable: true,
- // setting: JSON.stringify({
- // title: '请选择汇总的标段',
- // type: 'month',
- // special: [
- // {"title": "批复概算", "key": "gs"}
- // ]
- // })
- // };
- const define = {
- enable: true,
- setting: JSON.stringify({
- title: '请选择汇总的标段',
- type: 'ledger',
- })
- };
- const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherTenderInfo([], define, select);
- yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_tender_info.json'));
- // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
- // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
- // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
- // cDefine: { gather_select: select },
- // tplDefine: {gather_select: define },
- // });
- // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
- // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
- }); // 标段信息
- it('test getGatherDealPay - final', function* () {
- const ctx = app.mockContext(mockData);
- // const select = {
- // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
- // type: 'month',
- // month: '2020-01',
- // };
- const select = {
- tenders: [{tid: 2256}, {tid: 2257}],
- type: 'final',
- };
- // const define = {
- // enable: true,
- // setting: JSON.stringify({
- // title: '请选择汇总的标段',
- // type: 'month',
- // special: [
- // {"title": "批复概算", "key": "gs"}
- // ]
- // })
- // };
- const define = {
- enable: true,
- setting: JSON.stringify({
- title: '请选择汇总的标段',
- type: 'final',
- })
- };
- const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStagePay([], define, select);
- yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_pay.json'));
- // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
- // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
- // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
- // cDefine: { gather_select: select },
- // tplDefine: {gather_select: define },
- // });
- // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
- // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
- });
- it('test getGatherDealBills - final', function* () {
- const ctx = app.mockContext(mockData);
- // const select = {
- // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
- // type: 'month',
- // month: '2020-01',
- // };
- const select = {
- tenders: [{tid: 2256}, {tid: 2257}],
- type: 'final',
- };
- // const define = {
- // enable: true,
- // setting: JSON.stringify({
- // title: '请选择汇总的标段',
- // type: 'month',
- // special: [
- // {"title": "批复概算", "key": "gs"}
- // ]
- // })
- // };
- const define = {
- enable: true,
- setting: JSON.stringify({
- title: '请选择汇总的标段',
- type: 'final',
- })
- };
- const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherDealBills([], define, select);
- yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_pay.json'));
- // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
- // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
- // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
- // cDefine: { gather_select: select },
- // tplDefine: {gather_select: define },
- // });
- // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
- // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
- });
- });
|