package com.fs.watch.service.impl;

import com.fs.company.domain.Company;
import com.fs.watch.domain.WatchDeviceStatus;
import com.fs.watch.mapper.WatchDeviceStatusMapper;
import com.fs.watch.service.WatchDeviceStatusService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 设备原始回传信息记录(WatchDeviceStatus)表服务实现类
 *
 * @author makejava
 * @since 2024-12-17 15:11:06
 */
@Service("watchDeviceStatusService")
@Slf4j
public class WatchDeviceStatusServiceImpl implements WatchDeviceStatusService {
    @Autowired
    private WatchDeviceStatusMapper watchDeviceStatusMapper;


    /**
     * 新增数据
     *
     * @param watchDeviceStatus 实例对象
     * @return 实例对象
     */
    @Override
    public Boolean insert(WatchDeviceStatus watchDeviceStatus) {
        Integer num = watchDeviceStatusMapper.queryByCreateTime(watchDeviceStatus.getEventtime());
        if (num != null && num > 0) {
            return false;
        }
        try {
            watchDeviceStatusMapper.insert(watchDeviceStatus);
        } catch (Exception e) {
            log.error(e.getMessage());
            return false;
        }
        return true;
    }

    @Override
    public WatchDeviceStatus getLastByDeviceId(String deviceId) {
        return watchDeviceStatusMapper.getLastByDeviceId(deviceId);
    }

}
