Browse Source

上传模板文件,文件名加事件戳存储

MaiXinRong 7 years ago
parent
commit
a201f0a37a
3 changed files with 6 additions and 3 deletions
  1. 4 1
      app/controller/template_controller.js
  2. 1 0
      app/service/match.js
  3. 1 2
      app/service/template_node.js

+ 4 - 1
app/controller/template_controller.js

@@ -9,6 +9,7 @@
  */
 
 // excel解析
+const path = require('path');
 const excel = require('node-xlsx');
 const sendToWormhole = require('stream-wormhole');
 const paramConst = require('../const/template_param');
@@ -55,7 +56,9 @@ module.exports = app => {
             let stream;
             try {
                 stream = await ctx.getFileStream();
-                const fileName = this.app.baseDir + '/app/public/template/uploads/' + stream.filename;
+                const create_time = Date.parse( new Date())/1000;
+                const fileInfo = path.parse(stream.filename);
+                const fileName = this.app.baseDir + '/app/public/template/uploads/' + 'template' + create_time + fileInfo.ext;
                 // 保存文件
                 await ctx.helper.saveStreamFile(stream, fileName);
                 // 读取文件

+ 1 - 0
app/service/match.js

@@ -22,6 +22,7 @@ module.exports = app => {
          */
         _init(bills) {
             this.bills = bills instanceof Array ? bills : [bills];
+            this.bills[0].match_node = null;
             this.fixedBills = this.bills.filter(function (b) {
                 return b.n_id < 100;
             });

+ 1 - 2
app/service/template_node.js

@@ -164,7 +164,7 @@ module.exports = app => {
                         unit2: row[3],
                         node_id: nodes.length,
                         index_id: indexes.length + 1,
-                        rule: row[9]
+                        rule: row[9] ? row[9] : '',
                     };
                     if (row[4] === '√') {
                         index.index_type = 1;
@@ -194,7 +194,6 @@ module.exports = app => {
             try {
                 const nodes = [], indexes = [], params = [];
                 this._loadDefaultParam(params, paramConst.defaultGlobalParams, 0);
-                console.log(params);
                 for (const sheet of excelSheets) {
                     this._parseSheetData(sheet, nodes, indexes, params);
                 }