package com.madeu.dao.web.webstocksum;

import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import jakarta.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class WebStockSumSqlMapDAO extends SqlSessionDaoSupport{

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 현재고 재고품목수, 품목별 재고수, 거래처수, 재고총액 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalStockSumCompany(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumCompany START");
		String sqlId = "WebStockSum.selectTotalStockSumCompany";
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumCompany END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 현재 재고 제품별 거래처 리스트 총 갯수 (COUNT)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalStockSumCompanyCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumCompanyCount START");
		String sqlId = "WebStockSum.selectTotalStockSumCompanyCount";
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumCompanyCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 현재 재고 제품별 거래처 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockSumCompany(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectListStockSumCompany START");
		String sqlId = "WebStockSum.selectListStockSumCompany";
		logger.debug("WebStockSumSqlMapDAO selectListStockSumCompany END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 현재 재고 제품별 거래처 리스트 조회 (List, Excel)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockSumCompanyExcel(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectListStockSumCompanyExcel START");
		String sqlId = "WebStockSum.selectListStockSumCompanyExcel";
		logger.debug("WebStockSumSqlMapDAO selectListStockSumCompanyExcel END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 현재고 상세 제품명, 거래처, 평균 입고단가, 재고수량, 재고총액 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalStockSumCompanyHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumCompanyHistory START");
		String sqlId = "WebStockSum.selectTotalStockSumCompanyHistory";
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumCompanyHistory END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 현재 재고 제품별 거래처 - 상세 리스트 총 갯수 (COUNT)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalStockSumCompanyHistoryCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumCompanyHistoryCount START");
		String sqlId = "WebStockSum.selectTotalStockSumCompanyHistoryCount";
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumCompanyHistoryCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 현재 재고 제품별 거래처 - 상세 리스트 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockSumCompanyHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectListStockSumCompanyHistory START");
		String sqlId = "WebStockSum.selectListStockSumCompanyHistory";
		logger.debug("WebStockSumSqlMapDAO selectListStockSumCompanyHistory END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 제품별 실시간 재고 현황 총갯수 (재고조정 화면) (COUNT)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalStockSumAdjustmentCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumAdjustmentCount START");
		String sqlId = "WebStockSum.selectTotalStockSumAdjustmentCount";
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumAdjustmentCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 제품별 실시간 재고 현황 리스트 (재고조정 화면) (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockSumAdjustment(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectListStockSumAdjustment START");
		String sqlId = "WebStockSum.selectListStockSumAdjustment";
		logger.debug("WebStockSumSqlMapDAO selectListStockSumAdjustment END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 제품별 실시간 재고 현황 리스트 (재고조정 화면) (List, Excel)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockSumAdjustmentExcel(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectListStockSumAdjustmentExcel START");
		String sqlId = "WebStockSum.selectListStockSumAdjustmentExcel";
		logger.debug("WebStockSumSqlMapDAO selectListStockSumAdjustmentExcel END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 제품별 실시간 재고 현황 상세 총갯수 (재고조정 팝업 화면) (COUNT)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalStockSumAdjustmentDetailCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumAdjustmentDetailCount START");
		String sqlId = "WebStockSum.selectTotalStockSumAdjustmentDetailCount";
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumAdjustmentDetailCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 제품별 실시간 재고 현황 상세 리스트 (재고조정 팝업 화면) (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockSumAdjustmentDetail(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectListStockSumAdjustmentDetail START");
		String sqlId = "WebStockSum.selectListStockSumAdjustmentDetail";
		logger.debug("WebStockSumSqlMapDAO selectListStockSumAdjustmentDetail END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 현재 재고 확인 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockSum(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectListStockSum START");
		String sqlId = "WebStockSum.selectListStockSum";
		logger.debug("WebStockSumSqlMapDAO selectListStockSum END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 현재 재고 수량 확인
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalStockSumQuantity(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumQuantity START");
		String sqlId = "WebStockSum.selectTotalStockSumQuantity";
		logger.debug("WebStockSumSqlMapDAO selectTotalStockSumQuantity END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 입고일자에 등록된 게 잇는 지 확인 (COUNT)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> checkStockSumIn(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO checkStockSumIn START");
		String sqlId = "WebStockSum.checkStockSumIn";
		logger.debug("WebStockSumSqlMapDAO checkStockSumIn END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 재고 SUM 정보 (현재고) 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertStockSum(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO insertStockSum START");
		String sqlId = "WebStockSum.insertStockSum";
		logger.debug("WebStockSumSqlMapDAO insertStockSum END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 재고 SUM 정보 (현재고) 등록 2 (재고조정)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertStockSum2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO insertStockSum2 START");
		String sqlId = "WebStockSum.insertStockSum2";
		logger.debug("WebStockSumSqlMapDAO insertStockSum2 END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 재고 SUM 정보 (현재고) 수정
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateStockSum(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO updateStockSum START");
		String sqlId = "WebStockSum.updateStockSum";
		logger.debug("WebStockSumSqlMapDAO updateStockSum END");
		return getSqlSession().update(sqlId, paramMap);
	}
	/**
	 * 재고 SUM 정보 (현재고) 수정 (재고조정)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateStockSum2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockSumSqlMapDAO updateStockSum2 START");
		String sqlId = "WebStockSum.updateStockSum2";
		logger.debug("WebStockSumSqlMapDAO updateStockSum2 END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
