package cn.cecep.talroad.service.impl;

import cn.cecep.talroad.domain.MonDevBlHour;
import cn.cecep.talroad.mapper.MonDevBlHourMapper;
import cn.cecep.talroad.service.IMonDevBlHourService;
import cn.cecep.talroad.vo.MonDevBlVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;




/**
 * 设备数据-玻璃-小时 保存设备的小时数据Service业务层处理
 *
 * @author szhpt
 * @date 2023-01-10*/
@Service
public class MonDevBlHourServiceImpl extends ServiceImpl<MonDevBlHourMapper,MonDevBlHour> implements IMonDevBlHourService
{
    @Autowired
    private MonDevBlHourMapper monDevBlHourMapper;

    /**
     * 查询设备数据-玻璃-小时 保存设备的小时数据列表
     *
     * @param monDevBlHour 设备数据-玻璃-小时 保存设备的小时数据
     * @return 设备数据-玻璃-小时 保存设备的小时数据
     */
    @Override
    public List<MonDevBlHour> selectMonDevBlHourList(MonDevBlHour monDevBlHour)
    {
        return monDevBlHourMapper.selectMonDevBlHourList(monDevBlHour);
    }

    @Override
    public List<MonDevBlVO> getDataPage(String factoryId, List<String> deviceIds, String startTime, String endTime, String orderField, String orderType, Page page) {
        QueryWrapper<MonDevBlVO> queryWrapper = new QueryWrapper<MonDevBlVO>()
                .eq("r.factory_id", factoryId)
                .in("r.device_id", deviceIds)
                .ge("r.data_time", startTime)
                .le("r.data_time", endTime)
                .orderBy(StringUtils.isNotEmpty(orderField), "asc".equals(orderType), orderField, "r.data_id");
        return baseMapper.getDataPage(page, queryWrapper);
    }

}
