/**
 *
 */
package com.huatek.busi.service.impl;

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.entity.BusiEquipmentRelationship;
import com.huatek.busi.mapper.BusiEquipmentRelationshipMapper;
import com.huatek.busi.service.BusiEquipmentRelationshipService;
import com.huatek.busi.vo.TransformerTmpVo;

/**
 * @ClassName: BusiEquipmentRelationshipdServiceImpl
 * @FullClassPath: com.huatek.busi.service.impl.
 *                 BusiEquipmentRelationshipdServiceImpl
 * @Description: 主设备关系服务.
 * @author: Arno
 * @date: Aug 21, 2019 2:06:38 PM
 * @version: 1.0
 */
@Component
@Service(interfaceClass = BusiEquipmentRelationshipService.class)
@Transactional(rollbackFor = Exception.class)
public class BusiEquipmentRelationshipServiceImpl implements BusiEquipmentRelationshipService {

    @Autowired
    private BusiEquipmentRelationshipMapper busiEquipmentRelationshipMapper;

    @Override
    public BusiEquipmentRelationship findByEquipmentId(String equipmentId) {
        return busiEquipmentRelationshipMapper.selectByEquipmentId(equipmentId);
    }

    @Override
    public Boolean insertBusiEquipmentRelationship(BusiEquipmentRelationship entity) {
//		String equipmentId = entity.getEquipmentId();
//		BusiEquipmentRelationship find = this.findByEquipmentId(equipmentId);
        busiEquipmentRelationshipMapper.insertRelationship(entity);
        return true;
    }

    @Override
    public List<TransformerTmpVo> getCurrentTransformerInfo(String equipmentId) {
        return busiEquipmentRelationshipMapper.selectCurrentTransformerInfo(equipmentId);
    }

    public List<TransformerTmpVo> getCurrentTransformerInfo2(String equipmentId) {
        return busiEquipmentRelationshipMapper.selectCurrentTransformerInfo2(equipmentId);
    }

    @Override
    public Boolean cancelBusiEquipmentRelationship(BusiEquipmentRelationship entity) {
        return busiEquipmentRelationshipMapper.cancelRelationship(entity) > 0 ? true : false;
    }
}
