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.runeconomy.mapper.auto.ProEconWtCurveFittingMapper;
import com.gyee.runeconomy.model.auto.ProEconWtCurveFitting;
import com.gyee.runeconomy.service.auto.IProEconWtCurveFittingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 风电机拟合曲线 服务实现类
 * </p>
 *
 * @author shilin
 * @since 2022-10-21
 */
@Service
public class ProEconWtCurveFittingServiceImpl extends ServiceImpl<ProEconWtCurveFittingMapper, ProEconWtCurveFitting> implements IProEconWtCurveFittingService {


    @Resource
    private ProEconWtCurveFittingMapper proEconWtCurveFittingMapper;

    @Override
    public int deleteProEconWtCurveFittingByDay(Date recodedate) {
        return proEconWtCurveFittingMapper.deleteProEconWtCurveFittingByDay(recodedate);
    }

    @Override
    public List<ProEconWtCurveFitting> getProEconWtCurveFittingList(String windturbineId, Date recordDate) {
        QueryWrapper<ProEconWtCurveFitting> qw = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(windturbineId)) {
            qw.lambda().eq(ProEconWtCurveFitting::getWindturbineId, windturbineId);
        }

        if (null != recordDate) {
            qw.lambda().eq(ProEconWtCurveFitting::getRecordDate, recordDate);
        }

        qw.lambda().orderByAsc(ProEconWtCurveFitting::getSpeed);
        List<ProEconWtCurveFitting> list = baseMapper.selectList(qw);

        return list;
    }
}
