package com.zt.plat.module.contractorder.dal.mysql.contract;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.contractorder.api.vo.contract.NotRespVO;
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractNotDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 品位不计价配置 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface ContractNotMapper extends BaseMapperX<ContractNotDO> {

    @Select({
            "<script>",
            "select ID id",
            ", CTRT_ID contractId",
            ", ELEM_NUM elementNumber",
            ", ELEM_ABBR elementAbbreviation",
            ", ELEM_NAME elementName",
            ", GRD_UP gradeUp",
            ", GRD_DOWN gradeDown",
            ", RNG_WY rangeWay",
            ", MTRL_NAME materialName",
            ", MTRL_NUM materialNumber",
            ", CREATE_TIME createTime",
            ", (select ctrt_name from BSE_CTRT_MAIN where id = ctrt_id) contractName",
            ", (select ctrt_ppr_num from BSE_CTRT_MAIN where id = ctrt_id) contractPaperNumber",
            "from bse_ctrt_nt",
            "where DELETED = 0",
            "<if test= \"contractIds != null and contractIds.size() > 0\">",
            "and ctrt_id in",
            "<foreach collection = 'contractIds' item = 'contractId' open='(' separator = ',' close = ')'>",
            "#{contractId}",
            "</foreach>",
            "</if>",
            "<if test= \"materialName != null and materialName != ''\">",
            "and mtrl_name like concat('%',#{materialName},'%')",
            "</if>",
            "<if test= \"elementName != null and elementName != ''\">",
            "and elem_name like concat('%',#{elementName},'%')",
            "</if>",
            "</script>"
    })
    IPage<NotRespVO> selectNots(IPage<NotRespVO> page, List<Long> contractIds, String materialName, String elementName);
}