package com.gyee.alarm.service.auto.impl;

import com.gyee.alarm.model.auto.ProBasicDeviceFaultMode;
import com.gyee.alarm.mapper.auto.ProBasicDeviceFaultModeMapper;
import com.gyee.alarm.service.auto.IProBasicDeviceFaultModeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gyee.alarm.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 设备故障模型 服务实现类
 * </p>
 *
 * @author shilin
 * @since 2023-08-01
 */
@Service
public class ProBasicDeviceFaultModeServiceImpl extends ServiceImpl<ProBasicDeviceFaultModeMapper, ProBasicDeviceFaultMode> implements IProBasicDeviceFaultModeService {

    @Resource
    private  ProBasicDeviceFaultModeMapper proBasicDeviceFaultModeMapper;

    public ProBasicDeviceFaultMode getDeviceFaultModeByCode(String code)
    {
        ProBasicDeviceFaultMode vo=new ProBasicDeviceFaultMode();
        if(StringUtils.notEmp(code))
        {
            vo=  proBasicDeviceFaultModeMapper.getDeviceFaultModeByCode(code);
        }

        return vo;
    }

    public List<ProBasicDeviceFaultMode> getDeviceFaultModeByDeviceId(String deviceId)
    {
        List<ProBasicDeviceFaultMode> vos=new ArrayList<>();

        if(StringUtils.notEmp(deviceId))
        {
            vos=proBasicDeviceFaultModeMapper.getDeviceFaultModeByDeviceId(deviceId);
        }
        return vos;
    }

    public List<ProBasicDeviceFaultMode> getDeviceFaultModeByStructureCode(String deviceId,String structureCode)
    {
        List<ProBasicDeviceFaultMode> vos=new ArrayList<>();
        if(StringUtils.empty(deviceId))
        {
            deviceId=null;
        }
        if(StringUtils.empty(structureCode))
        {
            structureCode=null;
        }
        vos=proBasicDeviceFaultModeMapper.getDeviceFaultModeByStructureCode(deviceId,structureCode);

        return vos;
    }

    public ProBasicDeviceFaultMode getDeviceFaultModeTree(String deviceId,String nodeCode)
    {
        ProBasicDeviceFaultMode vo=new ProBasicDeviceFaultMode();
        if(StringUtils.empty(deviceId))
        {
            deviceId=null;
        }
        if(StringUtils.empty(nodeCode))
        {
            nodeCode=null;
        }
        vo=  proBasicDeviceFaultModeMapper.getDeviceFaultModeTree(deviceId,nodeCode);

        return vo;
    }
}
