package com.eactive.eai.rms.bap.tansaction.procWork;

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

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

import com.eactive.eai.rms.bap.common.base.BapBaseService;

@Service("bapProcWorkService")
public class BapProcWorkService extends BapBaseService {

	@Autowired
	@Qualifier("bapProcWorkDao")
	private BapProcWorkDao dao;

	public HashMap<String, Object> selectList(int startNum, int endNum, HashMap<String, Object> paramMap) throws Exception {
		// 전체 목록수 얻기
		int totalCount = dao.selectListCount(paramMap);

		paramMap.put("startNum" , startNum);// 시작 record
		paramMap.put("endNum"   , endNum);// 끝 record
		
		List<Map<String, Object>> list = dao.selectList(paramMap);

		HashMap<String, Object> map = new HashMap<String, Object>();

		map.put("totalCount", totalCount);

		map.put("list", list);

		return map;
	}	

	public HashMap<String, Object> selectDetail(HashMap<String, Object> param) throws Exception {

		HashMap<String, Object> detail = dao.selectDetail(param);

		String sndrcvStartHMS = (String)detail.get("SNDRCVSTARTHMS");
		String sndrcvEndHMS = (String)detail.get("SNDRCVENDHMS");
		String bjobDmndMsgCretnHMS = (String)detail.get("BJOBDMNDMSGCRETNHMS");
		String msgQueeTracTdmndHMS = (String)detail.get("MSGQUEETRACTDMNDHMS");
		
		detail.put("SNDRCVSTARTYMD", sndrcvStartHMS.substring(0, 8));
		detail.put("SNDRCVSTARTHMS", sndrcvStartHMS.substring(8));
		detail.put("SNDRCVENDYMD", sndrcvEndHMS.substring(0, 8));
		detail.put("SNDRCVENDHMS", sndrcvEndHMS.substring(8));
		detail.put("BJOBDMNDMSGCRETNYMD", bjobDmndMsgCretnHMS.substring(0, 8));
		detail.put("BJOBDMNDMSGCRETNHMS", bjobDmndMsgCretnHMS.substring(8));
		detail.put("MSGQUEETRACTDMNDYMD", msgQueeTracTdmndHMS.substring(0, 8));
		detail.put("MSGQUEETRACTDMNDHMS", msgQueeTracTdmndHMS.substring(8));
		
		HashMap<String, Object> map = new HashMap<String, Object>();

		map.put("detail", detail);

		return map;

	}
	
	public void delete(HashMap paramMap) throws Exception {
		dao.delete(paramMap);
	}

}