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

import java.time.LocalDateTime;
import java.util.List;

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.TransformerEpaDeviationDao;
import com.huatek.busi.entity.TransformerEpaData;
import com.huatek.busi.entity.TransformerEpaDeviation;
import com.huatek.busi.mapper.TransformerEpaDeviationMapper;
import com.huatek.busi.service.transformer.TransformerEpaDeviationService;
import com.huatek.busi.vo.epa.EpaDeviationOneDataVo;

/**
 * 变压器油色谱数据偏差率（实时数据） ServiceImpl
 *
 * @author anker_cheng
 * @date Jul 15, 2019 11:49:08 AM
 */
@Component
@Service(interfaceClass = TransformerEpaDeviationService.class)
@Transactional(rollbackFor = Exception.class)
public class TransformerEpaDeviationServiceImpl implements TransformerEpaDeviationService {

    @Autowired
    private TransformerEpaDeviationMapper transformerEpaDeviationMapper;
    @Autowired
    private TransformerEpaDeviationDao transformerEpaDeviationDao;

    @Override
    public int saveTransformerEpaDeviation(TransformerEpaDeviation entity) {
        return transformerEpaDeviationDao.saveOrUpdate(entity);
    }

    @Override
    public int saveTransformerEpaDeviation(TransformerEpaDeviation entity, TransformerEpaData cacEntity) {
        entity.setEquipmentId(cacEntity.getEquipmentId());
        entity.setMainEquipmentId(cacEntity.getMainEquipmentId());
        entity.setSubEquipmentId(cacEntity.getSubEquipmentId());
        entity.setSiteId(cacEntity.getSiteId());
        entity.setMainTreeId(cacEntity.getMainTreeId());
        entity.setSubTreeId(cacEntity.getSubTreeId());
        entity.setSensorCode(cacEntity.getSensorId());
        return saveTransformerEpaDeviation(entity);
    }

    @Override
    public List<EpaDeviationOneDataVo> getOneData(LocalDateTime startTime, LocalDateTime endTime) {
        return transformerEpaDeviationMapper.getOneData(startTime, endTime);
    }

	@Override
	public TransformerEpaDeviation getEpaDeviation(String sensorCode) {
		// TODO Auto-generated method stub
		return transformerEpaDeviationMapper.getEpaDeviationInfo(sensorCode);
	}
}