|
@@ -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);
|
|
|
}
|