ruifeng_liu 3 лет назад
Родитель
Сommit
1215dc0453
3 измененных файлов с 28 добавлено и 6 удалено
  1. 1 1
      app.js
  2. 27 2
      app/service/patent/patentinfo.js
  3. 0 3
      app/service/patent/patentwarning.js

+ 1 - 1
app.js

@@ -9,7 +9,7 @@ class AppBootHook {
     const ctx = await this.app.createAnonymousContext();
     // 检查种子
     // await ctx.service.install.index();
-    // await ctx.service.util.rabbitMq.mission();
+    await ctx.service.util.rabbitMq.mission();
   }
 
 }

+ 27 - 2
app/service/patent/patentinfo.js

@@ -111,7 +111,7 @@ class PatentinfoService extends CrudService {
         if (row) return { row, imageId };
       })
     );
-    sheet.eachRow((row, rindex) => {
+    sheet.eachRow(async (row, rindex) => {
       if (rindex !== 1) {
         // 组织数据,图片的索引和行索引不一致,准确的说是:图片索引比行索引少1
         // 原因:图片在工作簿中获取,按照1,2,3...顺序排序,但是行的第一行是表头(当前文件),所以当前行数需要减掉表头那一行
@@ -122,13 +122,22 @@ class PatentinfoService extends CrudService {
             url: this.turnImageToBase64(workbook.getImage(imgid.imageId)),
           });
         }
+        let inventor = row.getCell(6).value || undefined;
+        if (inventor) {
+          let arr = inventor.split(';');
+          arr = arr.map(i => _.trim(i));
+          const nameList = await this.toGetUser(arr);
+          if (nameList && nameList.length > 0) inventor = nameList;
+          else inventor = undefined;
+        }
+
         const create_number = row.getCell(2).value || undefined,
           create_date =
             moment(row.getCell(3).value).format('YYYY-MM-DD') || undefined,
           success_number = row.getCell(4).value || undefined,
           success_date =
             moment(row.getCell(5).value).format('YYYY-MM-DD') || undefined,
-          inventor = row.getCell(6).value || undefined,
+          // inventor = row.getCell(6).value || undefined,
           agent = row.getCell(7).value || undefined,
           agent_personal = row.getCell(8).value || undefined,
           abstract = row.getCell(9).value || undefined,
@@ -510,6 +519,22 @@ class PatentinfoService extends CrudService {
     const obj = { $gte: start, $lte: end };
     return obj;
   }
+
+  /**
+   * 根据人名数组查询每个人的数据.组织数据返回
+   * @param {Array[String]} nameList 名单
+   */
+  async toGetUser(nameList) {
+    const res = await this.personalModel.find({ name: { $in: nameList } });
+    const result = [];
+    if (res && res.length > 0) {
+      for (const i of res) {
+        const { _id: id, name } = i;
+        result.push({ id, name });
+      }
+    }
+    return result;
+  }
 }
 
 module.exports = PatentinfoService;

+ 0 - 3
app/service/patent/patentwarning.js

@@ -3,14 +3,12 @@ const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
 const { ObjectId } = require('mongoose').Types;
 const _ = require('lodash');
-const assert = require('assert');
 const compressing = require('compressing');
 const { sep } = require('path');
 const path = require('path');
 const fs = require('fs');
 const encoding = require('encoding'); // 编码转换
 const fxp = require('fast-xml-parser'); // xml转换
-const mime = require('mime-types'); // 任意类型转换
 // 专利运营专利申请预警表
 class PatentwarningService extends CrudService {
   constructor(ctx) {
@@ -98,7 +96,6 @@ class PatentwarningService extends CrudService {
         continue;
         // throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未通过申请号找到指定专利');
       }
-      console.log(result);
       let warningData;
       try {
         warningData = await this.getWarningData(result);