Browse Source

1. 指标匹配改进
2. 更新配置

MaiXinRong 7 years ago
parent
commit
beb2ef94b7

+ 6 - 2
app/service/match.js

@@ -53,10 +53,14 @@ module.exports = app => {
         _matchCode(code, rule) {
             const codeParts = code.split('-');
             const ruleParts = rule.split('-');
-            const numReg = /(^[0-9]+$)/;
+            const numReg = /(^[0-9]+$)/, charReg = /(^[a-z]+$)/i;
             if (codeParts.length !== ruleParts.length) { return false; }
             for (let i = 0, iLen = codeParts.length; i < iLen; i++) {
-                if (numReg.test(ruleParts[i]) && ruleParts[i] !== codeParts[i]) {
+                if (numReg.test(ruleParts[i])) {
+                    if (ruleParts[i] !== codeParts[i]) {
+                        return false;
+                    }
+                } else if (!charReg.test(ruleParts[i])) {
                     return false;
                 }
             }

+ 13 - 0
app/service/tender_param.js

@@ -34,8 +34,15 @@ module.exports = app => {
          * @private
          */
         async _calculateNodeIndex(transaction, condition, globalParams, newParam, gRelaParam) {
+            // let time1 = new Date();
             const nodeParams = await this.ctx.service.tenderParam.getAllDataByCondition({where: condition});
+            // await this.ctx.service.log.addLog('node' + this.serialNo + ':select tenderParam', new Date() - time1);
+            //
+            // time1 = new Date();
             const nodeIndexes = await this.ctx.service.tenderIndex.getAllDataByCondition({where: condition});
+            // await this.ctx.service.log.addLog('node' + this.serialNo + ':select tenderIndex', new Date() - time1);
+            //
+            // time1 = new Date();
             let relaParam;
             if (newParam) {
                 for (const np of nodeParams) {
@@ -56,6 +63,7 @@ module.exports = app => {
                     value: u.value,
                 });
             }
+            // await this.ctx.service.log.addLog('node' + this.serialNo + ':update tenderIndex', new Date() - time1);
         }
 
         /**
@@ -83,7 +91,12 @@ module.exports = app => {
             const nodes = await this.ctx.service.tenderNode.getAllDataByCondition({where: condition});
             const indexes = await this.ctx.service.tenderIndex.getAllDataByCondition({where: condition});
             const params = await this.ctx.service.tenderParam.getAllDataByCondition({where: condition});
+
+            // this.serialNo = 1;
             for (const node of nodes) {
+                // condition.node_id = node.node_id;
+                // await this._calculateNodeIndex(transaction, condition, globalParams);
+                // this.serialNo += 1;
                 node.indexes = indexes.filter(function (a) {
                     return a.node_id === node.node_id;
                 });

+ 1 - 1
config/config.default.js

@@ -17,7 +17,7 @@ module.exports = appInfo => {
             // 用户名
             user: 'root',
             // 密码
-            password: 'admin',
+            password: 'root',
             // 数据库名
             database: 'index_sys',
         },

+ 1 - 1
config/config.qa.js

@@ -11,7 +11,7 @@ module.exports = appInfo => {
     config.mysql = {
         client: {
             // host
-            host: '192.168.1.139',
+            host: '192.168.1.70',
             // 端口号
             port: '3306',
             // 用户名

+ 1 - 1
test/app/const/template_param.test.js

@@ -12,7 +12,7 @@ const { app, assert } = require('egg-mock/bootstrap');
 describe('test/app/const/template_param.test.js', () => {
     it('defaultGlobalParams', function* () {
         const ctx = app.mockContext();
-        assert(app.paramConst.defaultGlobalParams.length === 38);
+        assert(app.paramConst.defaultGlobalParams.length === 37);
     });
 
 });

+ 2 - 2
test/app/service/template_node.test.js

@@ -25,7 +25,7 @@ describe('test/app/service/template_node.test.js', () => {
 
         assert(nodes.length === 5);
         assert(indexes.length === 42);
-        assert(params.length === 64);
+        assert(params.length === 65);
     });
     it('_parseSheetData test xlsx File', function () {
         const ctx = app.mockContext();
@@ -39,7 +39,7 @@ describe('test/app/service/template_node.test.js', () => {
 
         assert(nodes.length === 3);
         assert(indexes.length === 12);
-        assert(params.length === 26);
+        assert(params.length === 27);
     });
 
     it('importData test xls File', function* () {