storoge

Untitled

Feb 27th, 2017
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.       $match: {
  3.         "creatorDeptId": {$exists: true},
  4.         "claimCreate"    : {$exists: true},
  5.         "customClaimNumber"    : {$exists: true},
  6.         "currStatus.statusCode"    : {$exists: true},
  7.         "daysToDeadline"  : {$exists: true},
  8.         "service.name"    : {$exists: true},
  9.         "service.srguServicePassportId"   : {$exists: true},
  10.         "service.srguDepartmentName"    : {$exists: true},
  11.         "oktmo": { $regex: "^46" } ,
  12.        
  13.     "creatorDeptId": "mfc-odincovo",
  14.        "claimCreate" : { $lte: { $date: "2016-10-07T23:59:59Z" }, $gte: { $date: "2016-10-01T00:00:00Z" } }
  15.       }
  16.     },
  17. {
  18. $project: {
  19.         "claimCreate"    : "$claimCreate",
  20.         "customClaimNumber"   : "$customClaimNumber",
  21.      "guid": "$_id",   
  22.         "creatorDeptId": "$creatorDeptId",                             
  23.      "service.srguServicePassportId"   : "$service.srguServicePassportId",
  24.     "currStatus.statusCode"   : "$currStatus.statusCode",
  25.     "person.fio":   { $ifNull: [ "$person.fio"    , "" ] },
  26.     "person.orgName":   { $ifNull: [ "$person.orgName"    , "" ] },
  27.     "service.srguDepartmentName":"$service.srguDepartmentName",
  28.     "providerName" : "$providerName",
  29.     "operatorFio" : "$operatorFio",
  30.     "service.serviceType":"$service.serviceType",
  31.     "placeOfIssue": "$placeOfIssue",
  32.     "provLevel": "$provLevel",
  33.     "serviceOrg":"$serviceOrg",
  34.        "cons_true": { $cond:  {if:  { $eq: ["$consultation", true  ] } , then: 1,else: 0}  },
  35.        "claim_true": { $cond:  {if:  { $eq: ["$consultation", false] } , then: 1,else: 0}  },
  36.      "urmName":   { $ifNull: [ "$urmName"    , "" ] },
  37.         "urmNumber": { $ifNull: [ "$urmNumber"  , "" ] },
  38.      "currStatus.operatorFio": { $ifNull: [ "$currStatus.operatorFio"  , "" ] },
  39.      "total_takeClaimant" :  { $cond: {if:  {$or: [ {$eq:["$currStatus.statusCode", "24"]},{$eq:["$currStatus_statusCode", "24"]}] },  then: 1, else: 0}},
  40.      "total_done" :  { $cond: {if:  {$or: [ {$eq:["$currStatus.statusCode", "4"]},{$eq:["$currStatus_statusCode", "3"]}] },  then: 1, else: 0}},
  41.          "total_email" :  { $cond: {if:  {$eq:["$personsInfo.contacts.type", "EML"] },  then: 1, else: 0}},
  42.          "total_deadline7"      :  { $cond: [ { $and: [ { $lt: ["$daysToDeadline", 0] }, { $gt: ["$daysToDeadline", -7] },  { $eq: ["$consultation", false] } ] }, 1, 0 ] },
  43.       "total_deadline7_14"     :  { $cond: [ { $and: [ { $lt: ["$daysToDeadline", -7] }, { $gt: ["$daysToDeadline", -14] } ,  { $eq: ["$consultation", false] }] }, 1, 0 ] },
  44.       "total_deadline14"     :  { $cond: [ { $and: [ { $lt: ["$daysToDeadline", -14] }, { $eq: ["$consultation", false] }] }, 1, 0 ]}  
  45. }
  46. }
RAW Paste Data