package com.eactive.eai.rms.onl.manage.inflow.history;

import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.eactive.eai.data.entity.onl.inflow.InflowControlLog;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.inflow.InflowControlLogService;

@Service
public class InflowControlHistoryManService extends BaseService {
	
	@Autowired
	InflowControlLogService service;
	
	@Autowired
	InflowControlHistoryManMapper mapper;
	
//	public Page<InflowControlHistoryManUI> selectList(Pageable pageable, InflowControlHistoryManUISearch uiSearch) {
//		return service.findAll(pageable, uiSearch).map(mapper::toVo);
//	}
	
	
	public Page<InflowControlHistoryManUI> selectList(Pageable pageable, InflowControlHistoryManUISearch uiSearch) {
		return service.selectList(pageable, uiSearch);
	}
	
	public List<HashMap<String, Object>> selectListToExcel(InflowControlHistoryManUISearch uiSearch) {
		Iterable<InflowControlLog> entityItr = service.findAll(uiSearch);
		return StreamSupport.stream(entityItr.spliterator(), false).map(entity -> {
			HashMap<String, Object> row = new HashMap<>();
			row.put("eaibzwkdstcd", entity.getId().getEaibzwkdstcd());
			row.put("eaisvcserno", entity.getId().getEaisvcserno());
			row.put("msgdpstyms", entity.getId().getMsgdpstyms());
			row.put("adptrbzwkgroupname", entity.getAdptrbzwkgroupname());
			row.put("eaisevrinstncname", entity.getEaisevrinstncname());
			row.put("eaisvcname", entity.getEaisvcname());
			row.put("threshold", entity.getThreshold());
			row.put("thresholdpersecond", entity.getThresholdpersecond());
			row.put("thresholdtimeunit", entity.getThresholdtimeunit());
			return row;
		}).collect(Collectors.toList());
	}
}
