|
@@ -2,6 +2,7 @@
|
|
|
const { CrudService } = require('naf-framework-mongoose/lib/service');
|
|
|
const { BusinessError, ErrorCode } = require('naf-core').Error;
|
|
|
const { ObjectId } = require('mongoose').Types;
|
|
|
+const moment = require('moment');
|
|
|
const _ = require('lodash');
|
|
|
const compressing = require('compressing');
|
|
|
const { sep } = require('path');
|
|
@@ -58,10 +59,10 @@ class PatentwarningService extends CrudService {
|
|
|
continue;
|
|
|
}
|
|
|
// 2021-10-16 修改: 取出第一层的xml文件,即:路径最短的;除文件名外,字符串长度最小的
|
|
|
- let xmlPaths = filePaths.filter((f) => f.includes('.xml'));
|
|
|
+ let xmlPaths = filePaths.filter(f => f.includes('.xml'));
|
|
|
if (xmlPaths.length > 0) {
|
|
|
// 去掉文件名
|
|
|
- xmlPaths = xmlPaths.map((i) => {
|
|
|
+ xmlPaths = xmlPaths.map(i => {
|
|
|
const arr = i.split(sep);
|
|
|
arr.pop();
|
|
|
const obj = { dir: arr.join(sep), fullPath: i };
|
|
@@ -124,7 +125,7 @@ class PatentwarningService extends CrudService {
|
|
|
continue;
|
|
|
// throw new BusinessError(ErrorCode.SERVICE_FAULT, '组织专利信息警告数据失败');
|
|
|
}
|
|
|
- const tifPaths = filePaths.filter((f) => f.includes('.tif'));
|
|
|
+ const tifPaths = filePaths.filter(f => f.includes('.tif'));
|
|
|
if (tifPaths && tifPaths.length > 0) {
|
|
|
try {
|
|
|
await this.toUploadTif(warningData, tifPaths);
|
|
@@ -143,7 +144,7 @@ class PatentwarningService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
// 2022-09-05 将错误信息添加到表中
|
|
|
- errorList = errorList.map((i) => ({ ...i, filepath: uri, time: moment().format('YYYY-MM-DD HH:mm:ss') }));
|
|
|
+ errorList = errorList.map(i => ({ ...i, filepath: uri, time: moment().format('YYYY-MM-DD HH:mm:ss') }));
|
|
|
await this.cpcErrorMsg.insertMany(errorList);
|
|
|
if (errorList.length > 0) return errorList;
|
|
|
return 'ok';
|
|
@@ -237,11 +238,11 @@ class PatentwarningService extends CrudService {
|
|
|
arr.push(obj);
|
|
|
}
|
|
|
// 2021-11-18 添加,user,mech,admin,agentmech是否存在,如果存在,也添加预警信息
|
|
|
- const list = ['user', 'mech', 'admin', 'agentmech'];
|
|
|
- const suffix = ['id', 'name'];
|
|
|
+ const list = [ 'user', 'mech', 'admin', 'agentmech' ];
|
|
|
+ const suffix = [ 'id', 'name' ];
|
|
|
for (const prefix of list) {
|
|
|
- const marr = suffix.map((i) => `${prefix}_${i}`);
|
|
|
- const r = marr.every((i) => _.get(patent, i));
|
|
|
+ const marr = suffix.map(i => `${prefix}_${i}`);
|
|
|
+ const r = marr.every(i => _.get(patent, i));
|
|
|
if (r) {
|
|
|
const obj = _.cloneDeep(object);
|
|
|
for (const key of suffix) {
|
|
@@ -271,7 +272,7 @@ class PatentwarningService extends CrudService {
|
|
|
arr.splice(arr.length - 1, 0, '.');
|
|
|
create_number = arr.join('');
|
|
|
let res;
|
|
|
- let needChange = false;
|
|
|
+ const needChange = false;
|
|
|
// 2022-09-02 改为多条数据查询,不再针对一个数据
|
|
|
// 1,名称相同,关联人不同:
|
|
|
const listPA = await this.patentApply.find({ $or: [{ create_number }, { name }] });
|
|
@@ -282,7 +283,7 @@ class PatentwarningService extends CrudService {
|
|
|
}
|
|
|
const listPI = await this.patentInfo.find({ $or: [{ create_number }, { name }] });
|
|
|
|
|
|
- res = [...listPA, ...listPI];
|
|
|
+ res = [ ...listPA, ...listPI ];
|
|
|
const returnObject = {};
|
|
|
if (res.length > 0) {
|
|
|
returnObject.patent = JSON.parse(JSON.stringify(res));
|
|
@@ -353,7 +354,7 @@ class PatentwarningService extends CrudService {
|
|
|
result.push(curPath);
|
|
|
}
|
|
|
}
|
|
|
- result = result.filter((f) => f.includes('.tif') || f.includes('.xml'));
|
|
|
+ result = result.filter(f => f.includes('.tif') || f.includes('.xml'));
|
|
|
return result;
|
|
|
}
|
|
|
|