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.InverterStatusData;
import com.jiayue.ipp.idp.mapper.InverterStatusDataMapper;
import com.jiayue.ipp.idp.service.InverterStatusDataService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * idp_inverter_status_data
 *
 * @author whc
 * @date 2022-03-18 15:49:14
 */
@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;
    }
}
