Advertisement
storoge

Untitled

Jul 13th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [
  2.  
  3.     {
  4.       $match: {
  5.          $and: [
  6.             {"daysToDeadline": {$exists: true}},
  7.             {"currStatus": {$exists: true}},
  8.     { "customClaimNumber"    : {$exists: true}},
  9.     {"service.name" : {$exists: true}},    
  10.     {"consultation": false},
  11.             {"creatorDeptId": {$exists: true}},
  12.             {"senderCode": {$exists: true}},
  13.             {"currStatus": {$exists: true}},
  14.             {"service.srguServiceId": {$exists: true}},
  15.             { "oktmo": { $regex: "^46" } }
  16.             ],
  17.             $or: [
  18.             {"claimCreate" : { $lte: { $date:"2016-08-31T23:59:59Z" }, $gte: { $date: "2016-08-01T00:00:00Z" } }},
  19.             {"docSendDate" : { $lte: { $date:"2016-08-31T23:59:59Z" }, $gte: { $date: "2016-08-01T00:00:00Z" } }}
  20.             ]
  21.             }
  22.          
  23.       },
  24.  
  25.     {
  26.       $project: {
  27. "creatorDeptId"  : "$creatorDeptId",
  28. "senderCode"  : "$senderCode",
  29. "srguServiceId":"$service.srguServiceId",
  30. "oktmo": { $substr: [ "$oktmo", 0, 5 ] },
  31. "provLevel": { $ifNull: [ "$provLevel"  , "" ] },
  32. "resultStatus": { $ifNull: [ "$resultStatus"  , "" ] },
  33. "daysToDeadline": "$daysToDeadline",
  34.  "OMSU"  : { $substr: [ "$creatorDeptId", 0, 4 ] },
  35. "in_Close":  { $and: [
  36.           { $lte: [ "$docSendDate", { $date: "2016-08-31T23:59:59Z" } ] },
  37.           { $gte: [ "$docSendDate", { $date: "2016-08-01T00:00:00Z" } ] } ] },
  38. "in_Create":  { $and: [
  39.           { $lte: [ "$claimCreate", { $date: "2016-08-31T23:59:59Z" } ] },
  40.           { $gte: [ "$claimCreate", { $date: "2016-08-01T00:00:00Z" } ] } ] }
  41.           }
  42.     },
  43.  
  44.     {
  45.       $group: {
  46.       _id: { "oktmo":  "$oktmo" ,"srguServiceId": "$srguServiceId"},
  47.       a_completed   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Close", true] } ] }, 1, 0 ] } },
  48.       a_completed_neg   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Close", true] }, {$eq: ["$resultStatus", "4" ]} ] }, 1, 0 ] } },
  49.       a_completed_pos   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Close", true] }, {$eq: ["$resultStatus", "3" ]} ] }, 1, 0 ] } },
  50.       a_completed_exp   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Close", true] }, {$lt: ["$daysToDeadline", 0 ]} ] }, 1, 0 ] } },
  51.       a_completed_MFC   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Close", true] }, {$eq: ["$OMSU", "mfc-" ]}, {$ne: ["$senderCode", "IPGU01001" ]} ] }, 1, 0 ] } },
  52.       a_completed_RPGU : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Close", true] }, {$eq: ["$senderCode", "IPGU01001" ]} ] }, 1, 0 ]} },
  53.       a_completed_OMSU   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Close", true] }, {$eq: ["$OMSU", "omsu" ]}, {$ne: ["$senderCode", "IPGU01001" ]} ] }, 1, 0 ] } },
  54.        
  55.       b_completed   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Create", true] } ] }, 1, 0 ] } },
  56.       b_completed_exp   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Create", true] }, {$lt: ["$daysToDeadline", 0 ]} ] }, 1, 0 ] } },
  57.       b_completed_MFC  : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Create", true] },  {$eq: ["$OMSU", "mfc-" ]}, {$ne: ["$senderCode", "IPGU01001" ]} ] }, 1, 0 ]} },
  58.       b_completed_MFC_exp   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Create", true] },  {$eq: ["$OMSU", "mfc-" ]}, {$ne: ["$senderCode", "IPGU01001" ]}, {$lt: ["$daysToDeadline", 0 ]} ] }, 1, 0 ]} },
  59.       b_completed_RPGU : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Create", true] }, {$eq: ["$senderCode", "IPGU01001" ]} ] }, 1, 0 ]} },
  60.       b_completed_RPGU_exp  : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Create", true] }, {$eq: ["$senderCode", "IPGU01001" ]}, {$lt: ["$daysToDeadline", 0 ]} ] }, 1, 0 ]} },
  61.       b_completed_OMSU   : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Create", true] }, {$eq: ["$OMSU", "omsu" ]},{$ne: ["$senderCode", "IPGU01001" ]} ] }, 1, 0 ] } },
  62.          b_completed_OMSU_exp    : { $sum: { $cond: [ { $and: [ { $eq: ["$in_Create", true] }, {$eq: ["$OMSU", "omsu" ]},{$ne: ["$senderCode", "IPGU01001" ]}, {$lt: ["$daysToDeadline", 0 ]} ] }, 1, 0 ] } }
  63.        }
  64.     }
  65.  
  66.   ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement