|
@@ -15,6 +15,8 @@ class PatentinfoService extends CrudService {
|
|
constructor(ctx) {
|
|
constructor(ctx) {
|
|
super(ctx, 'patentinfo');
|
|
super(ctx, 'patentinfo');
|
|
this.model = this.ctx.model.Patent.Patentinfo;
|
|
this.model = this.ctx.model.Patent.Patentinfo;
|
|
|
|
+ this.personalModel = this.ctx.model.Personal;
|
|
|
|
+
|
|
this.root_path = _.get(this.ctx.app.config.export, 'root_path');
|
|
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 = 'E:\\exportFile\\';
|
|
this.file_type = '';
|
|
this.file_type = '';
|
|
@@ -53,8 +55,6 @@ class PatentinfoService extends CrudService {
|
|
if (code) {
|
|
if (code) {
|
|
const plist = await this.personalModel.find({ code });
|
|
const plist = await this.personalModel.find({ code });
|
|
ids = plist.map(i => i._id);
|
|
ids = plist.map(i => i._id);
|
|
- const olist = await this.organizationModel.find({ code });
|
|
|
|
- ids = [ ...ids, ...olist.map(i => i._id) ];
|
|
|
|
}
|
|
}
|
|
if (ids.length > 0) {
|
|
if (ids.length > 0) {
|
|
query.user_id = { $elemMatch: { $in: ids } };
|
|
query.user_id = { $elemMatch: { $in: ids } };
|
|
@@ -63,6 +63,18 @@ class PatentinfoService extends CrudService {
|
|
return query;
|
|
return query;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async queryByOrg({ id, skip = 0, limit = 0 }) {
|
|
|
|
+ assert(id, '缺少机构信息');
|
|
|
|
+ let pids = await this.personalModel.find({ pid: id }, { _id: 1 });
|
|
|
|
+ if (pids.length <= 0) return { data: [], total: 0 };
|
|
|
|
+ pids = pids.map(i => i._id);
|
|
|
|
+ const query = { $elemMatch: { $in: pids } };
|
|
|
|
+ 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 };
|
|
|
|
+ }
|
|
|
|
+
|
|
async toImport({ uri, origin, user_id }) {
|
|
async toImport({ uri, origin, user_id }) {
|
|
assert(uri, '未获取到文件地址');
|
|
assert(uri, '未获取到文件地址');
|
|
const file = await this.ctx.curl(`${this.domain}${uri}`);
|
|
const file = await this.ctx.curl(`${this.domain}${uri}`);
|