package incheon.res.rdm.com.unitcst.service.impl;

import incheon.res.rdm.com.pjtplan.mapper.RdmComPjtplanMapper;
import incheon.res.rdm.com.pjtplan.vo.RdmComPjtplanVO;
import incheon.res.rdm.com.unitcst.mapper.RdmComUnitcstMapper;
import incheon.res.rdm.com.unitcst.service.RdmComUnitcstService;
import incheon.res.rdm.com.unitcst.vo.RdmComUnitcst;
import incheon.res.rdm.com.unitcst.vo.RdmComUnitcstVO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.egovframe.rte.psl.dataaccess.util.EgovMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RdmComUnitcstServiceImpl extends EgovAbstractServiceImpl implements RdmComUnitcstService {

	protected Log log = LogFactory.getLog(this.getClass());
	
	@Autowired
    private RdmComUnitcstMapper rdmComUnitcstMapper;

	@Autowired
    private RdmComPjtplanMapper rdmComPjtplanMapper;
	
	/**
	 * @MethodDESC : 목록조회
	 */
	@Override
	public List selectUnitcstList(RdmComUnitcstVO vo) throws Exception{
		String mngCde = vo.getMngInstCd();
		
		RdmComPjtplanVO guifParam = new RdmComPjtplanVO();
		List guifList = rdmComPjtplanMapper.selectMngCdeList(guifParam);
		String _mngCde = (String)((EgovMap)guifList.get(0)).get("mngCde");
		
		if(mngCde.equalsIgnoreCase(_mngCde)){
			vo.setMngInstCd("");
		}
		return rdmComUnitcstMapper.selectUnitcstList(vo);
	}
	
	/**
	 * @MethodDESC : 사업예정지 변경이력
	 */
	@Override
	public List selectUnitcstHistory(RdmComUnitcstVO vo) throws Exception{
		return rdmComUnitcstMapper.selectUnitcstHistory(vo);
	}
	
	/**
	 * @MethodDESC : 굴착예정지 목록 조회
	 */
	@Override
	public List selectUnitcstListAll(RdmComUnitcstVO vo) throws Exception{
		return rdmComUnitcstMapper.selectUnitcstListAll(vo);
	}
	
	/**
	 * @MethodDESC : 상세조회
	 */
	@Override
	public RdmComUnitcst selectUnitcst(RdmComUnitcstVO vo) throws Exception{
		return rdmComUnitcstMapper.selectUnitcst(vo);
	}
	
	/**
	 * @MethodDESC : 굴착 규모정보 목록
	 */
	@Override
	public List selectScaleList(RdmComUnitcstVO vo) throws Exception{
		return rdmComUnitcstMapper.selectScaleList(vo);
	}

	@Override
	public List selectPlanUnitcstList(RdmComUnitcstVO vo) throws Exception{
		return rdmComUnitcstMapper.selectPlanUnitcstList(vo);
	}
	
	/**
	 * @MethodDESC : 목록 카운트 조회
	 */
	@Override
	public int countList(RdmComUnitcstVO vo) throws Exception{
		return rdmComUnitcstMapper.countList(vo);
	}
	
	/**
	 * @MethodDESC : 심의의견 등록 및 수정
	 */
	@Override
	public int updateUnitcstDbt(RdmComUnitcstVO vo) throws Exception{
		return rdmComUnitcstMapper.updateUnitcstDbt(vo);
	}
	
	/**
	 * @MethodDESC : 변경이력 입력
	 */
	@Override
	public void insertUnitHistory(RdmComUnitcstVO vo) throws Exception{
		rdmComUnitcstMapper.insertUnitHistory(vo);
	}
	
	/**
	 * @MethodDESC : 변경이력 카운트
	 */
	@Override
	public RdmComUnitcst selectHistoryCount(RdmComUnitcstVO vo) throws Exception{
		return rdmComUnitcstMapper.selectHistoryCount(vo);
	}
}