Browse Source

修改检测文件

ruifeng_liu 3 years ago
parent
commit
50de85e74c
2 changed files with 14 additions and 17 deletions
  1. 7 10
      app/service/patent/patentwarning.js
  2. 7 7
      config/config.default.js

+ 7 - 10
app/service/patent/patentwarning.js

@@ -27,7 +27,7 @@ class PatentwarningService extends CrudService {
     const arr = fileFullName.split('.');
     const ext = _.last(arr);
     const fileName = _.head(arr);
-    const uncompressFilePath = `${this.import_root_path}${sep}`;
+    const uncompressFilePath = `${this.import_root_path}${sep}temp`;
     if (ext !== 'zip') {
       throw new BusinessError(ErrorCode.FILE_FAULT, '只接收压缩格式为zip的压缩包');
     }
@@ -76,8 +76,7 @@ class PatentwarningService extends CrudService {
     let lastResult;
     if (tifPaths && tifPaths.length > 0) lastResult = await this.toUploadTif(warningData, tifPaths);
     if (lastResult) {
-      console.log('to delete temp');
-      await this.dirDelete(`${uncompressFilePath}${fileName}`);
+      await this.dirDelete(`${uncompressFilePath}`);
     }
     return 'ok';
   }
@@ -123,7 +122,6 @@ class PatentwarningService extends CrudService {
       i.file_url = filePaths;
     }
     const res = await this.model.insertMany(data);
-    console.log('add finish');
     return res;
 
   }
@@ -213,20 +211,19 @@ class PatentwarningService extends CrudService {
    * 找到深层的tif和xml
    * 因为命名方式都是以文件名,之后tif的文件夹也在深层fileName.套娃且文件名都是fileName
    * @param {String} uri temp路径
-   * @param {String} fileName 文件名
    */
-  async findFileNameLoop(uri, fileName) {
-    const filePath = `${_.trimEnd(uri, sep)}${sep}${fileName}`;
+  async findFileNameLoop(uri) {
+    const filePath = `${_.trimEnd(uri, sep)}${sep}`;
     if (!fs.existsSync(filePath)) {
       return [];
     }
     const files = fs.readdirSync(filePath);
     let result = [];
     for (const file of files) {
-      const curPath = `${_.trimEnd(filePath)}${sep}${file}`;
+      const curPath = `${filePath}${file}`;
       if (fs.statSync(curPath).isDirectory()) {
-        const res = await this.findFileNameLoop(curPath, file);
-        result.push(...res);
+        const arr = await this.findFileNameLoop(curPath);
+        result.push(...arr);
       } else {
         result.push(curPath);
       }

+ 7 - 7
config/config.default.js

@@ -39,11 +39,11 @@ module.exports = appInfo => {
   config.mongoose = {
     url: `mongodb://localhost:27017/${config.dbName}`,
     options: {
-      user: 'admin',
-      pass: 'admin',
-      authSource: 'admin',
-      useNewUrlParser: true,
-      useCreateIndex: true,
+      // user: 'admin',
+      // pass: 'admin',
+      // authSource: 'admin',
+      // useNewUrlParser: true,
+      // useCreateIndex: true,
     },
   };
 
@@ -77,8 +77,8 @@ module.exports = appInfo => {
     domain: 'http://broadcast.waityou24.cn',
   };
   config.import = {
-    // root_path: 'E:\\exportFile',
-    root_path: 'D:\\free\\workspace\\server\\service-file\\upload',
+    root_path: 'E:\\exportFile',
+    // root_path: 'D:\\free\\workspace\\server\\service-file\\upload',
   };
   config.project = {
     mission: 'http://127.0.0.1:4001',