|
@@ -394,6 +394,7 @@ class IndexService extends CrudService {
|
|
|
as: 'report',
|
|
|
},
|
|
|
},
|
|
|
+ { $match: { 'report.0': { $exists: true } } },
|
|
|
{ $group: { _id: '', total: { $sum: 1 } } },
|
|
|
];
|
|
|
const r1 = await disclosure.aggregate(condition);
|
|
@@ -401,10 +402,21 @@ class IndexService extends CrudService {
|
|
|
const havehand = await disclosure.count({ user_id: ObjectId(id) });
|
|
|
const apply = { report, havehand };
|
|
|
// 发明,使用新型,其他
|
|
|
- const invent = await disclosure.count({ user_id: ObjectId(id), type: '发明' });
|
|
|
- const practical = await disclosure.count({ user_id: ObjectId(id), type: '使用新型' });
|
|
|
- const other = await disclosure.count({ user_id: ObjectId(id), $and: [{ type: { $ne: '使用新型' } }, { type: { $ne: '发明' } }] });
|
|
|
- const patent = { invent, practical, other };
|
|
|
+ let invent = 0,
|
|
|
+ practical = 0,
|
|
|
+ other = 0,
|
|
|
+ patent = {};
|
|
|
+ let user = await this.personalModel.findById(id);
|
|
|
+ if (!user) user = await this.organizationModel.findById(id);
|
|
|
+ if (user) {
|
|
|
+ const { name } = user;
|
|
|
+ const query = {};
|
|
|
+ if (name) query.$or = [{ inventor: new RegExp(name) }, { apply_personal: new RegExp(name) }];
|
|
|
+ invent = await this.patentModel.count({ type: '发明', ...query });
|
|
|
+ practical = await this.patentModel.count({ type: '使用新型', ...query });
|
|
|
+ other = await this.patentModel.count({ $and: [{ type: { $ne: '使用新型' } }, { type: { $ne: '发明' } }], ...query });
|
|
|
+ }
|
|
|
+ patent = { invent, practical, other };
|
|
|
// 消息:未读,已读,通知(所有)
|
|
|
const noticeModel = this.ctx.model.Patent.Notice;
|
|
|
const unread = await noticeModel.count({ to: ObjectId(id), is_read: false });
|