package cn.cecep.talroad.service.impl;

import cn.cecep.talroad.domain.MonDevJhOther;
import cn.cecep.talroad.mapper.MonDevJhOtherMapper;
import cn.cecep.talroad.service.IMonDevJhOtherService;
import cn.cecep.talroad.vo.MonDevJhVO;
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 MonDevJhOtherServiceImpl extends ServiceImpl<MonDevJhOtherMapper,MonDevJhOther> implements IMonDevJhOtherService
{
    @Autowired
    private MonDevJhOtherMapper monDevJhOtherMapper;

    /**
     * 查询设备数据-焦化-其它时间 保存设备的小时以上的数据列表
     *
     * @param monDevJhOther 设备数据-焦化-其它时间 保存设备的小时以上的数据
     * @return 设备数据-焦化-其它时间 保存设备的小时以上的数据
     */
    @Override
    public List<MonDevJhOther> selectMonDevJhOtherList(MonDevJhOther monDevJhOther)
    {
        return monDevJhOtherMapper.selectMonDevJhOtherList(monDevJhOther);
    }

    @Override
    public List<MonDevJhVO> getDataPage(String factoryId, List<String> deviceIds, String timeType, String startTime, String endTime, String orderField, String orderType, Page page) {
        QueryWrapper<MonDevJhVO> queryWrapper = new QueryWrapper<MonDevJhVO>()
                .eq("r.factory_id", factoryId)
                .in("r.device_id", deviceIds)
                .eq("r.time_type", timeType)
                .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);
    }

}
