package com.huatek.busi.service.impl;

import java.time.LocalDateTime;

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.BusiTransformerCorrectDao;
import com.huatek.busi.entity.BusiTransformerCorrect;
import com.huatek.busi.entity.TransformerEpaDataStatistics;
import com.huatek.busi.mapper.BusiTransformerCorrectMapper;
import com.huatek.busi.service.BusiTransformerCorrectService;
import com.huatek.torch.util.uuid.Uuid;

/**
 * 变压器例行修正值（按天） ServiceImpl
 *
 * @author anker_cheng
 * @date Jul 15, 2019 11:13:56 AM
 */
@Component
@Service(interfaceClass = BusiTransformerCorrectService.class)
@Transactional(rollbackFor = Exception.class)
public class BusiTransformerCorrectServiceImpl implements BusiTransformerCorrectService {

    @Autowired
    private BusiTransformerCorrectMapper busiTransformerCorrectMapper;
    @Autowired
    private BusiTransformerCorrectDao busiTransformerCorrectDao;
	@Override
	public BusiTransformerCorrect findBySubEquipmentId(String siteId, String subEquipmentId) {
		return busiTransformerCorrectMapper.findBySubEquipmentId(siteId, subEquipmentId);
	}

    @Override
    public void saveBusiTransformerCorrect(LocalDateTime dateTime, TransformerEpaDataStatistics param) {
        BusiTransformerCorrect t = new BusiTransformerCorrect();
        t.setC2h2(param.getC2h2());
        t.setC2h4(param.getC2h4());
        t.setC2h6(param.getC2h6());
        t.setCh4(param.getCh4());
        t.setCo(param.getCo2());
        t.setCo2(param.getCo2());
        t.setCorrectTime(dateTime);
        t.setH2(param.getH2());
        t.setH2o(param.getH2o());
        t.setTotalHydrocarbon(param.getTotalHydrocarbon());
        t.setSiteId(param.getSiteId());
        t.setEquipmentId(param.getEquipmentId());
        t.setMainEquipmentId(param.getMainEquipmentId());
        t.setSubEquipmentId(param.getSubEquipmentId());
        t.setId(Uuid.getUUID());
        t.setMainTreeId(param.getMainTreeId());
        t.setSubTreeId(param.getSubTreeId());
        busiTransformerCorrectDao.add(t);
    }

}