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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gyee.common.model.StringUtils;
import com.gyee.runeconomy.mapper.auto.ProEconTargetdataCopyMapper;
import com.gyee.runeconomy.model.auto.ProEconTargetdataCopy;
import com.gyee.runeconomy.service.auto.IProEconTargetdataCopyService;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author wang
 * @since 2023-07-24
 */
@Service
public class ProEconTargetdataCopyServiceImpl extends ServiceImpl<ProEconTargetdataCopyMapper, ProEconTargetdataCopy> implements IProEconTargetdataCopyService {

    @Override
    public IPage<ProEconTargetdataCopy> getList(String windpowerstationid, String windpowerstationName, String recorddate, String pageNum, String pageSize) {
        QueryWrapper<ProEconTargetdataCopy> qw = new QueryWrapper<>();

        if (StringUtils.isNotEmpty(windpowerstationid)) {
            qw.eq("windpowerstation_id", windpowerstationid);
        }

        if (StringUtils.isNotEmpty(windpowerstationName) && windpowerstationName.equals("qb")) {

        } else if (StringUtils.isNotEmpty(windpowerstationName)) {
            qw.like("windpowerstation_name", windpowerstationName);
        }

        if (StringUtils.isNotEmpty(recorddate)) {
            try {
                Date beginDate = new SimpleDateFormat("yyyy-MM-dd").parse(recorddate);
                qw.ge("record_date", beginDate);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }


        Page<ProEconTargetdataCopy> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
        IPage<ProEconTargetdataCopy> InputPage = getBaseMapper().selectPage(page, qw);
        //        List<Windpowerstation> list = companysPage.getRecords();
        return InputPage;

    }
}
