package com.sunda.spmsoversea.mapper;

import com.sunda.spmsoversea.entity.OverseaWhsInventoryLoss;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * <p>
 * 海外仓-存货损益头表 Mapper 接口
 * </p>
 *
 * @author Hzc
 * @since 2024-05-07
 */
@Mapper
public interface OverseaWhsInventoryLossMapper extends BaseMapper<OverseaWhsInventoryLoss> {
	
	@Select("<script>" +
			"SELECT \n" +
			"	UUID AS \"uuid\",\n" +
			"	SPMS_ID AS \"spmsId\",\n" +
			"	SAP_PACKAGE_LIST AS \"sapPackageList\",\n" +
			"	SAP_DELIVERY_NOTE AS \"sapDeliveryNote\",\n" +
			"	WERKS AS \"werks\",\n" +
			"	WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
			"	SPMS_STATUS AS \"spmsStatus\",\n" +
			"	MOVEMENT_TYPE AS \"movementType\",\n" +
			"	ORDER_TYPE AS \"orderType\",\n" +
			"	OA_WORKFLOW AS \"oaWorkflow\",\n" +
			"	OA_BIANHAO AS \"oaBianhao\",\n" +
			"	COST_CENTER AS \"costCenter\",\n" +
			"	SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
			"	POSTING_DATE AS \"postingDate\",\n" +
			"	CREATE_TIME AS \"createTime\",\n" +
			"	CREATE_USERID AS \"createUserid\",\n" +
			"	CANCEL_REASON AS \"cancelReason\",\n" +
			"	DATA_VERSION AS \"dataVersion\" \n" +
			"FROM OVERSEA_WHS_INVENTORY_LOSS \n" +
			"WHERE 1=1 \n" +
			" 	<when test='werks != null and werks != \"\"'> AND WERKS = #{werks}</when>" +
            " 	<when test='whsLocationCode != null and whsLocationCode != \"\"'> AND WHS_LOCATION_CODE = #{whsLocationCode}</when>" +
            " 	<when test='spmsStatus != null and spmsStatus != \"\"'> AND SPMS_STATUS = #{spmsStatus}</when>" +
            " 	<when test='orderType != null and orderType != \"\"'> AND ORDER_TYPE = #{orderType}</when>" +
            " 	<when test='movementType != null and movementType != \"\"'> AND MOVEMENT_TYPE = #{movementType}</when>" +
            " 	<when test='spmsId != null and spmsId != \"\"'> AND SPMS_ID = #{spmsId}</when>" +
            " 	<when test='oaWorkflow != null and oaWorkflow != \"\"'> AND OA_WORKFLOW = #{oaWorkflow}</when>" +
            " 	<when test='sapDeliveryNote != null and sapDeliveryNote != \"\"'> AND SAP_DELIVERY_NOTE = #{sapDeliveryNote}</when>" +
            " 	<when test='beginDate!=null'><![CDATA[ AND CREATE_TIME >= TO_DATE(#{beginDate}, 'yyyy-MM-dd')]]></when>" +
            " 	<when test='endDate!=null'> <![CDATA[ AND CREATE_TIME <= TO_DATE(#{endDate}, 'yyyy-MM-dd') ]]></when>" +
			"</script>")
	List<Map<String, Object>> selectListByPage(Page<Map<String, Object>> pages, @Param("werks") String werks, 
											@Param("whsLocationCode") String whsLocationCode, 
											@Param("beginDate") String beginDate, 
											@Param("endDate") String endDate, 
											@Param("spmsStatus") String spmsStatus, 
											@Param("orderType") String orderType, 
											@Param("movementType") String movementType, 
											@Param("spmsId") String spmsId, 
											@Param("oaWorkflow") String oaWorkflow, 
											@Param("sapDeliveryNote") String sapDeliveryNote);

}
