package com.sh.djpk.econsole.rest.service.impl;

import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sh.djpk.econsole.rest.dao.MonitoringDao;
import com.sh.djpk.econsole.rest.service.MonitoringSvc;


@Service("monitoringSvc")
@Transactional(readOnly = false)
@SuppressWarnings("rawtypes")
public class MonitoringSvcImpl implements MonitoringSvc {

	public static final Logger LOGGER = LoggerFactory
			.getLogger(MonitoringSvcImpl.class);
	
	@Autowired
	MonitoringDao monitoringDao;
	
	@Override
	@Transactional(readOnly = true)
	public List<HashMap> getNationalMonitoring(Integer tahun) {
		LOGGER.info(
				"getting data National Monitoring for year ={}",
				tahun);
		@SuppressWarnings("unused")
		String thnAng = String.valueOf(tahun);
		List<HashMap> l =monitoringDao.getNationalMonitoring(tahun.toString());
		LOGGER.trace("data from db={}", l);
		return l;
	}

	@Override
	public List<HashMap> getHeaderProvinceMonitoring(Integer tahunAnggaran, String prov_id) {
		
		if (prov_id == null || prov_id.isEmpty()) {
			prov_id = "00";
		}
		LOGGER.info(
				"getting data Province Monitoring for year ={}, provinsi={}",
				tahunAnggaran, prov_id);
		@SuppressWarnings("unused")
		String thnAng = String.valueOf(tahunAnggaran);
		List<HashMap> l =monitoringDao.getHeaderProvinceMonitoring(tahunAnggaran.toString(), prov_id);
		LOGGER.trace("data from db={}", l);
		return l;
	}
	
	@Override
	public List<HashMap> getDetailProvinceMonitoring(Integer tahunAnggaran, String prov_id) {
		
		if (prov_id == null || prov_id.isEmpty()) {
			prov_id = "00";
		}
		LOGGER.info(
				"getting data perProvince Monitoring for year ={}, provinsi={}",
				tahunAnggaran, prov_id);
		@SuppressWarnings("unused")
		String thnAng = String.valueOf(tahunAnggaran);
		List<HashMap> l =monitoringDao.getDetailProvinceMonitoring(tahunAnggaran.toString(), prov_id);
		LOGGER.trace("data from db={}", l);
		return l;
	}


}
