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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cpp.web.domain.station.InverterStatusData;
import com.cpp.web.mapper.station.InverterStatusDataMapper;
import com.cpp.web.service.station.InverterStatusDataService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * cpp_inverter_status_data
 *
 * @author tl
 * @date 2024-09-23 15:28:33
 */
@Service
public class InverterStatusDataServiceImpl extends ServiceImpl<InverterStatusDataMapper, InverterStatusData> implements InverterStatusDataService {
    @Override
    public QueryWrapper<InverterStatusData> getByStationCodeAndEquipmentIdAndTimeBetween(String stationCode, String equipmentId, Date startTime, Date endTime) {
        QueryWrapper<InverterStatusData> 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;
    }
}
