MaiXinRong 3 år sedan
förälder
incheckning
5aac812a31

+ 0 - 1
app/extend/helper.js

@@ -282,7 +282,6 @@ module.exports = {
                 data,
                 dataType,
             }) : await this.ctx.curl(url);
-            // console.log(response);
             if (response.status !== 200) {
                 if (count > 0) {
                     count = count - 1;

+ 0 - 1
app/lib/sum_load.js

@@ -542,7 +542,6 @@ class sumLoad {
             const curStageChange = stage.status === auditConst.stage.status.checked
                 ? await this.ctx.service.stageChangeFinal.getSumLoadFinalData(stage.id)
                 : await this.ctx.service.stageChange.getSumLoadFinalData(stage.id);
-            console.log(curStageChange);
             this._loadCurStageAndChange(billsData, curStageData, curStageChange);
             const billsTree = new Ledger.billsTree(this.ctx, {
                 id: 'ledger_id',

+ 8 - 2
app/middleware/auto_finish_logger.js

@@ -7,6 +7,7 @@
  * @date 2017/10/30
  * @version
  */
+const os = require('os');
 
 module.exports = options => {
     return async function autoFinishLogger(ctx, next) {
@@ -15,11 +16,16 @@ module.exports = options => {
         if (ctx.url.indexOf('/public/') === 0) return;
 
         const responseTime = new Date();
-        const runTime = responseTime.getTime() - ctx.logTime.getTime();
+        const runTime = responseTime.getTime() - ctx.logInfo.time.getTime();
         let logData;
         if (ctx.session && ctx.session.sessionUser) {
+            const cpus = os.cpus();
+            const endCpus = cpus.map(x => {
+                return `${((1-x.times.idle/(x.times.idle+x.times.user+x.times.nice+x.times.sys+x.times.irq))*100).toFixed(2)}%`
+            });
             logData = {
-                requestTime: ctx.logTime, responseTime, runTime,
+                requestTime: ctx.logInfo.time, responseTime, runTime,
+                beginCpus: ctx.logInfo.cpus, endCpus,
                 user: ctx.session.sessionUser.accountId, userName: ctx.session.sessionUser.name, loginType: ctx.session.sessionUser.loginType,
                 pCode: ctx.session.sessionProject.code,
                 data: ctx.request.body,

+ 6 - 1
app/middleware/auto_logger.js

@@ -7,6 +7,7 @@
  * @date 2017/10/30
  * @version
  */
+const os = require('os');
 
 module.exports = options => {
     return function* autoLogger(next) {
@@ -36,7 +37,11 @@ module.exports = options => {
             };
             bLogger.info(JSON.stringify(logData));
         }
-        this.logTime = new Date();
+        this.logInfo = { time: new Date() };
+        const cpus = os.cpus();
+        this.logInfo.cpus = cpus.map(x => {
+            return `${((1-x.times.idle/(x.times.idle+x.times.user+x.times.nice+x.times.sys+x.times.irq))*100).toFixed(2)}%`
+        });
 
         // 自动记录log的action
         // const autoLogAction = ['save', 'delete'];

+ 0 - 1
app/service/stage_change.js

@@ -380,7 +380,6 @@ module.exports = app => {
                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
                 '  Where cf.sid = ?';
             const result = await this.db.query(sql, [sid]);
-            console.log(this.db.format(sql, [sid]));
             return this.ctx.helper.filterLastestData(result, ['lid', 'pid', 'cbid'], 'stimes', 'sorder');
         }
 

+ 0 - 2
db_script/depart-database-table.js

@@ -284,7 +284,6 @@ const generateAllCreateSql = function () {
 // generateAllCreateSql();
 
 // const tenders = querySql('Select * From zh_tender');
-// console.log(tenders.length);
 //
 const log = [];
 const depart = async function (info) {
@@ -293,7 +292,6 @@ const depart = async function (info) {
         const sql = 'Insert Into ' + info.table + '_' + i +
             '  Select * From ' + info.table +
             '  Where ' + info.relaId + ' % ' + info.count + ' = ' + i;
-        console.log(sql);
         log.push(sql);
         await querySql(sql);
     }

+ 0 - 1
test/app/lib/rpt_data_analysis.test.js

@@ -202,7 +202,6 @@ describe('test/app/service/report_memory.test.js', () => {
             mem_stage_im_zl: ['lid', 'code'],
         });
         reportDataAnalysis.analysisObj.loadCooperationData.fun(ctx, data, [], {table: 'mem_stage_im_zl', co_sign: [0, 1, 2, 3]}, null);
-        console.log(data.mem_stage_im_zl);
     });
     it('test join', function* () {
         const ctx = app.mockContext(mockData);