package com.xisc.pm.infra.repository.impl;

import com.xisc.pm.domain.entity.PmSlabPoolIn;
import com.xisc.pm.domain.repository.PmSlabPoolInRepository;
import com.xisc.pm.domain.vo.CtMainVO;
import com.xisc.pm.infra.mapper.PmSlabPoolInMapper;
import org.apache.commons.collections.CollectionUtils;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.hzero.mybatis.domian.Condition;
import org.hzero.mybatis.util.Sqls;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 组炉收池表(PmSlabPoolIn)资源库
 *
 * @author 纪文桃 wentao.ji01@hand-china.com
 * @since 2024-08-07 17:11:27
 */
@Component
public class PmSlabPoolInRepositoryImpl extends BaseRepositoryImpl<PmSlabPoolIn> implements PmSlabPoolInRepository {
    @Resource
    private PmSlabPoolInMapper pmSlabPoolInMapper;

    @Override
    public List<PmSlabPoolIn> selectList(PmSlabPoolIn pmSlabPoolIn) {
        return pmSlabPoolInMapper.selectList(pmSlabPoolIn);
    }

    @Override
    public PmSlabPoolIn selectByPrimary(Long slabPoolInId) {
        PmSlabPoolIn pmSlabPoolIn = new PmSlabPoolIn();
        pmSlabPoolIn.setSlabPoolInId(slabPoolInId);
        List<PmSlabPoolIn> pmSlabPoolIns = pmSlabPoolInMapper.selectList(pmSlabPoolIn);
        if (CollectionUtils.isEmpty(pmSlabPoolIns)) {
            return null;
        }
        return pmSlabPoolIns.get(0);
    }

    @Override
    public List<PmSlabPoolIn> selectByVirtualSlabNoList(List<String> virtualNoList, Long tenantId) {
        return this.selectByCondition(Condition.builder(PmSlabPoolIn.class)
                .andWhere(Sqls.custom().andEqualTo(PmSlabPoolIn.FIELD_TENANT_ID, tenantId))
                .andWhere(Sqls.custom().andIn(PmSlabPoolIn.FIELD_VIRTUAL_SLAB_NO, virtualNoList))
                .build());
    }

    @Override
    public List<CtMainVO> selectCtMainByOrderNoList(List<String> orderNoList, Long tenantId) {
        return pmSlabPoolInMapper.selectCtMainByOrderNoList(orderNoList, tenantId);
    }
}
