Sfoglia il codice sorgente

中间计量,计算式说明问题

MaiXinRong 5 anni fa
parent
commit
c1d0f65493

+ 1 - 1
app/lib/stage_im.js

@@ -259,7 +259,7 @@ class StageIm {
                 }
             }
             im.calc_memo = memo.join('\n');
-        } else if (im.check) {
+        } else if (im.gclBills && im.gclBills.length > 0) {
             const memo = [];
             for (const [i, b] of im.gclBills.entries()) {
                 if (b.pos && b.pos.length > 0) {

+ 14 - 11
app/service/report_memory.js

@@ -193,13 +193,12 @@ module.exports = app => {
             }
         }
 
-        async getStageImTzData(tid, sid, fields) {
+        async getStageImTzData(tid, sid, fields, readCache = true) {
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.stage.checkStage(sid);
-            const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
-            if (cache) {
-                // console.log('cache');
-                return cache;
+            if (readCache) {
+                const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
+                if (cache) return cache;
             }
 
             // console.log('build');
@@ -218,11 +217,13 @@ module.exports = app => {
             return this.stageImData.main;
         }
 
-        async getStageImTzBillsData(tid, sid, fields) {
+        async getStageImTzBillsData(tid, sid, fields, readCache = true) {
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.stage.checkStage(sid);
-            const cache = await this._getReportMemoryCache('mem_stage_im_tz_bills', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
-            if (cache) return cache;
+            if (readCache) {
+                const cache = await this._getReportMemoryCache('mem_stage_im_tz_bills', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
+                if (cache) return cache;
+            }
 
             if (!this.stageImData) {
                 this.stageImData = {};
@@ -239,11 +240,13 @@ module.exports = app => {
             return this.stageImData.bills;
         }
 
-        async getStageImZlData(tid, sid, fields) {
+        async getStageImZlData(tid, sid, fields, readCache = true) {
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.stage.checkStage(sid);
-            const cache = await this._getReportMemoryCache('mem_stage_im_zl', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
-            if (cache) return cache;
+            if (readCache) {
+                const cache = await this._getReportMemoryCache('mem_stage_im_zl', tid, sid, this.ctx.stage.cacheTime, stageImVersion);
+                if (cache) return cache;
+            }
 
             this.stageImData = {};
             try {

+ 23 - 0
test/app/service/report_memory_temp.test.js

@@ -70,6 +70,15 @@ const testSetting3 = {
     },
     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 reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
 
@@ -129,4 +138,18 @@ describe('test/app/service/report_memory.test.js', () => {
         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 = testSetting4;
+        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'));
+    });
 });