Bläddra i källkod

patentInfo导入修改

ruifeng_liu 3 år sedan
förälder
incheckning
5a2418276d
1 ändrade filer med 16 tillägg och 10 borttagningar
  1. 16 10
      app/service/patent/patentinfo.js

+ 16 - 10
app/service/patent/patentinfo.js

@@ -122,14 +122,14 @@ 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;
-        }
+        // 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 =
@@ -228,10 +228,16 @@ class PatentinfoService extends CrudService {
       const { inventor } = i;
       let midNameList = inventor.split(/[,;/]/);
       midNameList = midNameList.map(i => _.trim(i));
-      if (!_.isArray(i.user_id)) i.user_id = [];
+      const iList = [];
+      if (!_.isArray(i.user_id)) i.inventor = iList;
       for (const name of midNameList) {
         const rList = nList.filter(f => f.name === name);
-        i.user_id = [ ...i.user_id, ...rList.map(i => i._id) ];
+        if (rList && rList.length > 0) {
+          for (const r of rList) {
+            iList.push({ id: r._id, name: r.name });
+          }
+        }
+        // i.user_id = [ ...i.user_id, ...rList.map(i => i._id) ];
       }
     }
     await this.model.insertMany(arr);