|
@@ -11,6 +11,7 @@
|
|
|
const { app, assert } = require('egg-mock/bootstrap');
|
|
|
const mockData = {};
|
|
|
const path = require('path');
|
|
|
+let savePath;
|
|
|
|
|
|
const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
|
|
|
|
|
@@ -18,6 +19,7 @@ describe('test/app/service/report_memory.test.js', () => {
|
|
|
// 准备测试数据
|
|
|
before(function* () {
|
|
|
const ctx = app.mockContext();
|
|
|
+ savePath = path.join(ctx.app.baseDir,'report_temp');
|
|
|
// 模拟登录session
|
|
|
// const postData = {
|
|
|
// account: 'fuqingqing',
|
|
@@ -491,4 +493,40 @@ describe('test/app/service/report_memory.test.js', () => {
|
|
|
// };
|
|
|
// ctx.helper.saveBufferFile(JSON.stringify(x, "", "\t"), ctx.app.baseDir + '/mem_stage_pos.json');
|
|
|
});
|
|
|
+ it('test sortPos/unionPos', function* () {
|
|
|
+ const ctx = app.mockContext(mockData);
|
|
|
+
|
|
|
+ // test12 - 第6期
|
|
|
+ const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
|
|
|
+ const params = {
|
|
|
+ tender_id: stage.tid,
|
|
|
+ stage_id: stage.id,
|
|
|
+ };
|
|
|
+ const filters = ['mem_stage_bills', 'tender_info', 'mem_stage_pos'];
|
|
|
+ const data = yield ctx.service.report.getReportData(params, filters, {
|
|
|
+ mem_stage_bills: [
|
|
|
+ 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
|
|
|
+ 'code', 'b_code', 'name', 'unit', 'unit_price',
|
|
|
+ 'deal_qty', 'deal_tp',
|
|
|
+ 'sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'quantity', 'total_price',
|
|
|
+ 'dgn_qty1', 'dgn_qty2',
|
|
|
+ 'drawing_code', 'memo', 'node_type', 'is_tp',
|
|
|
+ 'contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp', 'postil',
|
|
|
+ 'pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp',
|
|
|
+ 'end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp',
|
|
|
+ 'final_tp', 'final_ratio',
|
|
|
+ 'qc_bgl_code',
|
|
|
+ 'chapter',
|
|
|
+ ],
|
|
|
+ mem_stage_pos: [],
|
|
|
+ });
|
|
|
+ // sortPos
|
|
|
+ // reportDataAnalysis.analysisObj.sortPos.fun(ctx, data, [], {bills: 'mem_stage_bills', pos: 'mem_stage_pos'});
|
|
|
+ // yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_stage_bills, "", "\t"), path.join(savePath, 'mem_stage_bills.json'));
|
|
|
+ // yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_stage_pos, "", "\t"), path.join(savePath, 'mem_stage_pos.json'));
|
|
|
+
|
|
|
+ // unionPos
|
|
|
+ reportDataAnalysis.analysisObj.unionPos.fun(ctx, data, [], {bills: 'mem_stage_bills', pos: 'mem_stage_pos'});
|
|
|
+ yield ctx.helper.saveBufferFile(JSON.stringify(data.mem_stage_bills, "", "\t"), path.join(savePath, 'mem_stage_bills.json'));
|
|
|
+ });
|
|
|
});
|