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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.generation.model.auto.TurbineInfoMin;
import com.gyee.generation.mapper.auto.TurbineInfoMinMapper;
import com.gyee.generation.service.auto.ITurbineInfoMinService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author shilin
 * @since 2024-12-16
 */
@Service
public class TurbineInfoMinServiceImpl extends ServiceImpl<TurbineInfoMinMapper, TurbineInfoMin> implements ITurbineInfoMinService {

    @Override
    public List<TurbineInfoMin> selectByTurbineId(String turbineId, String kssj, String jssj) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime startDate = LocalDateTime.parse(kssj, formatter);
        LocalDateTime endDate = LocalDateTime.parse(jssj, formatter);

        QueryWrapper<TurbineInfoMin> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().ge(TurbineInfoMin::getRecordDate, startDate)
                .le(TurbineInfoMin::getRecordDate, endDate);
        queryWrapper.lambda().eq(TurbineInfoMin::getTurbineId, turbineId);

        // 获取数据
        List<TurbineInfoMin> infoMins = baseMapper.selectList(queryWrapper);
        return infoMins;
    }

}
