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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.runeconomy.model.auto.TurbineInfoDay;
import com.gyee.runeconomy.mapper.auto.TurbineInfoDayMapper;
import com.gyee.runeconomy.service.auto.ITurbineInfoDayService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-11-18
 */
@Service
public class TurbineInfoDayServiceImpl extends ServiceImpl<TurbineInfoDayMapper, TurbineInfoDay> implements ITurbineInfoDayService {
    @Override
    public List<TurbineInfoDay> getTurbineInfoDayList(String wpid, String kssj) throws ParseException {
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        Date kssjDate = new SimpleDateFormat("yyyy-MM-dd").parse(kssj);
        qw.lambda().eq(TurbineInfoDay::getTurbineId,wpid);
        qw.lambda().eq(TurbineInfoDay::getRecordDate,kssjDate);
        List<TurbineInfoDay> list = baseMapper.selectList(qw);
        return list;
    }

    @Override
    public List<TurbineInfoDay> getTurbineList(String wtid, String kssj, String jssj) throws ParseException {
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        Date kssjDate = new SimpleDateFormat("yyyy-MM-dd").parse(kssj);
        Date jssjDate = new SimpleDateFormat("yyyy-MM-dd").parse(jssj);
        qw.lambda().eq(TurbineInfoDay::getTurbineId,wtid);
        qw.lambda().between(TurbineInfoDay::getRecordDate,kssjDate,jssjDate);
        List<TurbineInfoDay> list = baseMapper.selectList(qw);
        return list;
    }
}
