package com.gonghang.h5clientapp.service;

import com.gonghang.h5clientapp.beans.dto.RobotWarningDTO;
import com.gonghang.h5clientapp.dao.RobotWarningMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by shiwn on 2022/8/3 15:44
 */
@Service
public class RobotWarningServiceImpl implements RobotWarningService {
    @Autowired
    private RobotWarningMapper robotWarningMapper;

    /**
     * @Description: 判断机器人是否自检告警
     * @Date: 2022/7/5 10:08
     * @Author: shiwn
     * @Param: [robotIp]
     * @Return: true-告警，false-不告警
     */
    @Override
    public Boolean getStatus(String robotIp) {
        boolean status = false;
        //  查询最新的告警记录
        RobotWarningDTO dto = robotWarningMapper.selectNewOne(robotIp);
        //  判断是否告警
        if (dto == null) {
            return status;
        }
        if (!dto.getFaultCode().equals("000")) {
            status = true;
        }
        //  返回
        return status;
    }
}
