|
@@ -168,6 +168,110 @@ class IntelligentDockingService extends CrudService {
|
|
|
const limit = Number.parseInt(data.limit) || 10;
|
|
|
|
|
|
// const total = await this.model.countDocuments(query);
|
|
|
+ const total = await this.model.aggregate([
|
|
|
+ { $match: query },
|
|
|
+ { $project:
|
|
|
+ {
|
|
|
+ ensure_id: 1,
|
|
|
+ person: 1,
|
|
|
+ money: 1,
|
|
|
+ claims_min_term: 1,
|
|
|
+ claims_max_term: 1,
|
|
|
+ mongey_min_rate: 1,
|
|
|
+ mongey_max_rate: 1,
|
|
|
+ when: 1,
|
|
|
+ refuse_times: 1,
|
|
|
+ additional_information: 1,
|
|
|
+ status: 1,
|
|
|
+ jg_id: { $toObjectId: '$jg_id' },
|
|
|
+ cid: { $toObjectId: '$cid' },
|
|
|
+ uid: '$uid',
|
|
|
+ xqId: { $toString: '$_id' },
|
|
|
+ time: '$meta.createdAt',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { $lookup:
|
|
|
+ {
|
|
|
+ from: 'company_identify',
|
|
|
+ localField: 'uid',
|
|
|
+ foreignField: 'uid',
|
|
|
+ as: 'company',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { $lookup:
|
|
|
+ {
|
|
|
+ from: 'institution',
|
|
|
+ localField: 'jg_id',
|
|
|
+ foreignField: '_id',
|
|
|
+ as: 'institution',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { $lookup:
|
|
|
+ {
|
|
|
+ from: 't_finance_claims',
|
|
|
+ localField: 'cid',
|
|
|
+ foreignField: '_id',
|
|
|
+ as: 'finance_claims',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { $lookup:
|
|
|
+ {
|
|
|
+ from: 'dictionary',
|
|
|
+ localField: 'ensure_id',
|
|
|
+ foreignField: 'code',
|
|
|
+ as: 'dictionary',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ // { $lookup:
|
|
|
+ // {
|
|
|
+ // from: 'dictionary',
|
|
|
+ // localField: 'when',
|
|
|
+ // foreignField: 'code',
|
|
|
+ // as: 'when',
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ { $lookup:
|
|
|
+ {
|
|
|
+ from: 'intelligent_follow',
|
|
|
+ localField: 'xqId',
|
|
|
+ foreignField: 'intelligentId',
|
|
|
+ as: 'follow',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { $unwind: '$company' },
|
|
|
+ { $unwind: '$institution' },
|
|
|
+ { $unwind: '$finance_claims' },
|
|
|
+ { $unwind: '$dictionary' },
|
|
|
+ { $unwind: { path: '$follow', preserveNullAndEmptyArrays: true } },
|
|
|
+ // { $unwind: { path: '$when', preserveNullAndEmptyArrays: true } },
|
|
|
+ { $project:
|
|
|
+ {
|
|
|
+ ensure_id: 1,
|
|
|
+ person: 1,
|
|
|
+ money: 1,
|
|
|
+ claims_min_term: 1,
|
|
|
+ claims_max_term: 1,
|
|
|
+ mongey_min_rate: 1,
|
|
|
+ mongey_max_rate: 1,
|
|
|
+ when: 1,
|
|
|
+ refuse_times: 1,
|
|
|
+ additional_information: 1,
|
|
|
+ status: 1,
|
|
|
+ creditStatus: '$follow.creditStatus',
|
|
|
+ jg_id: { $toObjectId: '$jg_id' },
|
|
|
+ cid: { $toObjectId: '$cid' },
|
|
|
+ uid: '$uid',
|
|
|
+ xqId: { $toString: '$_id' },
|
|
|
+ time: '$meta.createdAt',
|
|
|
+ company: '$company',
|
|
|
+ institution: '$institution',
|
|
|
+ finance_claims: '$finance_claims',
|
|
|
+ dictionary: '$dictionary',
|
|
|
+ follow: '$follow',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { $sort: { time: -1 } },
|
|
|
+ ]);
|
|
|
const result = await this.model.aggregate([
|
|
|
{ $match: query },
|
|
|
{ $project:
|
|
@@ -274,8 +378,7 @@ class IntelligentDockingService extends CrudService {
|
|
|
{ $limit: limit },
|
|
|
{ $sort: { time: -1 } },
|
|
|
]);
|
|
|
- // return { result, total };
|
|
|
- return { result, total: result.length };
|
|
|
+ return { result, total: total.length };
|
|
|
}
|
|
|
|
|
|
// 拒绝接口
|