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.ProEconWtCurveFittingMonthMapper;
import com.gyee.runeconomy.model.auto.ProEconWtCurveFittingMonth;
import com.gyee.runeconomy.service.auto.IProEconWtCurveFittingMonthService;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 风电机月拟合曲线 服务实现类
 * </p>
 *
 * @author shilin
 * @since 2022-10-21
 */
@Service
public class ProEconWtCurveFittingMonthServiceImpl extends ServiceImpl<ProEconWtCurveFittingMonthMapper, ProEconWtCurveFittingMonth> implements IProEconWtCurveFittingMonthService {
    @Resource
    private ProEconWtCurveFittingMonthMapper proEconWtCurveFittingMonthMapper;

    @Override
    public int deleteProEconWtCurveFittingByMonth(String year, String month) {

        return proEconWtCurveFittingMonthMapper.deleteProEconWtCurveFittingByMonth(year, month);
    }

    @Override
    public List<ProEconWtCurveFittingMonth> getProEconWtCurveFittingMonthList(String windturbineId, String month, String year) {

        QueryWrapper<ProEconWtCurveFittingMonth> qw = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(windturbineId)) {
            qw.lambda().eq(ProEconWtCurveFittingMonth::getWindturbineId, windturbineId);
        }

        if (StringUtils.isNotEmpty(month)) {
            qw.lambda().eq(ProEconWtCurveFittingMonth::getMonth, month);
        }

        if (StringUtils.isNotEmpty(year)) {
            qw.lambda().eq(ProEconWtCurveFittingMonth::getYear, year);
        }
        qw.lambda().orderByAsc(ProEconWtCurveFittingMonth::getSpeed);
        List<ProEconWtCurveFittingMonth> list = baseMapper.selectList(qw);

        return list;
    }
}
