package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jasamedika.medifirst2000.dao.IpsrsMonevMaintenanceDao;
import com.jasamedika.medifirst2000.service.IpsrsMonevMaintenanceService;
import com.jasamedika.medifirst2000.util.CommonUtil;

@Service("ipsrsMonevMaintenanceService")
public class IpsrsMonevMaintenanceServiceImpl implements IpsrsMonevMaintenanceService{

	@Autowired
	private IpsrsMonevMaintenanceDao ipsrsMonevMaintenanceDao;
	
	@Override
	public Map<String, Object> getRekananByJadwal(){
		Map<String, Object> result = new HashMap<>();
		List<Map<String, Object>> listData = ipsrsMonevMaintenanceDao.getRekananByJadwal();
		if(CommonUtil.isNotNullOrEmpty(listData)){
			result.put("listData", listData);
		}
		return result;
	}
	
	@Override
	public Map<String, Object> getKontakService(Integer rekananId){
		Map<String, Object> result = new HashMap<>();
		List<Map<String, Object>> listData = ipsrsMonevMaintenanceDao.getKontakService(rekananId);
		if(CommonUtil.isNotNullOrEmpty(listData)){
			result.put("listData", listData);
		}
		return result;
	}
	
	public Map<String, Object> getChartKontakService(String jenisPenjadwalan, String noRecPenjadwalan, String jenisPeriode) {
		Map<String, Object> result = new HashMap<>();
		
		String[] bulan = {"Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"};
		
		List<Map<String, Object>> listChart = new ArrayList<>();
		
		if(jenisPeriode.matches("Mingguan")){
			for(int i=0; i<12; i++){
				Map<String, Object> dataChart =  new HashMap<>();
				dataChart.put("bulan", bulan[i]);
				dataChart.put("target", "40");
				dataChart.put("realisasi", "");
			}
			
		} else if(jenisPeriode.matches("Bulanan")){
			
			
		} else if(jenisPeriode.matches("Tahunan")){
			
			
		}
		return result;
	}
	
	
	
}
