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.ProEconWtCurveFittingYearMapper;
import com.gyee.runeconomy.model.auto.ProEconWtCurveFittingYear;
import com.gyee.runeconomy.service.auto.IProEconWtCurveFittingYearService;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 风电机年拟合曲线 服务实现类
 * </p>
 *
 * @author shilin
 * @since 2022-11-07
 */
@Service
public class ProEconWtCurveFittingYearServiceImpl extends ServiceImpl<ProEconWtCurveFittingYearMapper, ProEconWtCurveFittingYear> implements IProEconWtCurveFittingYearService {
    @Resource
    private ProEconWtCurveFittingYearMapper proEconWtCurveFittingYearMapper;

    @Override
    public int deleteProEconWtCurveFittingByYear(String year) {
        return proEconWtCurveFittingYearMapper.deleteProEconWtCurveFittingByYear(year);
    }

    @Override
    public List<ProEconWtCurveFittingYear> getProEconWtCurveFittingYearList(String windturbineId, String year) {
        QueryWrapper<ProEconWtCurveFittingYear> qw = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(windturbineId)) {
            qw.lambda().eq(ProEconWtCurveFittingYear::getWindturbineId, windturbineId);
        }

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

        return list;
    }
}
