package com.huatek.busi.service.impl.transformer;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Service;
import com.huatek.busi.dao.TransformerEpaAbsIncreaseStatisticsDao;
import com.huatek.busi.entity.TransformerEpaAbsIncreaseStatistics;
import com.huatek.busi.mapper.TransformerEpaAbsIncreaseStatisticsMapper;
import com.huatek.busi.service.transformer.TransformerEpaAbsIncreaseStatisticsService;
import com.huatek.frame.base.util.BeanUtils;

/**
 * 变压器油色谱绝对产气速率统计 ServiceImpl
 *
 * @author anker_cheng
 * @date Sep 26, 2019 8:59:07 PM
 */
@Component
@Service(interfaceClass = TransformerEpaAbsIncreaseStatisticsService.class)
@Transactional(rollbackFor = Exception.class)
public class TransformerEpaAbsIncreaseStatisticsServiceImpl implements TransformerEpaAbsIncreaseStatisticsService {

    @Autowired
    private TransformerEpaAbsIncreaseStatisticsMapper transformerEpaAbsIncreaseStatisticsMapper;
    @Autowired
    private TransformerEpaAbsIncreaseStatisticsDao transformerEpaAbsIncreaseStatisticsDao;

    @Override
    public void saveTransformerEpaAbsIncreaseStatistics(LocalDateTime dateTime,
        TransformerEpaAbsIncreaseStatistics param) {
        TransformerEpaAbsIncreaseStatistics transformerEpaAbsIncreaseStatistics =
            transformerEpaAbsIncreaseStatisticsMapper.getTransformerEpaAbsIncreaseStatistics(param);
        if (transformerEpaAbsIncreaseStatistics == null) {
            transformerEpaAbsIncreaseStatistics = new TransformerEpaAbsIncreaseStatistics();
        }
        BeanUtils.copyPropertiesWithIgnoreNull(param, transformerEpaAbsIncreaseStatistics);
        transformerEpaAbsIncreaseStatisticsDao.saveOrUpdate(transformerEpaAbsIncreaseStatistics);
    }

    @Override
    public Map<String, Object> getGrowthRateMap(String sensorCode, LocalDate day) {
         return transformerEpaAbsIncreaseStatisticsMapper.getGrowthRateMap(sensorCode, day);
    }
}