123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- const { app, assert } = require('egg-mock/bootstrap');
- const path = require('path');
- let savePath;
- const mockData = {};
- const testSetting1 = {
- postData: {
- account: 'fuqingqing',
- project: 'P0505',
- project_password: '123456',
- },
- define: {
- enable: true,
- setting: JSON.stringify({
- title: '请选择汇总的标段',
- type: 'final',
- })
- },
- select: {
- tenders: [{tid: 2283}, {tid: 2281}],
- type: 'final',
- }
- };
- const testSetting2 = {
- postData: {
- account: 'zengpeiwen',
- project: 'P1201',
- project_password: '123456',
- },
- define: {
- enable: true,
- setting: JSON.stringify({
- title: '请选择汇总的标段',
- type: 'final',
- })
- },
- select: {
- tenders: [{tid: 2046}, {tid: 1942}, {tid: 2217}],
- type: 'final',
- }
- };
- const testSetting3 = {
- postData: {
- account: 'zengpeiwen',
- project: 'P1201',
- project_password: '123456',
- },
- define: {
- enable: true,
- setting: JSON.stringify({
- "title": "请选择汇总的标段",
- "type": "final",
- "nameColWidth": 180,
- "special": [
- {"title": "估算", "key": "gu", "width": 60},
- {"title": "概算", "key": "gai", "width": 60},
- {"title": "预算", "key": "yu", "width": 60}
- ]
- })
- },
- select: JSON.parse('{"tenders":[{"tid":1942},{"tid":2217},{"tid":2046},{"tid":2172,"gu":true},{"tid":2324,"gai":true},{"tid":2326,"yu":true}],"type":"final"}')
- };
- const testSetting4 = {
- postData: {
- account: 'zengpeiwen',
- project: 'P1201',
- project_password: '123456',
- },
- tenderId: 2436,
- sorder: 1,
- };
- const testSetting5 = {
- postData: {
- account: 'fuqingqing',
- project: 'P0505',
- project_password: '123456',
- },
- tenderId: 2142,
- sorder: 4,
- };
- const testSetting6 = {
- postData: {
- account: 'zengpeiwen',
- project: 'P1201',
- project_password: '123456',
- },
- tenderId: 2504,
- sorder: 1,
- };
- const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
- describe('test/app/service/report_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 = {};
- mockData.session = ctx.session;
- });
- // 汇总合同支付
- it('test getGatherStagePay', function* () {
- const ctx = app.mockContext();
- const postData = {
- account: 'fuqingqing',
- project: 'P0505',
- project_password: '123456',
- };
- ctx.session = {};
- const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
- assert(loginResult);
- const select = {
- tenders: [{tid: 2283}, {tid: 2281}],
- type: 'final',
- };
- const define = {
- enable: true,
- setting: JSON.stringify({
- title: '请选择汇总的标段',
- type: 'final',
- })
- };
- const data = {};
- data.mem_gather_stage_pay = yield ctx.service.rptGatherMemory.getGatherStagePay([], define, select);
- yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_stage_pay, "", "\t"), path.join(savePath, 'mem_gather_stage_pay.json'));
- reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, data, [], {table: ['mem_gather_stage_pay']}, {
- tplDefine: {gather_select: define}, cDefine: {gather_select: select}});
- yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_stage_pay, "", "\t"), path.join(savePath, 'mem_gather_stage_pay_converse.json'));
- });
- // 汇总签约清单
- it('test getGatherDealBills', function* () {
- const ctx = app.mockContext();
- const testSetting = testSetting3;
- ctx.session = {};
- const loginResult = yield ctx.service.projectAccount.accountLogin(testSetting.postData, 2);
- assert(loginResult);
- const data = {};
- data.mem_gather_deal_bills = yield ctx.service.rptGatherMemory.getGatherDealBills([], testSetting.define, testSetting.select);
- yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_gather_deal_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_bills.json'));
- });
- it('test getStageImTzData && getStageImTzBillsData', function* () {
- const ctx = app.mockContext();
- const testSetting = testSetting6;
- ctx.session = {};
- const loginResult = yield ctx.service.projectAccount.accountLogin(testSetting.postData, 2);
- assert(loginResult);
- const data = {};
- const stage = yield ctx.service.stage.getDataByCondition({tid: testSetting.tenderId, order: testSetting.sorder});
- data.mem_stage_im_tz = yield ctx.service.reportMemory.getStageImTzData(stage.tid, stage.id, [], false);
- yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_stage_im_tz, "", "\t"), path.join(savePath, 'mem_stage_im_tz.json'));
- data.mem_stage_im_tz_bills = yield ctx.service.reportMemory.getStageImTzBillsData(stage.tid, stage.id, [], false);
- yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_stage_im_tz_bills, "", "\t"), path.join(savePath, 'mem_stage_im_tz_bills.json'));
- });
- it('test getStageImZlData', function* () {
- const ctx = app.mockContext();
- const testSetting = testSetting5;
- ctx.session = {};
- const loginResult = yield ctx.service.projectAccount.accountLogin(testSetting.postData, 2);
- assert(loginResult);
- const data = {};
- const stage = yield ctx.service.stage.getDataByCondition({tid: testSetting.tenderId, order: testSetting.sorder});
- data.mem_stage_im_zl = yield ctx.service.reportMemory.getStageImZlData(stage.tid, stage.id, []);
- yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_stage_im_zl, "", "\t"), path.join(savePath, 'mem_stage_im_zl.json'));
- });
- });
|