|
@@ -2105,6 +2105,859 @@ class TGovernmentStatisticsService extends CrudService {
|
|
|
|
|
|
},
|
|
|
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $group: {
|
|
|
+ _id: '$name',
|
|
|
+ id: {
|
|
|
+ $first: "$_id"
|
|
|
+ },
|
|
|
+ name: {
|
|
|
+ $first: "$name"
|
|
|
+ },
|
|
|
+ help_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '1']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ receive_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '0']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ approval_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '2']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ refuse_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '3']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '1']
|
|
|
+ }, '$t_finance_follows.credit_money', 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_time1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '1']
|
|
|
+ }, '$t_finance_follows.accept_time', 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_rate1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '1']
|
|
|
+ }, { $toDouble: '$t_finance_follows.sxcplilue'}, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $lookup:
|
|
|
+ {
|
|
|
+ from: "intelligent_follow",
|
|
|
+ let: {
|
|
|
+ jg_id: {
|
|
|
+ $toString: "$id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pipeline: [
|
|
|
+ {
|
|
|
+ $match:
|
|
|
+ {
|
|
|
+ $expr:
|
|
|
+ {
|
|
|
+ $and:
|
|
|
+ [
|
|
|
+ {
|
|
|
+ $eq: ['$uid', "$$jg_id"]
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ as: "intelligent_follows"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $unwind: {
|
|
|
+ path: '$intelligent_follows',
|
|
|
+ preserveNullAndEmptyArrays: true,
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $group: {
|
|
|
+ _id: '$name',
|
|
|
+ id: {
|
|
|
+ $first: "$id"
|
|
|
+ },
|
|
|
+ help_count1: {
|
|
|
+ $first: "$help_count1"
|
|
|
+ },
|
|
|
+ receive_count1: {
|
|
|
+ $first: "$receive_count1"
|
|
|
+ },
|
|
|
+ approval_count1: {
|
|
|
+ $first: "$approval_count1"
|
|
|
+ },
|
|
|
+ refuse_count1: {
|
|
|
+ $first: "$refuse_count1"
|
|
|
+ },
|
|
|
+ sum_count1: {
|
|
|
+ $first: "$sum_count1"
|
|
|
+ },
|
|
|
+ sum_time1: {
|
|
|
+ $first: "$sum_time1"
|
|
|
+ },
|
|
|
+ sum_rate1: {
|
|
|
+ $first: "$sum_rate1"
|
|
|
+ },
|
|
|
+ help_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '1']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ receive_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '0']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ approval_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '2']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ refuse_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '3']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '1']
|
|
|
+ }, '$intelligent_follows.credit_money', 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_time2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '1']
|
|
|
+ }, '$intelligent_follows.accept_time', 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_rate2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '1']
|
|
|
+ }, { $toDouble: '$intelligent_follows.sxcplilue'}, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $lookup:
|
|
|
+ {
|
|
|
+ from: "claim_need",
|
|
|
+ let: {
|
|
|
+ jg_id: {
|
|
|
+ $toString: "$id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pipeline: [
|
|
|
+ {
|
|
|
+ $match:
|
|
|
+ {
|
|
|
+ $expr:
|
|
|
+ {
|
|
|
+ $and:
|
|
|
+ [
|
|
|
+ {
|
|
|
+ $eq: ['$status', "0"],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $eq: ['$jg_id', "$$jg_id"]
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ as: "claim_needs"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $lookup:
|
|
|
+ {
|
|
|
+ from: "intelligent_docking",
|
|
|
+ let: {
|
|
|
+ jg_id: {
|
|
|
+ $toString: "$id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pipeline: [
|
|
|
+ {
|
|
|
+ $match:
|
|
|
+ {
|
|
|
+ $expr:
|
|
|
+ {
|
|
|
+ $and:
|
|
|
+ [
|
|
|
+ {
|
|
|
+ $eq: ['$jg_id', "$$jg_id"]
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ as: "intelligent_dockings"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $project: {
|
|
|
+ id: 1,
|
|
|
+ help_count1: 1,
|
|
|
+ receive_count1: 1,
|
|
|
+ approval_count1: 1,
|
|
|
+ refuse_count1: 1,
|
|
|
+ sum_count1: 1,
|
|
|
+ sum_time1: 1,
|
|
|
+ help_count2: 1,
|
|
|
+ receive_count2: 1,
|
|
|
+ approval_count2: 1,
|
|
|
+ refuse_count2: 1,
|
|
|
+ sum_count2: 1,
|
|
|
+ sum_time2: 1,
|
|
|
+ sum_rate1: 1,
|
|
|
+ sum_rate2: 1,
|
|
|
+ push_count1: {
|
|
|
+ $size: "$claim_needs"
|
|
|
+ },
|
|
|
+ push_count2: {
|
|
|
+ $size: "$intelligent_dockings"
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $project: {
|
|
|
+ _id: 0,
|
|
|
+ bank_name: '$_id',
|
|
|
+ push_count: {
|
|
|
+ $add: ["$push_count1", "$push_count2"]
|
|
|
+ },
|
|
|
+ // receive_count:{ $add: [ "$receive_count1", "$receive_count2" ] },
|
|
|
+ approval_count: {
|
|
|
+ $add: ["$approval_count1", "$approval_count2"]
|
|
|
+ },
|
|
|
+ help_count: {
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ },
|
|
|
+ refuse_count: {
|
|
|
+ $add: ["$refuse_count1", "$refuse_count2"]
|
|
|
+ },
|
|
|
+ sum_money: {
|
|
|
+ $add: ["$sum_count1", "$sum_count2"]
|
|
|
+ },
|
|
|
+ avg_money: {
|
|
|
+ $cond: {
|
|
|
+ if : {
|
|
|
+ $eq: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, 0]
|
|
|
+ },
|
|
|
+ then: 0,
|
|
|
+ else : {
|
|
|
+ $divide: [{
|
|
|
+ $add: ["$sum_count1", "$sum_count2"]
|
|
|
+ }, {
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }]
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ avg_time: {
|
|
|
+ $cond: {
|
|
|
+ if : {
|
|
|
+ $eq: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, 0]
|
|
|
+ },
|
|
|
+ then: 0,
|
|
|
+ else : {
|
|
|
+ $divide: [{
|
|
|
+ $add: ["$sum_time1", "$sum_time2"]
|
|
|
+ }, {
|
|
|
+ $multiply: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, 86400000]
|
|
|
+ }]
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ success_probability: {
|
|
|
+ $cond: {
|
|
|
+ if : {
|
|
|
+ $eq: [{
|
|
|
+ $add: ["$help_count1", "$help_count2", "$refuse_count1", "$refuse_count2"]
|
|
|
+ }, 0]
|
|
|
+ },
|
|
|
+ then: 0,
|
|
|
+ else : {
|
|
|
+ $multiply: [{
|
|
|
+ $divide: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, {
|
|
|
+ $add: ["$help_count1", "$help_count2", "$refuse_count1", "$refuse_count2"]
|
|
|
+ }]
|
|
|
+ }, 100]
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ avg_rate: {
|
|
|
+ $cond: {
|
|
|
+ if : {
|
|
|
+ $eq: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, 0]
|
|
|
+ },
|
|
|
+ then: 0,
|
|
|
+ else : {
|
|
|
+ $divide: [{
|
|
|
+ $add: ["$sum_rate1", "$sum_rate2"]
|
|
|
+ }, {
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }]
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $sort: {success_probability:-1}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $skip: Number.parseInt(skip),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $limit:Number.parseInt(limit),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ let totalAgg = [
|
|
|
+ {
|
|
|
+ $lookup:
|
|
|
+ {
|
|
|
+ from: "t_finance_follow",
|
|
|
+ let: {
|
|
|
+ jg_id: {
|
|
|
+ $toString: "$_id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pipeline: [
|
|
|
+ {
|
|
|
+ $match:
|
|
|
+ {
|
|
|
+ $expr:
|
|
|
+ {
|
|
|
+ $and:
|
|
|
+ [
|
|
|
+ {
|
|
|
+ $eq: ['$userid', "$$jg_id"]
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ as: "t_finance_follows"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $unwind: {
|
|
|
+ path: '$t_finance_follows',
|
|
|
+ preserveNullAndEmptyArrays: true,
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $group: {
|
|
|
+ _id: '$name',
|
|
|
+ id: {
|
|
|
+ $first: "$_id"
|
|
|
+ },
|
|
|
+ name: {
|
|
|
+ $first: "$name"
|
|
|
+ },
|
|
|
+ help_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '1']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ receive_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '0']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ approval_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '2']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ refuse_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '3']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_count1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '1']
|
|
|
+ }, '$t_finance_follows.credit_money', 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_time1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '1']
|
|
|
+ }, '$t_finance_follows.accept_time', 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_rate1: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$t_finance_follows.orcredit', '1']
|
|
|
+ }, { $toDouble: '$t_finance_follows.sxcplilue'}, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $lookup:
|
|
|
+ {
|
|
|
+ from: "intelligent_follow",
|
|
|
+ let: {
|
|
|
+ jg_id: {
|
|
|
+ $toString: "$id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pipeline: [
|
|
|
+ {
|
|
|
+ $match:
|
|
|
+ {
|
|
|
+ $expr:
|
|
|
+ {
|
|
|
+ $and:
|
|
|
+ [
|
|
|
+ {
|
|
|
+ $eq: ['$uid', "$$jg_id"]
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ as: "intelligent_follows"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $unwind: {
|
|
|
+ path: '$intelligent_follows',
|
|
|
+ preserveNullAndEmptyArrays: true,
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $group: {
|
|
|
+ _id: '$name',
|
|
|
+ id: {
|
|
|
+ $first: "$id"
|
|
|
+ },
|
|
|
+ help_count1: {
|
|
|
+ $first: "$help_count1"
|
|
|
+ },
|
|
|
+ receive_count1: {
|
|
|
+ $first: "$receive_count1"
|
|
|
+ },
|
|
|
+ approval_count1: {
|
|
|
+ $first: "$approval_count1"
|
|
|
+ },
|
|
|
+ refuse_count1: {
|
|
|
+ $first: "$refuse_count1"
|
|
|
+ },
|
|
|
+ sum_count1: {
|
|
|
+ $first: "$sum_count1"
|
|
|
+ },
|
|
|
+ sum_time1: {
|
|
|
+ $first: "$sum_time1"
|
|
|
+ },
|
|
|
+ sum_rate1: {
|
|
|
+ $first: "$sum_rate1"
|
|
|
+ },
|
|
|
+ help_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '1']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ receive_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '0']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ approval_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '2']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ refuse_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '3']
|
|
|
+ }, 1, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_count2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '1']
|
|
|
+ }, '$intelligent_follows.credit_money', 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_time2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '1']
|
|
|
+ }, '$intelligent_follows.accept_time', 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sum_rate2: {
|
|
|
+ $sum: {
|
|
|
+ $cond: [{
|
|
|
+ $eq: ['$intelligent_follows.creditStatus', '1']
|
|
|
+ }, { $toDouble: '$intelligent_follows.sxcplilue'}, 0],
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $lookup:
|
|
|
+ {
|
|
|
+ from: "claim_need",
|
|
|
+ let: {
|
|
|
+ jg_id: {
|
|
|
+ $toString: "$id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pipeline: [
|
|
|
+ {
|
|
|
+ $match:
|
|
|
+ {
|
|
|
+ $expr:
|
|
|
+ {
|
|
|
+ $and:
|
|
|
+ [
|
|
|
+ {
|
|
|
+ $eq: ['$status', "0"],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $eq: ['$jg_id', "$$jg_id"]
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ as: "claim_needs"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $lookup:
|
|
|
+ {
|
|
|
+ from: "intelligent_docking",
|
|
|
+ let: {
|
|
|
+ jg_id: {
|
|
|
+ $toString: "$id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pipeline: [
|
|
|
+ {
|
|
|
+ $match:
|
|
|
+ {
|
|
|
+ $expr:
|
|
|
+ {
|
|
|
+ $and:
|
|
|
+ [
|
|
|
+ {
|
|
|
+ $eq: ['$jg_id', "$$jg_id"]
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ as: "intelligent_dockings"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $project: {
|
|
|
+ id: 1,
|
|
|
+ help_count1: 1,
|
|
|
+ receive_count1: 1,
|
|
|
+ approval_count1: 1,
|
|
|
+ refuse_count1: 1,
|
|
|
+ sum_count1: 1,
|
|
|
+ sum_time1: 1,
|
|
|
+ help_count2: 1,
|
|
|
+ receive_count2: 1,
|
|
|
+ approval_count2: 1,
|
|
|
+ refuse_count2: 1,
|
|
|
+ sum_count2: 1,
|
|
|
+ sum_time2: 1,
|
|
|
+ sum_rate1: 1,
|
|
|
+ sum_rate2: 1,
|
|
|
+ push_count1: {
|
|
|
+ $size: "$claim_needs"
|
|
|
+ },
|
|
|
+ push_count2: {
|
|
|
+ $size: "$intelligent_dockings"
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $project: {
|
|
|
+ _id: 0,
|
|
|
+ bank_name: '$_id',
|
|
|
+ push_count: {
|
|
|
+ $add: ["$push_count1", "$push_count2"]
|
|
|
+ },
|
|
|
+ // receive_count:{ $add: [ "$receive_count1", "$receive_count2" ] },
|
|
|
+ approval_count: {
|
|
|
+ $add: ["$approval_count1", "$approval_count2"]
|
|
|
+ },
|
|
|
+ help_count: {
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ },
|
|
|
+ refuse_count: {
|
|
|
+ $add: ["$refuse_count1", "$refuse_count2"]
|
|
|
+ },
|
|
|
+ sum_money: {
|
|
|
+ $add: ["$sum_count1", "$sum_count2"]
|
|
|
+ },
|
|
|
+ avg_money: {
|
|
|
+ $cond: {
|
|
|
+ if : {
|
|
|
+ $eq: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, 0]
|
|
|
+ },
|
|
|
+ then: 0,
|
|
|
+ else : {
|
|
|
+ $divide: [{
|
|
|
+ $add: ["$sum_count1", "$sum_count2"]
|
|
|
+ }, {
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }]
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ avg_time: {
|
|
|
+ $cond: {
|
|
|
+ if : {
|
|
|
+ $eq: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, 0]
|
|
|
+ },
|
|
|
+ then: 0,
|
|
|
+ else : {
|
|
|
+ $divide: [{
|
|
|
+ $add: ["$sum_time1", "$sum_time2"]
|
|
|
+ }, {
|
|
|
+ $multiply: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, 86400000]
|
|
|
+ }]
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ success_probability: {
|
|
|
+ $cond: {
|
|
|
+ if : {
|
|
|
+ $eq: [{
|
|
|
+ $add: ["$help_count1", "$help_count2", "$refuse_count1", "$refuse_count2"]
|
|
|
+ }, 0]
|
|
|
+ },
|
|
|
+ then: 0,
|
|
|
+ else : {
|
|
|
+ $multiply: [{
|
|
|
+ $divide: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, {
|
|
|
+ $add: ["$help_count1", "$help_count2", "$refuse_count1", "$refuse_count2"]
|
|
|
+ }]
|
|
|
+ }, 100]
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ avg_rate: {
|
|
|
+ $cond: {
|
|
|
+ if : {
|
|
|
+ $eq: [{
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }, 0]
|
|
|
+ },
|
|
|
+ then: 0,
|
|
|
+ else : {
|
|
|
+ $divide: [{
|
|
|
+ $add: ["$sum_rate1", "$sum_rate2"]
|
|
|
+ }, {
|
|
|
+ $add: ["$help_count1", "$help_count2"]
|
|
|
+ }]
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $count: 'total',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ /*let dataAgg = [
|
|
|
+ {
|
|
|
+ $lookup:
|
|
|
+ {
|
|
|
+ from: "t_finance_follow",
|
|
|
+ let: {
|
|
|
+ jg_id: {
|
|
|
+ $toString: "$_id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ pipeline: [
|
|
|
+ {
|
|
|
+ $match:
|
|
|
+ {
|
|
|
+ $expr:
|
|
|
+ {
|
|
|
+ $and:
|
|
|
+ [
|
|
|
+ {
|
|
|
+ $eq: ['$userid', "$$jg_id"]
|
|
|
+ },
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ as: "t_finance_follows"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $unwind: {
|
|
|
+ path: '$t_finance_follows',
|
|
|
+ preserveNullAndEmptyArrays: true,
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
},
|
|
|
{
|
|
|
$group: {
|
|
@@ -2840,7 +3693,7 @@ class TGovernmentStatisticsService extends CrudService {
|
|
|
{
|
|
|
$count: 'total',
|
|
|
},
|
|
|
- ];
|
|
|
+ ];*/
|
|
|
|
|
|
const data = await this.institutionModel.aggregate(dataAgg);
|
|
|
const totalTemp = await this.institutionModel.aggregate(totalAgg);
|