package com.jiayue.ipp.idp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiayue.ipp.common.data.entity.WindTurbineStatusData;
import com.jiayue.ipp.idp.mapper.WindTurbineStatusDataMapper;
import com.jiayue.ipp.idp.service.WindTurbineStatusDataService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 风机数据业务层实现类
 *
 * @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);
        }
        String[] args = equipmentId.split(",");
        if (equipmentId != null && !equipmentId.equals("")) {
            wrapper.in("equipment_id", args);
        }
        if (startTime != null && !startTime.equals("") && endTime != null && !endTime.equals("")) {
            wrapper.between("time", startTime, endTime);
        }
        return wrapper;
    }
}
