|
@@ -20,7 +20,9 @@ class PatentinfoService extends CrudService {
|
|
|
this.organizationModel = this.ctx.model.Organization;
|
|
|
|
|
|
this.root_path = _.get(this.ctx.app.config.export, 'root_path');
|
|
|
- if (process.env.NODE_ENV === 'development') { this.root_path = 'E:\\exportFile\\'; }
|
|
|
+ if (process.env.NODE_ENV === 'development') {
|
|
|
+ this.root_path = 'S:\\workspace\\exportFile\\';
|
|
|
+ }
|
|
|
this.file_type = '';
|
|
|
if (!fs.existsSync(`${this.root_path}${this.file_type}`)) {
|
|
|
// 如果不存在文件夹,就创建
|
|
@@ -28,18 +30,15 @@ class PatentinfoService extends CrudService {
|
|
|
}
|
|
|
this.excel_path = `${sep}excel${sep}`;
|
|
|
this.domain = 'http://127.0.0.1';
|
|
|
- if (process.env.NODE_ENV === 'development') { this.domain = 'http://127.0.0.1:9999'; }
|
|
|
+ if (process.env.NODE_ENV === 'development') {
|
|
|
+ this.domain = 'http://127.0.0.1:9999';
|
|
|
+ }
|
|
|
this.export_limit = 50;
|
|
|
}
|
|
|
|
|
|
async query(query, { skip = 0, limit = 0 }) {
|
|
|
const newquery = await this.resetCode(query);
|
|
|
- console.log(newquery);
|
|
|
- const res = await this.model
|
|
|
- .find(newquery)
|
|
|
- .skip(parseInt(skip))
|
|
|
- .limit(parseInt(limit))
|
|
|
- .sort({ 'meta.createdAt': -1 });
|
|
|
+ const res = await this.model.find(newquery).skip(parseInt(skip)).limit(parseInt(limit)).sort({ 'meta.createdAt': -1 });
|
|
|
return res;
|
|
|
}
|
|
|
async count(query) {
|
|
@@ -51,19 +50,32 @@ class PatentinfoService extends CrudService {
|
|
|
async resetCode(query) {
|
|
|
let newquery = _.cloneDeep(query);
|
|
|
newquery = this.ctx.service.util.util.dealQuery(newquery);
|
|
|
- const { type } = newquery;
|
|
|
- if (type === 'else') {
|
|
|
- newquery.$and = [
|
|
|
- { type: { $ne: '发明申请' } },
|
|
|
- { type: { $ne: '实用新型' } },
|
|
|
- ];
|
|
|
- delete newquery.type;
|
|
|
+ if (Object.keys(newquery).length <= 0) return newquery;
|
|
|
+ // 2021-11-03 没有其他的类型,不需要该查询条件
|
|
|
+ // const { type } = newquery;
|
|
|
+ // if (type === 'else') {
|
|
|
+ // newquery.$and = [
|
|
|
+ // { type: { $ne: '发明申请' } },
|
|
|
+ // { type: { $ne: '实用新型' } },
|
|
|
+ // ];
|
|
|
+ // delete newquery.type;
|
|
|
+ // }
|
|
|
+ // 2021-11-03 添加新查询条件:
|
|
|
+ /**
|
|
|
+ * {String} 作为申请号(create_number)字段的 第5位 字符串的查询条件
|
|
|
+ */
|
|
|
+ const apply_type = _.get(newquery, 'apply_type');
|
|
|
+ if (apply_type) {
|
|
|
+ const str = `^\\w{4}${apply_type}`;
|
|
|
+ const reg = new RegExp(str);
|
|
|
+ newquery.create_number = reg;
|
|
|
+ delete newquery.apply_type;
|
|
|
}
|
|
|
const { code, user_id } = newquery;
|
|
|
let ids = [];
|
|
|
if (code) {
|
|
|
const plist = await this.personalModel.find({ code });
|
|
|
- ids = plist.map(i => i._id);
|
|
|
+ ids = plist.map((i) => i._id);
|
|
|
if (ids.length > 0) {
|
|
|
newquery['inventor.user_id'] = { $in: ids };
|
|
|
delete newquery.code;
|
|
@@ -79,15 +91,11 @@ class PatentinfoService extends CrudService {
|
|
|
assert(code, '缺少机构信息');
|
|
|
let pids = await this.personalModel.find({ code }, { _id: 1 });
|
|
|
if (pids.length <= 0) return { data: [], total: 0 };
|
|
|
- pids = pids.map(i => i._id);
|
|
|
+ pids = pids.map((i) => i._id);
|
|
|
const query = { 'inventor.user_id': { $in: pids } };
|
|
|
if (status) query.status = status;
|
|
|
if (term) query.term = term;
|
|
|
- const data = await this.model
|
|
|
- .find(query)
|
|
|
- .skip(parseInt(skip))
|
|
|
- .limit(parseInt(limit))
|
|
|
- .sort({ 'meta.createdAt': -1 });
|
|
|
+ const data = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit)).sort({ 'meta.createdAt': -1 });
|
|
|
const total = await this.model.count(query);
|
|
|
return { data, total };
|
|
|
}
|
|
@@ -105,7 +113,7 @@ class PatentinfoService extends CrudService {
|
|
|
const allNotice = [];
|
|
|
const sheetImageInfo = sheet.getImages();
|
|
|
const imgids = _.compact(
|
|
|
- sheetImageInfo.map(i => {
|
|
|
+ sheetImageInfo.map((i) => {
|
|
|
const { imageId, range } = i;
|
|
|
const row = _.get(range, 'tl.nativeRow');
|
|
|
if (row) return { row, imageId };
|
|
@@ -115,7 +123,7 @@ class PatentinfoService extends CrudService {
|
|
|
if (rindex !== 1) {
|
|
|
// 组织数据,图片的索引和行索引不一致,准确的说是:图片索引比行索引少1
|
|
|
// 原因:图片在工作簿中获取,按照1,2,3...顺序排序,但是行的第一行是表头(当前文件),所以当前行数需要减掉表头那一行
|
|
|
- const imgid = imgids.find(f => f.row === rindex - 1);
|
|
|
+ const imgid = imgids.find((f) => f.row === rindex - 1);
|
|
|
const img_url = [];
|
|
|
if (imgid) {
|
|
|
img_url.push({
|
|
@@ -124,11 +132,9 @@ class PatentinfoService extends CrudService {
|
|
|
}
|
|
|
|
|
|
const create_number = row.getCell(2).value || undefined,
|
|
|
- create_date =
|
|
|
- moment(row.getCell(3).value).format('YYYY-MM-DD') || undefined,
|
|
|
+ create_date = moment(row.getCell(3).value).format('YYYY-MM-DD') || undefined,
|
|
|
success_number = row.getCell(4).value || undefined,
|
|
|
- success_date =
|
|
|
- moment(row.getCell(5).value).format('YYYY-MM-DD') || undefined,
|
|
|
+ success_date = moment(row.getCell(5).value).format('YYYY-MM-DD') || undefined,
|
|
|
inventor = row.getCell(6).value || undefined,
|
|
|
agent = row.getCell(7).value || undefined,
|
|
|
agent_personal = row.getCell(8).value || undefined,
|
|
@@ -144,20 +150,15 @@ class PatentinfoService extends CrudService {
|
|
|
ipc_type = row.getCell(17).value || undefined,
|
|
|
onlegal_status = row.getCell(18).value || undefined,
|
|
|
legal_status = row.getCell(19).value || undefined,
|
|
|
- law_date =
|
|
|
- moment(row.getCell(20).value).format('YYYY-MM-DD') || undefined,
|
|
|
+ law_date = moment(row.getCell(20).value).format('YYYY-MM-DD') || undefined,
|
|
|
on_obligee = row.getCell(21).value || undefined,
|
|
|
apply_address = row.getCell(22).value || undefined,
|
|
|
apply_other = row.getCell(23).value || undefined,
|
|
|
law_num = row.getCell(24).value || undefined,
|
|
|
- first_opendate =
|
|
|
- moment(row.getCell(25).value).format('YYYY-MM-DD') || undefined,
|
|
|
- empower_date =
|
|
|
- moment(row.getCell(26).value).format('YYYY-MM-DD') || undefined,
|
|
|
- lose_date =
|
|
|
- moment(row.getCell(27).value).format('YYYY-MM-DD') || undefined,
|
|
|
- examine_date =
|
|
|
- moment(row.getCell(28).value).format('YYYY-MM-DD') || undefined,
|
|
|
+ first_opendate = moment(row.getCell(25).value).format('YYYY-MM-DD') || undefined,
|
|
|
+ empower_date = moment(row.getCell(26).value).format('YYYY-MM-DD') || undefined,
|
|
|
+ lose_date = moment(row.getCell(27).value).format('YYYY-MM-DD') || undefined,
|
|
|
+ examine_date = moment(row.getCell(28).value).format('YYYY-MM-DD') || undefined,
|
|
|
invention_design = row.getCell(29).value || undefined;
|
|
|
const obj = {
|
|
|
create_number,
|
|
@@ -209,21 +210,21 @@ class PatentinfoService extends CrudService {
|
|
|
for (const i of arr) {
|
|
|
const { inventor } = i;
|
|
|
const midList = inventor.split(/[,;/]/);
|
|
|
- nameList = [ ...nameList, ...midList ];
|
|
|
+ nameList = [...nameList, ...midList];
|
|
|
}
|
|
|
- nameList = nameList.map(i => _.trim(i));
|
|
|
+ nameList = nameList.map((i) => _.trim(i));
|
|
|
const l1 = await this.personalModel.find({ name: nameList });
|
|
|
const l2 = await this.organizationModel.find({ name: nameList });
|
|
|
// 查出来的所有人
|
|
|
- const nList = [ ...l1, ...l2 ];
|
|
|
+ const nList = [...l1, ...l2];
|
|
|
for (const i of arr) {
|
|
|
const { inventor } = i;
|
|
|
let midNameList = inventor.split(/[,;/]/);
|
|
|
- midNameList = midNameList.map(i => _.trim(i));
|
|
|
+ midNameList = midNameList.map((i) => _.trim(i));
|
|
|
const iList = [];
|
|
|
if (!_.isArray(i.user_id)) i.inventor = iList;
|
|
|
for (const name of midNameList) {
|
|
|
- const rList = nList.filter(f => f.name === name);
|
|
|
+ const rList = nList.filter((f) => f.name === name);
|
|
|
if (rList && rList.length > 0) {
|
|
|
for (const r of rList) {
|
|
|
iList.push({ user_id: r._id, name: r.name });
|
|
@@ -247,11 +248,7 @@ class PatentinfoService extends CrudService {
|
|
|
tenant: 'live',
|
|
|
};
|
|
|
try {
|
|
|
- await this.ctx.service.util.httpUtil.cpost(
|
|
|
- '/api/mission',
|
|
|
- 'mission',
|
|
|
- data
|
|
|
- );
|
|
|
+ await this.ctx.service.util.httpUtil.cpost('/api/mission', 'mission', data);
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
|
throw new BusinessError(ErrorCode.SERVICE_FAULT, '任务创建失败');
|
|
@@ -283,11 +280,7 @@ class PatentinfoService extends CrudService {
|
|
|
status: '1',
|
|
|
id: missionid,
|
|
|
};
|
|
|
- this.ctx.service.util.httpUtil.cpost(
|
|
|
- '/api/mission/progress',
|
|
|
- 'mission',
|
|
|
- data
|
|
|
- );
|
|
|
+ this.ctx.service.util.httpUtil.cpost('/api/mission/progress', 'mission', data);
|
|
|
} catch (error) {
|
|
|
this.logger.error(`任务id:${missionid},进度更新失败`);
|
|
|
}
|
|
@@ -298,11 +291,7 @@ class PatentinfoService extends CrudService {
|
|
|
status: '2',
|
|
|
uri: downloadPath,
|
|
|
};
|
|
|
- await this.ctx.service.util.httpUtil.cpost(
|
|
|
- `/api/mission/update/${missionid}`,
|
|
|
- 'mission',
|
|
|
- data
|
|
|
- );
|
|
|
+ await this.ctx.service.util.httpUtil.cpost(`/api/mission/update/${missionid}`, 'mission', data);
|
|
|
} catch (error) {
|
|
|
this.logger.error(`任务id:${missionid},已完成更新失败`);
|
|
|
}
|
|
@@ -440,7 +429,6 @@ class PatentinfoService extends CrudService {
|
|
|
{ header: '失效日', key: 'lose_date', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
|
|
|
{ header: '实际审查失效日', key: 'examine_date', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
|
|
|
{ header: '发明人(设计)其他', key: 'invention_design', width: 30, style: { alignment: { wrapText: true, vertical: 'middle', horizontal: 'center' } } },
|
|
|
-
|
|
|
];
|
|
|
return arr;
|
|
|
}
|
|
@@ -459,8 +447,7 @@ class PatentinfoService extends CrudService {
|
|
|
if (empower_sort === '0') {
|
|
|
sort = 'asc';
|
|
|
}
|
|
|
- const data = await this.model.find(newQuery).sort({ empower_date: sort }).skip(parseInt(skip))
|
|
|
- .limit(parseInt(limit));
|
|
|
+ const data = await this.model.find(newQuery).sort({ empower_date: sort }).skip(parseInt(skip)).limit(parseInt(limit));
|
|
|
const total = await this.model.count(newQuery);
|
|
|
return { data, total };
|
|
|
}
|
|
@@ -503,12 +490,11 @@ class PatentinfoService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
return queryObject;
|
|
|
-
|
|
|
}
|
|
|
async dealCode(code) {
|
|
|
let pids = await this.personalModel.find({ code }, { _id: 1 });
|
|
|
if (pids.length <= 0) return { data: [], total: 0 };
|
|
|
- pids = pids.map(i => i._id);
|
|
|
+ pids = pids.map((i) => i._id);
|
|
|
const query = { user_id: { $elemMatch: { $in: pids } } };
|
|
|
return query;
|
|
|
}
|