package com.cpp.web.service.station.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cpp.web.domain.station.WindTurbineStatusData;
import com.cpp.web.mapper.station.WindTurbineStatusDataMapper;
import com.cpp.web.service.station.WindTurbineStatusDataService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 风机数据业务层实现类
 *
 * @author tl
 * @date 2022-05-11 18:07:03
 */
@Service
public class WindTurbineStatusDataServiceImpl extends ServiceImpl<WindTurbineStatusDataMapper, WindTurbineStatusData> implements WindTurbineStatusDataService {
    @Override
    public QueryWrapper<WindTurbineStatusData> getByStationCodeAndEquipmentIdAndTimeBetween(String stationCode, String equipmentId, Date startTime, Date endTime) {
        QueryWrapper<WindTurbineStatusData> wrapper = new QueryWrapper<>();
        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("station_code", stationCode);
        }

        if (equipmentId != null && !equipmentId.equals("")) {
            wrapper.in("equipment_id", Arrays.asList(equipmentId.split(",")));
        }
        if (startTime != null && !startTime.equals("") && endTime != null && !endTime.equals("")) {
            wrapper.between("time", startTime, endTime);
        }
        return wrapper;
    }
}
