package com.css.txw.gxzx.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.css.ggzc.framework.common.util.gy.GyUtils;
import com.css.ggzc.framework.mybatis.core.query.QueryWrapperX;
import com.css.txw.gxzx.pojo.domain.TxwGxzxGxxxbDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.css.txw.gxzx.pojo.vo.GetGxSqListReqVO;
import com.css.txw.gxzx.pojo.vo.GxxxReqVO;

import java.util.List;
import java.util.Set;

/**
* @author AirlH
* @description 针对表【txw_gxzx_gxxxb(供需信息表)】的数据库操作Mapper
* @createDate 2025-09-13 11:26:24
* @Entity com.css.txw.gxzx.pojo.domain.TxwGxzxGxxxb
*/
public interface TxwGxzxGxxxbMapper extends BaseMapper<TxwGxzxGxxxbDO> {

    default Page<TxwGxzxGxxxbDO> gxxxList(GxxxReqVO reqVO, Set<String> gxuuids){
        Page<TxwGxzxGxxxbDO> page = new Page<>(reqVO.getPageNo(),reqVO.getPageSize());
        QueryWrapperX<TxwGxzxGxxxbDO> wrapper = new QueryWrapperX<>();
        wrapper.lambda()
                .eq(TxwGxzxGxxxbDO::getYwlxDm,reqVO.getYwlxDm())
                .and(!GyUtils.isNull(reqVO.getNr()),w->w.like(TxwGxzxGxxxbDO::getBt1,reqVO.getNr()).or().like(TxwGxzxGxxxbDO::getFwnr,reqVO.getNr()).or().like(TxwGxzxGxxxbDO::getQymc,reqVO.getNr()))
                .eq(TxwGxzxGxxxbDO::getSjzt,"Y")
                .eq(TxwGxzxGxxxbDO::getZt,"3")
                .in(!GyUtils.isNull(reqVO.getSshy()),TxwGxzxGxxxbDO::getSshy,reqVO.getSshy())
                .like(!GyUtils.isNull(reqVO.getDq()),TxwGxzxGxxxbDO::getFwfw,reqVO.getDq())
                .lt(!GyUtils.isNull(reqVO.getFbsjz()),TxwGxzxGxxxbDO::getLrrq,reqVO.getFbsjz())
                .gt(!GyUtils.isNull(reqVO.getFbsjq()),TxwGxzxGxxxbDO::getLrrq,reqVO.getFbsjq())
                .in(!GyUtils.isNull(gxuuids),TxwGxzxGxxxbDO::getGxUuid,gxuuids)
                .in(!GyUtils.isNull(reqVO.getQyuuids()),TxwGxzxGxxxbDO::getQyuuid,reqVO.getQyuuids())
                .orderByDesc(TxwGxzxGxxxbDO::getLrrq);
        return selectPage(page,wrapper);

    }

    default Page<TxwGxzxGxxxbDO> gxxxListByYh(GxxxReqVO reqVO,String yhuuid){
        Page<TxwGxzxGxxxbDO> page = new Page<>(reqVO.getPageNo(),reqVO.getPageSize());
        QueryWrapper<TxwGxzxGxxxbDO> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(TxwGxzxGxxxbDO::getLrruuid,yhuuid)
                .eq(TxwGxzxGxxxbDO::getYwlxDm,reqVO.getYwlxDm())
                .and(!GyUtils.isNull(reqVO.getNr()),w->w.like(TxwGxzxGxxxbDO::getBt1,reqVO.getNr()).or().like(TxwGxzxGxxxbDO::getFwnr,reqVO.getNr()).or().like(TxwGxzxGxxxbDO::getQymc,reqVO.getNr()))
                .lt(!GyUtils.isNull(reqVO.getFbsjz()),TxwGxzxGxxxbDO::getLrrq,reqVO.getFbsjz())
                .gt(!GyUtils.isNull(reqVO.getFbsjq()),TxwGxzxGxxxbDO::getLrrq,reqVO.getFbsjq())
                .orderByDesc(TxwGxzxGxxxbDO::getLrrq);
        return selectPage(page,wrapper);
    }

    default Page<TxwGxzxGxxxbDO> getGxSqList(GetGxSqListReqVO reqVO){
        Page<TxwGxzxGxxxbDO> page = new Page<>(reqVO.getPageNo(),reqVO.getPageSize());
        QueryWrapper<TxwGxzxGxxxbDO> wrapper = new QueryWrapper<>();
        wrapper.lambda()
//                .eq(TxwGxzxGxxxbDO::getZt,"2")
        .eq(TxwGxzxGxxxbDO::getYwlxDm,reqVO.getYwlxDm())
        .like(!GyUtils.isNull(reqVO.getQymc()),TxwGxzxGxxxbDO::getQymc,reqVO.getQymc())
        .like(!GyUtils.isNull(reqVO.getNsrsbh()),TxwGxzxGxxxbDO::getNsrsbh,reqVO.getNsrsbh())
        .like(!GyUtils.isNull(reqVO.getBt1()),TxwGxzxGxxxbDO::getBt1,reqVO.getBt1())
        .eq(!GyUtils.isNull(reqVO.getSjzt()),TxwGxzxGxxxbDO::getSjzt,reqVO.getSjzt())
        .eq(!GyUtils.isNull(reqVO.getZt()),TxwGxzxGxxxbDO::getZt,reqVO.getZt())
        .like(!GyUtils.isNull(reqVO.getFwlxDm()),TxwGxzxGxxxbDO::getFwlxjh,reqVO.getFwlxDm())
        .orderByDesc(TxwGxzxGxxxbDO::getLrrq);
        return selectPage(page,wrapper);
    }
}




