|  | @@ -7,6 +7,7 @@ const {
 | 
	
		
			
				|  |  |    cekBanyakDataSanksi,
 | 
	
		
			
				|  |  |  } = require('../utils/cekData')
 | 
	
		
			
				|  |  |  const laporanModel = require('../model/laporan.model')
 | 
	
		
			
				|  |  | +const sanksiModel = require('../model/sanksi.model')
 | 
	
		
			
				|  |  |  const moment = require('moment')
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  exports.laporan = handleError(async (req, res) => {
 | 
	
	
		
			
				|  | @@ -392,3 +393,108 @@ exports.laporanSelesai = handleError(async (req, res) => {
 | 
	
		
			
				|  |  |      data,
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  |  })
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +exports.jumlahStatusLaporan = handleError(async (req, res) => {
 | 
	
		
			
				|  |  | +  const pembina = await laporanModel.distinct('pt.pembina.nama')
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  let data = await Promise.all(
 | 
	
		
			
				|  |  | +    pembina.map(async (e) => {
 | 
	
		
			
				|  |  | +      return {
 | 
	
		
			
				|  |  | +        [e]: {
 | 
	
		
			
				|  |  | +          jumlah_jadwal_evaluasi: await laporanModel
 | 
	
		
			
				|  |  | +            .find({
 | 
	
		
			
				|  |  | +              jadwal: {
 | 
	
		
			
				|  |  | +                $ne: null,
 | 
	
		
			
				|  |  | +                $exists: true,
 | 
	
		
			
				|  |  | +              },
 | 
	
		
			
				|  |  | +              'pt.pembina.nama': e,
 | 
	
		
			
				|  |  | +            })
 | 
	
		
			
				|  |  | +            .count(),
 | 
	
		
			
				|  |  | +          jumlah_pemeriksaan: await laporanModel
 | 
	
		
			
				|  |  | +            .find({
 | 
	
		
			
				|  |  | +              evaluasi: {
 | 
	
		
			
				|  |  | +                $ne: [],
 | 
	
		
			
				|  |  | +                $exists: true,
 | 
	
		
			
				|  |  | +              },
 | 
	
		
			
				|  |  | +              'pt.pembina.nama': e,
 | 
	
		
			
				|  |  | +            })
 | 
	
		
			
				|  |  | +            .count(),
 | 
	
		
			
				|  |  | +          jumlah_sanksi: await laporanModel
 | 
	
		
			
				|  |  | +            .find({
 | 
	
		
			
				|  |  | +              sanksi: {
 | 
	
		
			
				|  |  | +                $ne: null,
 | 
	
		
			
				|  |  | +                $exists: true,
 | 
	
		
			
				|  |  | +              },
 | 
	
		
			
				|  |  | +              'pt.pembina.nama': e,
 | 
	
		
			
				|  |  | +            })
 | 
	
		
			
				|  |  | +            .count(),
 | 
	
		
			
				|  |  | +          jumlah_keberatan: (
 | 
	
		
			
				|  |  | +            await sanksiModel
 | 
	
		
			
				|  |  | +              .find({
 | 
	
		
			
				|  |  | +                'pengajuan.keberatan': {
 | 
	
		
			
				|  |  | +                  $ne: null,
 | 
	
		
			
				|  |  | +                  $exists: true,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +              .populate({
 | 
	
		
			
				|  |  | +                path: 'laporan',
 | 
	
		
			
				|  |  | +                match: {
 | 
	
		
			
				|  |  | +                  'pt.pembina.nama': e,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +          ).filter((e) => e.laporan != null).length,
 | 
	
		
			
				|  |  | +          jumlah_banding: (
 | 
	
		
			
				|  |  | +            await sanksiModel
 | 
	
		
			
				|  |  | +              .find({
 | 
	
		
			
				|  |  | +                'pengajuan.banding': {
 | 
	
		
			
				|  |  | +                  $ne: null,
 | 
	
		
			
				|  |  | +                  $exists: true,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +              .populate({
 | 
	
		
			
				|  |  | +                path: 'laporan',
 | 
	
		
			
				|  |  | +                match: {
 | 
	
		
			
				|  |  | +                  'pt.pembina.nama': e,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +          ).filter((e) => e.laporan != null).length,
 | 
	
		
			
				|  |  | +          jumlah_pemantauan_perbaikan: (
 | 
	
		
			
				|  |  | +            await sanksiModel
 | 
	
		
			
				|  |  | +              .find({
 | 
	
		
			
				|  |  | +                perbaikan: {
 | 
	
		
			
				|  |  | +                  $ne: [],
 | 
	
		
			
				|  |  | +                  $exists: true,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +              .populate({
 | 
	
		
			
				|  |  | +                path: 'laporan',
 | 
	
		
			
				|  |  | +                match: {
 | 
	
		
			
				|  |  | +                  'pt.pembina.nama': e,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +          ).filter((e) => e.laporan != null).length,
 | 
	
		
			
				|  |  | +          jumlah_pencabutan_sanksi: (
 | 
	
		
			
				|  |  | +            await sanksiModel
 | 
	
		
			
				|  |  | +              .find({
 | 
	
		
			
				|  |  | +                'pengajuan.cabut_sanksi': {
 | 
	
		
			
				|  |  | +                  $ne: null,
 | 
	
		
			
				|  |  | +                  $exists: true,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +              .populate({
 | 
	
		
			
				|  |  | +                path: 'laporan',
 | 
	
		
			
				|  |  | +                match: {
 | 
	
		
			
				|  |  | +                  'pt.pembina.nama': e,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  | +          ).filter((e) => e.laporan != null).length,
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    })
 | 
	
		
			
				|  |  | +  )
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  return response.success(res, {
 | 
	
		
			
				|  |  | +    message: 'Berhasil menganalisis data',
 | 
	
		
			
				|  |  | +    data,
 | 
	
		
			
				|  |  | +  })
 | 
	
		
			
				|  |  | +})
 |