package com.sunda.spmsoversea.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sunda.spmsoversea.dto.WhsDumpConfigQueryDTO;
import com.sunda.spmsoversea.entity.WhsDumpConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * IPO工厂转储配置表 Mapper 接口
 * </p>
 *
 * @author Hzc
 * @since 2023-02-22
 */
@Mapper
public interface WhsDumpConfigMapper extends BaseMapper<WhsDumpConfig> {


    @Select("<script>" +
            "SELECT OW.UUID AS \"uuid\",\n" +
            "       OW.OUT_WERKS AS \"outWerks\",\n" +
            "       OW.IN_WERKS AS \"inWerks\",\n" +
            "       OW.RECEIVE_WERKS AS \"receiveWerks\",\n" +
            "       OW.CREATE_DATE AS \"createDate\",\n" +
            "       OW.WORK_CODE AS \"workCode\",\n" +
            "       OW.SPMS_STATUS AS \"spmsStatus\",\n" +
            "       OW.UPDATE_DATE AS \"updateDate\"\n" +
            "FROM WHS_DUMP_CONFIG  OW " +
            "WHERE OW.SPMS_STATUS != '0' " +
            " <when test='dto.outWerks!=null and dto.outWerks != \"\"'> AND OW.OUT_WERKS = #{dto.outWerks}</when>" +
            " <when test='dto.inWerks!=null and dto.inWerks != \"\"'> AND OW.IN_WERKS = #{dto.inWerks}</when>" +
            " <when test='dto.receiveWerks!=null and dto.receiveWerks != \"\"'> AND OW.RECEIVE_WERKS = #{dto.receiveWerks}</when>" +
            " ORDER BY OW.CREATE_DATE DESC " +
            "</script>")
    List<Map<String, Object>> getWhsDumpConfigPage(IPage page, @Param("dto") WhsDumpConfigQueryDTO dto);
}
