Browse Source

1. 日志,记录报表详细
2. 报表,加载水印调整

MaiXinRong 1 year ago
parent
commit
b343006ae0

+ 2 - 5
app/controller/report_controller.js

@@ -1612,7 +1612,6 @@ async function encodeDummySignatureDataUri(pageRst, baseDir) {
 }
 
 async function getWatermarkPicData(pageRst, baseDir) {
-    let rst = '';
     if (pageRst) {
         for (const page of pageRst.items) {
             for (const signature of page[JV.PROP_WATERMARK_CELLS]) {
@@ -1623,8 +1622,7 @@ async function getWatermarkPicData(pageRst, baseDir) {
                         if (res) {
                             const bData = fs.readFileSync(filePath);
                             const base64Str = bData.toString('base64');
-                            rst = 'data:image/png;base64,' + base64Str;
-                            break;
+                            return 'data:image/png;base64,' + base64Str;
                         } else {
                             console.log('文件不存在:' + filePath);
                         }
@@ -1632,11 +1630,10 @@ async function getWatermarkPicData(pageRst, baseDir) {
                         console.error(err);
                     }
                 }
-                if (rst !== null) break;
             }
         }
     }
-    return rst;
+    return '';
 }
 
 function mergeTextSignature(isTxtSignature, status, pageData, singleRoleRel, rpt_ids, stgAudit, stageList, closeArchiveSignature = false, isArchive = false) {

+ 1 - 1
app/middleware/auto_logger.js

@@ -44,7 +44,7 @@ module.exports = options => {
             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)}%`
             });
-            yield this.service.globalLog.requestLog();
+            yield this.service.globalLog.requestLog(this.request.body.data);
         }
         yield next;
     };

+ 18 - 0
app/service/global_log.js

@@ -21,6 +21,23 @@ module.exports = app => {
             this.tableName = 'global_log';
         }
 
+        getRptTplInfo(data) {
+            if (!data || !data.params) return '';
+
+            try {
+                const params = JSON.parse(data.params);
+                return JSON.stringify({ rpt_tpl_id: params.rpt_tpl_id, project_id: params.project_id, tender_id: params.tender_id, stage_id: params.stage_id });
+            } catch(err) {
+                return '';
+            }
+        }
+
+        getMemo(url, data) {
+            if (url.indexOf('report_api/getReport') === -1) return '';
+
+            return this.getRptTplInfo(data);
+        }
+
         async requestLog() {
             if (!this.ctx.session || !this.ctx.session.sessionProject || !this.ctx.session.sessionUser) return;
 
@@ -32,6 +49,7 @@ module.exports = app => {
                 user_name: this.ctx.session.sessionUser.name,
                 url: this.ctx.url,
                 method: this.ctx.method,
+                memo: this.getMemo(this.ctx.url, this.ctx.request.body),
             });
         }
 

+ 1 - 4
app/service/report_memory.js

@@ -908,7 +908,7 @@ module.exports = app => {
                 const decimal = this.ctx.tender.info.decimal, ctx = this.ctx;
                 const where = { tid, valid: 1 };
                 if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.flow.status.checked;
-                const change = await this.ctx.service.change.getAllDataByCondition({ where, orders: [['in_time', 'desc']] });
+                const change = await this.ctx.service.change.getAllDataByCondition({ where, orders: [['code', 'asc']] });
                 for (const c of change) {
                     const types = ctx.helper._.map(c.type.split(','), function (t) {
                         return self._getChangeConstName(changeConst.type, ctx.helper._.toInteger(t));
@@ -946,9 +946,6 @@ module.exports = app => {
                     }
                 }
 
-                change.sort(function (a, b) {
-                    return a.code.localeCompare(b.code);
-                });
                 changeBills.sort(function (a, b) {
                     const aCIndex = change.findIndex(function (c) {
                         return c.cid === a.cid;

+ 4 - 1
sql/update.sql

@@ -36,5 +36,8 @@ ADD COLUMN `audit_order`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审批
 ALTER TABLE `zh_change_plan`
 ADD COLUMN `sp_group` int(11) NULL DEFAULT 0 COMMENT '固定审批组id' AFTER `decimal`;
 
-ALTER TABLE `calculation`.`zh_stage`
+ALTER TABLE `zh_stage`
 ADD COLUMN `final_auditor_str` varchar(50) NOT NULL DEFAULT '' COMMENT '终审人相关' AFTER `pre_negative_qc_tp`;
+
+ALTER TABLE `zh_global_log`
+ADD COLUMN `memo` varchar(255) NOT NULL DEFAULT '' AFTER `run_time`;