package com.gyee.runeconomy.service.auto.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gyee.common.model.StringUtils;
import com.gyee.common.util.DateUtils;
import com.gyee.runeconomy.mapper.auto.ProEconWtAlysisDayMapper;
import com.gyee.runeconomy.model.auto.ProEconWtAlysisDay;
import com.gyee.runeconomy.service.auto.IProEconWtAlysisDayService;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 风机日性能分析表 服务实现类
 * </p>
 *
 * @author shilin
 * @since 2022-11-24
 */
@Service
public class ProEconWtAlysisDayServiceImpl extends ServiceImpl<ProEconWtAlysisDayMapper, ProEconWtAlysisDay> implements IProEconWtAlysisDayService {

    @Override
    public List<ProEconWtAlysisDay> getProEconWtAlysisDayList(String windturbineIds, String date) {

        QueryWrapper<ProEconWtAlysisDay> qw = new QueryWrapper<>();
        Date recorddate = DateUtils.parseDate(date);

        if (StringUtils.isNotEmpty(windturbineIds)) {
            String[] wtidArray = windturbineIds.split(",");
            List<String> wtidList = Arrays.asList(wtidArray);
            qw.lambda().in(ProEconWtAlysisDay::getWindturbineId, wtidList);
        } else {
            return null;
        }

        qw.lambda().eq(ProEconWtAlysisDay::getRecordDate, recorddate);
        List<ProEconWtAlysisDay> list = baseMapper.selectList(qw);
        return list;
    }
}
