| 
					
				 | 
			
			
				@@ -17,6 +17,7 @@ const audit = require('../const/audit'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const stageImTz = 'mem_stage_im_tz'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const stageImTzBills = 'mem_stage_im_tz_bills'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const stageImZl = 'mem_stage_im_zl'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const stageImVersion = '1.0'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     class ReportMemory extends app.BaseService { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -39,9 +40,9 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 1. 达到redis内存阈值时,数据会swap到磁盘,此时将消耗IO时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 2. redis单独服务器 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 3. redis集群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        async _getReportMemoryCache(name, tid, sid, time) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        async _getReportMemoryCache(name, tid, sid, time, version = '') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // redis 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const cacheKey = name + '-t' + tid + (sid ? '-s' + sid : '') + (time ? '-' + time : ''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const cacheKey = name + '-t' + tid + (sid ? '-s' + sid : '') + (time ? '-' + time : '') + version; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const data = await this.cache.get(cacheKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return eval(data); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -64,9 +65,9 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        async _setReportMemoryCache(name, tid, sid, time, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        async _setReportMemoryCache(name, tid, sid, time, data, version = '') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // redis 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const cacheKey = name + '-t' + tid + (sid ? '-s' + sid : '') + (time ? '-' + time : ''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const cacheKey = name + '-t' + tid + (sid ? '-s' + sid : '') + (time ? '-' + time : '') + version; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.cache.set(cacheKey, JSON.stringify(data), 'EX', this.ctx.app.config.cacheTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // mysql + IO 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -93,10 +94,10 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.stageImData.main = stageIm.ImData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (isTz) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 this.stageImData.bills = stageIm.ImBillsData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this._setReportMemoryCache(stageImTz, tid, sid, this.ctx.stage.cacheTime, this.stageImData.main); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this._setReportMemoryCache(stageImTzBills, tid, sid, this.ctx.stage.cacheTime, this.stageImData.bills); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this._setReportMemoryCache(stageImTz, tid, sid, this.ctx.stage.cacheTime, this.stageImData.main, stageImVersion); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this._setReportMemoryCache(stageImTzBills, tid, sid, this.ctx.stage.cacheTime, this.stageImData.bills, stageImVersion); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this._setReportMemoryCache(stageImZl, tid, sid, this.ctx.stage.cacheTime, this.stageImData.main); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this._setReportMemoryCache(stageImZl, tid, sid, this.ctx.stage.cacheTime, this.stageImData.main, stageImVersion); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -127,7 +128,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getStageImTzData(tid, sid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime, stageImVersion); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (cache) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // console.log('cache'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return cache; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -152,7 +153,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getStageImTzBillsData(tid, sid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const cache = await this._getReportMemoryCache('mem_stage_im_tz_bills', tid, sid, this.ctx.stage.cacheTime, stageImVersion); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (cache) return cache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!this.stageImData) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -173,7 +174,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getStageImZlData(tid, sid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const cache = await this._getReportMemoryCache('mem_stage_im_zl', tid, sid, this.ctx.stage.cacheTime, stageImVersion); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (cache) return cache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.stageImData = {}; 
			 |