|
@@ -13,6 +13,41 @@ class DisclosureService extends CrudService {
|
|
|
this.model = this.ctx.model.Patent.Disclosure;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询有评估报告的交底书
|
|
|
+ * @param {Object} param0 条件
|
|
|
+ */
|
|
|
+ async haveReport({ skip, limit, ...query }) {
|
|
|
+ const { user_id, admin_id, mechanism_id } = query;
|
|
|
+ if (user_id) query.user_id = ObjectId(user_id);
|
|
|
+ if (admin_id) query.admin_id = ObjectId(admin_id);
|
|
|
+ if (mechanism_id) query.mechanism_id = ObjectId(mechanism_id);
|
|
|
+ const condition = [
|
|
|
+ { $match: { ...query } },
|
|
|
+ {
|
|
|
+ $lookup: {
|
|
|
+ from: 'disclosure_report',
|
|
|
+ localField: '_id',
|
|
|
+ foreignField: 'disclosure_id',
|
|
|
+ as: 'report',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { $match: { 'report.0': { $exists: true } } },
|
|
|
+ { $sort: { 'meta.createdAt': -1 } },
|
|
|
+ ];
|
|
|
+ const ctotal = [
|
|
|
+ ...condition,
|
|
|
+ { $group: { _id: '', total: { $sum: 1 } } },
|
|
|
+ ];
|
|
|
+ const tres = await this.model.aggregate(ctotal);
|
|
|
+ const total = _.get(_.head(tres), 'total', 0);
|
|
|
+ if (skip && limit) {
|
|
|
+ condition.push({ $skip: parseInt(skip) });
|
|
|
+ condition.push({ $limit: parseInt(limit) });
|
|
|
+ }
|
|
|
+ const res = await this.model.aggregate(condition);
|
|
|
+ return { data: res, total };
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 交底书审核
|
|
@@ -62,7 +97,12 @@ class DisclosureService extends CrudService {
|
|
|
break;
|
|
|
}
|
|
|
const data = await this.model.findById(id);
|
|
|
- if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '添加记录----未找到数据');
|
|
|
+ if (!data) {
|
|
|
+ throw new BusinessError(
|
|
|
+ ErrorCode.DATA_NOT_EXIST,
|
|
|
+ '添加记录----未找到数据'
|
|
|
+ );
|
|
|
+ }
|
|
|
const obj = {
|
|
|
time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
word,
|
|
@@ -70,7 +110,6 @@ class DisclosureService extends CrudService {
|
|
|
};
|
|
|
data.record.push(obj);
|
|
|
return await data.save();
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|