lrf 2 年之前
父节点
当前提交
3f9241b61b
共有 1 个文件被更改,包括 4 次插入22 次删除
  1. 4 22
      app/service/patent/patentwarning.js

+ 4 - 22
app/service/patent/patentwarning.js

@@ -38,6 +38,7 @@ class PatentwarningService extends CrudService {
     const tempDirRootPath = `${uncompressFilePath}${sep}`;
     const tempDir = await fs.readdirSync(tempDirRootPath);
     const errorList = [];
+    let throwData = [];
     for (const tempDirPath of tempDir) {
       if (tempDirPath.includes('.zip')) continue;
       // const thisDirPath = `${tempDirRootPath}${sep}${tempDirPath}`;
@@ -106,13 +107,6 @@ class PatentwarningService extends CrudService {
           // throw new BusinessError(ErrorCode.SERVICE_FAULT, '查询专利信息失败');
         }
 
-        // 找不到就算了,弹回去了
-        // if (!result || !_.get(result, 'patent')) {
-        //   errorList.push({ key: patentNumber, word: '未通过 申请号 或 专利名称 找到指定专利' });
-        //   continue;
-        //   // throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未通过申请号找到指定专利');
-        // }
-
         // 2022-09-02 数组处理模式 ↑
         const patents = _.get(result, 'patent');
         if (!patents || patents.length <= 0) {
@@ -120,9 +114,6 @@ class PatentwarningService extends CrudService {
           continue;
         }
 
-        // const patent = _.get(result, 'patent');
-        const needChange = _.get(result, 'needChange');
-        const create_number = _.get(result, 'create_number');
         for (const patent of patents) {
           // 2022-09-02 原处理进入循环中处理
           let warningData;
@@ -142,17 +133,8 @@ class PatentwarningService extends CrudService {
               continue;
             }
           }
-
-          // 查看是否需要更改申请号
-          // if (needChange) {
-          //   try {
-          //     await this.patentApply.updateOne({ _id: patent._id }, { create_number });
-          //   } catch (error) {
-          //     // errorList.push({ key: patentNumber, word: 'xml申请号同步至专利申请号失败' });
-          //     continue;
-          //   }
-          // }
         }
+        throwData = [...throwData, ...patents];
       } finally {
         try {
           await this.dirDelete(`${thisDirPath}`);
@@ -162,7 +144,8 @@ class PatentwarningService extends CrudService {
       }
     }
     if (errorList.length > 0) return errorList;
-    return 'ok';
+    return throwData;
+    // return 'ok';
   }
 
   /**
@@ -293,7 +276,6 @@ class PatentwarningService extends CrudService {
     const listPA = await this.patentApply.find({ $or: [{ create_number }, { name }] });
     for (const i of listPA) {
       const { create_number: ocn, _id } = i;
-      console.log(ocn, create_number);
       // create_number 不一致,就去更改
       if (ocn !== create_number) await this.patentApply.updateOne({ _id }, { create_number });
     }