/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sikd.ikonsol.ejb.dao;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import sikd.ikonsol.model.AkunEliminasi;
import sikd.ikonsol.model.AkunResiprokal;
import sikd.ikonsol.model.HeaderDataKonsolidasi;
import sikd.ikonsol.model.RawData;
import sikd.ikonsol.model.SusunKonsolidasi;

/**
 *
 * @author Imam Bhoim
 */
public class AkunEliminasiDao implements IDAO<AkunEliminasi>, Serializable {

    private SqlSessionFactory sqlSessionFactory = null;
    private SqlSession session = null;

    public AkunEliminasiDao(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
    }

    @Override
    public AkunEliminasi createNew() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<AkunEliminasi> findAll() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("AkunEliminasiMapper.selectAllMaster");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    @Override
    public List<AkunEliminasi> findByCriteria(String sql) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public AkunEliminasi findByID(int id) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public AkunEliminasi findByKode(String kode) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public AkunEliminasi save(AkunEliminasi obj) {
        session = sqlSessionFactory.openSession();
        session.insert("AkunEliminasiMapper.insertOneManual", obj);
        session.commit();
        session.close();
        return obj;
    }

    @Override
    public AkunEliminasi update(AkunEliminasi obj) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

    }

    @Override
    public void deleteByID(int id) {

        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.delete("AkunEliminasiMapper.deleteOneIdSerial", id);
        session.commit();
        session.close();
    }

    @Override
    public void deleteByPK(String pk) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    public AkunEliminasi saveProses(AkunEliminasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("AkunEliminasiMapper.insertOne", obj);
        session.commit();
        session.close();
        return obj;
    }

    public List<AkunEliminasi> selectCompare() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("AkunEliminasiMapper.selectAllCompare");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public List<AkunEliminasi> findAllByTahunBasJnsLaporan(int tahun, int idbas, int idjnslaporan, String kdperiode) {
        Map<String, Object> map = new HashMap<>();
        map.put("tahun", tahun);
        map.put("idbas", idbas);
        map.put("idjnslaporan", idjnslaporan);
        map.put("kdperiode", kdperiode);
        List<AkunEliminasi> list = null;
        session = sqlSessionFactory.openSession();
        try {

            list = session.selectList("AkunEliminasiMapper.selectAllMaster", map);

        } finally {
            session.close();
        }
        return list;
    }

    public List<AkunEliminasi> findKodeProvinsi(String kode, int id, int tahun, int idbas, int idjnslaporan, String kdperiode) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        Map<String, Object> map = new HashMap<>();
        map.put("kdpemda", kode);
        map.put("idheaderresipo", id);
        map.put("tahun", tahun);
        map.put("idbas", idbas);
        map.put("idjnslaporan", idjnslaporan);
        map.put("kdperiode", kdperiode);
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("AkunEliminasiMapper.selectAllDetail", map);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public List<AkunEliminasi> selectKdProv(int idheaderdata) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("AkunEliminasiMapper.selectGrupProvinsi", idheaderdata);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public AkunEliminasi selectKdWilayah(String kdprov) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectGrupWilayah", kdprov);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return obj;
    }

    public List<AkunResiprokal> selectResipro(int idjnslapor) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        List<AkunResiprokal> list = new ArrayList<AkunResiprokal>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("AkunEliminasiMapper.selectResiprokal", idjnslapor);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public List<RawData> selectProvRawData(AkunResiprokal obj, SusunKonsolidasi obj2, HeaderDataKonsolidasi obj3,
            String kdpemda) {
        Map<String, Object> map = new HashMap<>();
        map.put("idjnslaporan", obj3.getIdjnslaporan());
        map.put("tahun", obj2.getTahun());
        map.put("kdperiode", obj3.getKodeperiode());
        map.put("kdprov", kdpemda);
        map.put("id_header_data", obj2.getHeader_data_id());
        map.put("kdrek1", obj.getKdlevel1());
        map.put("kdrek2", obj.getKdlevel2());
        map.put("kdrek3", obj.getKdlevel3());
        map.put("kdrek4", obj.getKdlevel4());

//        if (obj.getHeader_id_resipro() == 1) {
//            List<RawData> list = null;
//            session = sqlSessionFactory.openSession();
//            try {
//
//                list = session.selectList("AkunEliminasiMapper.selectCompareProvinsi3", map);
//
//            } finally {
//                session.close();
//            }
//            return list;
//        } else 
        if (obj2.getLevel() == 5 || obj2.getLevel() == 4) {
            List<RawData> list = null;
            session = sqlSessionFactory.openSession();
            try {

                list = session.selectList("AkunEliminasiMapper.selectCompareProvinsi4", map);

            } finally {
                session.close();
            }
            return list;
        } else {
            List<RawData> list = null;
            session = sqlSessionFactory.openSession();
            try {

                list = session.selectList("AkunEliminasiMapper.selectCompareProvinsi3", map);

            } finally {
                session.close();
            }
            return list;
        }

    }

    public List<RawData> selectKabRawData(AkunResiprokal obj, SusunKonsolidasi obj2, HeaderDataKonsolidasi obj3,
            String kdpemda) {
        Map<String, Object> map = new HashMap<>();
        map.put("idjnslaporan", obj3.getIdjnslaporan());
        map.put("tahun", obj2.getTahun());
        map.put("kdperiode", obj3.getKodeperiode());
        map.put("kdprov", kdpemda);
        map.put("id_header_data", obj2.getHeader_data_id());
        map.put("kdrek1", obj.getKdlevel1());
        map.put("kdrek2", obj.getKdlevel2());
        map.put("kdrek3", obj.getKdlevel3());
        map.put("kdrek4", obj.getKdlevel4());

        if (obj2.getLevel() == 5 || obj2.getLevel() == 4) {
            List<RawData> list = null;
            session = sqlSessionFactory.openSession();
            try {
                list = session.selectList("AkunEliminasiMapper.selectCompareKab4", map);

            } finally {
                session.close();
            }
            return list;
        } else {
            List<RawData> list = null;
            session = sqlSessionFactory.openSession();
            try {

                list = session.selectList("AkunEliminasiMapper.selectCompareKab3", map);

            } finally {
                session.close();
            }
            return list;
        }

    }

    public List<AkunEliminasi> selectKdProv1(int idheaderdata) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("AkunEliminasiMapper.selectGrupProvinsi2", idheaderdata);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public List<AkunResiprokal> selectResipro2(int id, String kdpemda) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        Map<String, Object> map = new HashMap<>();
        map.put("idheaderkons", id);
        map.put("kdpemda", kdpemda);
        List<AkunResiprokal> list = new ArrayList<AkunResiprokal>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("AkunEliminasiMapper.selectResiprokal2", map);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public AkunResiprokal selectOpsiNilai(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        AkunResiprokal obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectOpsiNilai", id);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi selectCountKabKota(int idres, String kdprov, int idheader) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("idres", idres);
        map.put("kdpemda", kdprov);
        map.put("idheader", idheader);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectCountKabKota", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi updateProses(AkunEliminasi obj) {

        session = sqlSessionFactory.openSession();
        session.insert("AkunEliminasiMapper.updateOne", obj);
        session.commit();
        session.close();
        return obj;
    }

    // TAMBAHAN RIYAN selectRefAkun2
    // dapatkan jumlah data resipokal berpasangan atau tidak dengan cara count datanya
    public AkunEliminasi selectCountFlag(String kdprov, String flag, int idheader, int idres) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("idHeaderKons", idheader);
        map.put("kdPemda", kdprov);
        map.put("flag", flag);
        map.put("idHeaderResipro", idres);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectCountFlag", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi selectRefAkun1(String kdLvl1, int idbas) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("idBas", idbas);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectRefAkun1", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi selectRefAkun2(String kdLvl1, String kdLvl2, int idbas) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("idBas", idbas);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectRefAkun2", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi selectRefAkun3(String kdLvl1, String kdLvl2, String kdLvl3, int idbas) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("idBas", idbas);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectRefAkun3", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi selectRefAkun4(String kdLvl1, String kdLvl2, String kdLvl3, String kdLvl4, int idbas) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("kdLvl4", kdLvl4);
        map.put("idBas", idbas);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectRefAkun4", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi updateEliminasi(AkunEliminasi obj) {

        session = sqlSessionFactory.openSession();
        session.insert("AkunEliminasiMapper.updateEliminasi", obj);
        session.commit();
        session.close();
        return obj;
    }

    public AkunEliminasi updateEliminasiManual(AkunEliminasi obj) {

        session = sqlSessionFactory.openSession();
        session.insert("AkunEliminasiMapper.updateEliminasiManual", obj);
        session.commit();
        session.close();
        return obj;
    }

    public List<AkunEliminasi> findAllByListNasional(String priode, int idbas, int idjenis, int tahun) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListNasional", map);

        } finally {
            session.close();
        }
        return list;

    }
    
     public List<AkunEliminasi> findAllByListNasionalEksport(String priode, int idbas, int idjenis, int tahun) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListNasionalEksport", map);

        } finally {
            session.close();
        }
        return list;

    }

    public List<AkunEliminasi> findAllByListProv(String priode, int idbas, int idjenis, int tahun, String kdProv) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdProv", kdProv);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListProvinsi", map);

        } finally {
            session.close();
        }
        return list;

    }
    
    public List<AkunEliminasi> findAllByListProvEksport(String priode, int idbas, int idjenis, int tahun, String kdProv) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdProv", kdProv);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListProvinsiEksport", map);

        } finally {
            session.close();
        }
        return list;

    }

    public List<AkunEliminasi> findAllByListWilayah(String priode, int idbas, int idjenis, int tahun, String kdWilayah) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdWilayah", kdWilayah);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListWilayah", map);

        } finally {
            session.close();
        }
        return list;

    }
    
    public List<AkunEliminasi> findAllByListWilayahEksport(String priode, int idbas, int idjenis, int tahun, String kdWilayah) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdWilayah", kdWilayah);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListWilayahEksport", map);

        } finally {
            session.close();
        }
        return list;

    }

    public AkunEliminasi selectEliminasi(String kdLvl1, String kdLvl2, String kdLvl3, int idbas, String kdperiode,
            String kdprov, int idlaporan, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("kdProv", kdprov);
        map.put("idJenis", idlaporan);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectEliminasi", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi selectEliminasiWilayah(String kdLvl1, String kdLvl2, String kdLvl3, int idbas, String kdperiode,
            String kdwil, int idlaporan, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("kdWilayah", kdwil);
        map.put("idJenis", idlaporan);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectEliminasiWilayah", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi selectEliminasiNasional(String kdLvl1, String kdLvl2, String kdLvl3, int idbas, String kdperiode,
            int idlaporan, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("idJenis", idlaporan);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectEliminasiNasional", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi findKodeAkunHeaderLengkap(int tahun, String kdprov, int lvl1, int lvl2, int lvl3, String lvl4,
            String lvl5, int kategoripemdaid, int idbas, int idlap, int idresipro, int idtransfer, int idheaderdata, String kdperiode) {
        Map<String, Object> map = new HashMap<>();
        map.put("tahun", tahun);
        map.put("kdprov", kdprov);
        map.put("kdlevel1", lvl1);
        map.put("kdlevel2", lvl2);
        map.put("kdlevel3", lvl3);
        map.put("kdlevel4", lvl4);
        map.put("kdlevel5", lvl5);
        map.put("idkatpemda", kategoripemdaid);
        map.put("idbas", idbas);
        map.put("idlap", idlap);
        map.put("idresipro", idresipro);
        map.put("idtransfer", idtransfer);
        map.put("idheaderdata", idheaderdata);
        map.put("kdperiode", kdperiode);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectKodeAkunHeaderLengkap", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public List<AkunEliminasi> findAllByListWilayahSummary(String priode, int idbas, int idjenis, int tahun,
            String kdWilayah, int kdlvl1, int kdlvl2) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdWilayah", kdWilayah);
        map.put("kdlvl1", kdlvl1);
        map.put("kdlvl2", kdlvl2);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListWilayahSummary", map);

        } finally {
            session.close();
        }
        return list;

    }

    public List<AkunEliminasi> findAllByListNasionalSummary(String priode, int idbas, int idjenis, int tahun,
            int kdlvl1, int kdlvl2) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdlvl1", kdlvl1);
        map.put("kdlvl2", kdlvl2);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListNasionalSummary", map);

        } finally {
            session.close();
        }
        return list;

    }

    public List<AkunEliminasi> findAllByListProvSummary(String priode, int idbas, int idjenis, int tahun,
            String prov, int kdlvl1, int kdlvl2) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdProv", prov);
        map.put("kdlvl1", kdlvl1);
        map.put("kdlvl2", kdlvl2);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectAllListProvSummary", map);

        } finally {
            session.close();
        }
        return list;

    }

    public List<AkunEliminasi> findAllByListProvLak(String priode, int idjenis, int tahun, String kdProv) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdProv", kdProv);

        if (idjenis == 4) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListProvinsiLak", map);

            } finally {
                session.close();
            }
            return list;
        } else if (idjenis == 5) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListProvinsiLpe", map);

            } finally {
                session.close();
            }
            return list;
        } else if (idjenis == 6) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListProvinsiLpsal", map);

            } finally {
                session.close();
            }
            return list;
        } else {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();
            return list;
        }

    }

    public List<AkunEliminasi> findAllByListWilayahLak(String priode, int idjenis, int tahun, String kdWilayah) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdWilayah", kdWilayah);

        if (idjenis == 4) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListWilayahLak", map);

            } finally {
                session.close();
            }
            return list;
        } else if (idjenis == 5) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListWilayahLpe", map);

            } finally {
                session.close();
            }
            return list;
        } else if (idjenis == 6) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListWilayahLpsal", map);

            } finally {
                session.close();
            }
            return list;
        } else {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();
            return list;
        }

    }

    public List<AkunEliminasi> findAllByListNasionalLak(String priode, int idjenis, int tahun) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);

        if (idjenis == 4) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListNasionalLak", map);

            } finally {
                session.close();
            }
            return list;
        } else if (idjenis == 5) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListNasionalLpe", map);

            } finally {
                session.close();
            }
            return list;
        } else if (idjenis == 6) {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

            try {
                list = session.selectList("AkunEliminasiMapper.selectAllListNasionalLpsal", map);

            } finally {
                session.close();
            }
            return list;
        } else {
            session = sqlSessionFactory.openSession();
            List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();
            return list;
        }

    }

    public AkunEliminasi findNasional(String priode, int idbas, int idjenis, int tahun) {
        Map<String, Object> map = new HashMap<>();
        map.put("tahun", tahun);
        map.put("idbas", idbas);
        map.put("idlap", idjenis);
        map.put("kdperiode", priode);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectNasional", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public List<AkunEliminasi> findAllByListProvSummaryEliminasi(String priode, int idbas, int idjenis, int tahun,
            String prov, int kdlvl1, int kdlvl2) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdProv", prov);
        map.put("kdlvl1", kdlvl1);
        map.put("kdlvl2", kdlvl2);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectEliminasiProv", map);

        } finally {
            session.close();
        }
        return list;

    }

    public List<AkunEliminasi> findAllByListNasionalSummaryEliminasi(String priode, int idbas, int idjenis, int tahun,
            int kdlvl1, int kdlvl2) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdlvl1", kdlvl1);
        map.put("kdlvl2", kdlvl2);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectEliminasiNasionalSummary", map);

        } finally {
            session.close();
        }
        return list;

    }

    public List<AkunEliminasi> findAllByListWilayahSummaryEliminasi(String priode, int idbas, int idjenis, int tahun,
            String kdwilayah, int kdlvl1, int kdlvl2) {

        Map<String, Object> map = new HashMap<>();
        map.put("idPriode", priode);
        map.put("idBas", idbas);
        map.put("idJenis", idjenis);
        map.put("tahun", tahun);
        map.put("kdWilayah", kdwilayah);
        map.put("kdlvl1", kdlvl1);
        map.put("kdlvl2", kdlvl2);

        session = sqlSessionFactory.openSession();
        List<AkunEliminasi> list = new ArrayList<AkunEliminasi>();

        try {
            list = session.selectList("AkunEliminasiMapper.selectEliminasiWilayahSummary", map);

        } finally {
            session.close();
        }
        return list;

    }

    public void deleteBySusun(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.delete("AkunEliminasiMapper.deleteBySusun", id);
        session.commit();
        session.close();
    }

    public AkunEliminasi selectEliminasiCari(String kdLvl1, String kdLvl2, String kdLvl3, String kdLvl4, int idbas, String kdperiode,
            String kdprov, int idlaporan, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("kdLvl4", kdLvl4);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("kdProv", kdprov);
        map.put("idJenis", idlaporan);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectEliminasiCari", map);

        } finally {
            session.close();
        }
        return obj;
    }

    public AkunEliminasi selectRawDataCari(String kdLvl1, String kdLvl2, String kdLvl3,String kdLvl4, int idbas, String kdperiode,
            String kdprov, int idlaporan, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("kdLvl4", kdLvl4);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("kdProv", kdprov);
        map.put("idJenis", idlaporan);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        AkunEliminasi obj = null;
        try {
            obj = session.selectOne("AkunEliminasiMapper.selectRawDataCari", map);

        } finally {
            session.close();
        }
        return obj;
    }

}
