package com.huimv.acquisition.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huimv.acquisition.entity.SowRankTableEntity;
import com.huimv.acquisition.mapper.SowRankTableDao;
import com.huimv.acquisition.service.SowRankTableService;
import com.huimv.acquisition.utils.PageUtils;
import com.huimv.acquisition.utils.Query;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 
 *
 * @author yinhao
 * @version ${version}
 * @date 2021-08-04 17:47:18
 */
@Service("sowRankTableService")
public class SowRankTableServiceImpl extends ServiceImpl<SowRankTableDao, SowRankTableEntity> implements SowRankTableService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SowRankTableEntity> page = this.page(
                new Query<SowRankTableEntity>().getPage(params),
                new QueryWrapper<SowRankTableEntity>()
        );

      /*  String max_sow_count = String.valueOf(params.get("max_sow_count"));//母猪存栏最高
        String min_sow_count = String.valueOf( params.get("min_sow_count"));//母猪存栏最低
        String max_sow_inc = String.valueOf( params.get("max_sow_inc"));//母猪新增最高
        String min_sow_inc = String.valueOf( params.get("min_sow_inc"));//母猪新增最低

        if(StringUtilsWork.isNotBlank(max_sow_count)||StringUtilsWork.isNotBlank(min_sow_count)||StringUtilsWork.isNotBlank(max_sow_count)||StringUtilsWork.isNotBlank(min_sow_count))
        {
            LambdaQueryWrapper<SowRankTableEntity> wrapper = Wrappers.lambdaQuery();
            if (StringUtilsWork.isNotBlank(max_sow_count) & StringUtilsWork.isNotBlank(min_sow_count)) {
                wrapper.between(SowRankTableEntity::getSowLivestock, max_sow_count, min_sow_count);
            }
            if (StringUtilsWork.isNotBlank(max_sow_count) & StringUtilsWork.isNotBlank(min_sow_count)) {
                wrapper.between(SowRankTableEntity::getSowLivestockInc, max_sow_inc, min_sow_inc);
            }
            wrapper.orderByDesc(SowRankTableEntity::getRank);
            IPage<SowRankTableEntity> page1 = this.page((new Query<SowRankTableEntity>().getPage(params)), wrapper);
            return new PageUtils(page1);
        }*/

        return   new PageUtils(page)   ;


    }

}