package com.eactive.eai.common.logger.mapper;

import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

import com.eactive.eai.common.monitor.StatMonitorLogVO;
import com.eactive.eai.data.entity.onl.logger.StatLog;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;

@Mapper(config = BaseMapperConfig.class)
public interface StatLogMapper extends GenericMapper<StatMonitorLogVO, StatLog> {

	@Mapping(source = "id.baseymd", target = "ymd")
	@Mapping(source = "id.basehh", target = "hour")
	@Mapping(source = "id.basehhmm", target = "min")
	@Mapping(source = "id.eaibzwkdstcd", target = "bzwkDstcd")
	@Mapping(source = "id.eaisvcname", target = "svcName")
	@Mapping(source = "id.eaisevrinstncname", target = "sevrInstncName")
	@Mapping(source = "eaiprcssttmval", target = "prcssTtmVal", qualifiedByName = "devide")
	@Mapping(source = "eaipsvprcssttmval", target = "psvPrcssTtmVal", qualifiedByName = "devide")
	@Mapping(source = "eaitotalprcssttmval", target = "totalPrcssTtmVal", qualifiedByName = "devide")
	@Mapping(source = "wholprcssnoitm", target = "wholPrcssNoitm")
	@Mapping(source = "errznoitm", target = "errzNoitm")
	@Mapping(source = "toutnoitm", target = "toutNoitm")
	@Mapping(source = "nomalnoitm", target = "nomalNoitm")
	@Override
	StatMonitorLogVO toVo(StatLog entity);

	@Named("devide")
	default Double devide(Double org) {
		return org / 1000;
	}

	@InheritInverseConfiguration
	@Override
	StatLog toEntity(StatMonitorLogVO vo);

}
