package com.zhongshu.card.server.core.service.statistics;

import com.zhongshu.card.client.model.devices.DeviceInfoSearch;
import com.zhongshu.card.client.type.OnLineState;
import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
import com.zhongshu.card.server.core.service.base.SuperService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 设备统计
 *
 * @author TRX
 * @date 2024/12/12
 */
@Slf4j
@Service
public class DeviceStatisticsService extends SuperService {

    @Autowired
    private DeviceInfoDao deviceInfoDao;

    /**
     * 查询项目所有的设备数量
     *
     * @param projectOid
     * @return
     */
    public long countProjectAllDevice(String projectOid) {
        DeviceInfoSearch param = new DeviceInfoSearch();
        param.setProjectOid(projectOid);
        return deviceInfoDao.count(param);
    }

    /**
     * 查询项目设备在线的数量
     *
     * @param projectOid
     * @return
     */
    public long countProjectOnlineDevice(String projectOid) {
        DeviceInfoSearch param = new DeviceInfoSearch();
        param.setProjectOid(projectOid);
        param.setOnLineState(OnLineState.OnLine);
        return deviceInfoDao.count(param);
    }

}
