<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
	namespace="com.xisc.pm.infra.mapper.PmAutoPdPositionMapper">
	<!-- 可根据自己的需求，是否要使用 -->
	<resultMap id="BaseResultMap"
		type="com.xisc.pm.domain.entity.PmAutoPdPosition">
		<result column="POSITION_ID" property="positionId"
			jdbcType="DECIMAL" />
		<result column="ORDER_NO" property="orderNo" jdbcType="VARCHAR" />
		<result column="ORDER_SEQ_NO" property="orderSeqNo"
			jdbcType="DECIMAL" />
		<result column="VIRTUAL_SLAB_NO" property="virtualSlabNo"
			jdbcType="VARCHAR" />
		<result column="PICK_MODE_WID_DIR" property="pickModeWidDir"
			jdbcType="DECIMAL" />
		<result column="PICK_MODE_LEN_DIR" property="pickModeLenDir"
			jdbcType="DECIMAL" />
		<result column="TENANT_ID" property="tenantId"
			jdbcType="DECIMAL" />
		<result column="OBJECT_VERSION_NUMBER"
			property="objectVersionNumber" jdbcType="DECIMAL" />
		<result column="CREATION_DATE" property="creationDate"
			jdbcType="VARCHAR" />
		<result column="CREATED_BY" property="createdBy"
			jdbcType="DECIMAL" />
		<result column="LAST_UPDATED_BY" property="lastUpdatedBy"
			jdbcType="DECIMAL" />
		<result column="LAST_UPDATE_DATE" property="lastUpdateDate"
			jdbcType="VARCHAR" />
		<result column="ATTRIBUTE1" property="attribute1"
			jdbcType="VARCHAR" />
		<result column="ATTRIBUTE2" property="attribute2"
			jdbcType="VARCHAR" />
		<result column="ATTRIBUTE3" property="attribute3"
			jdbcType="VARCHAR" />
		<result column="ATTRIBUTE4" property="attribute4"
			jdbcType="VARCHAR" />
		<result column="ATTRIBUTE5" property="attribute5"
			jdbcType="VARCHAR" />
	</resultMap>


	<select id="selectList"
		resultType="com.xisc.pm.domain.entity.PmAutoPdPosition">
		select
		papp.*,
		ppcpa.ORDER_LEN ,
		ppcpa.ORDER_WIDTH
		from
		PM_AUTO_PD_POSITION papp
		LEFT JOIN PM_PRO_CONT_PROD_ATTR ppcpa on ppcpa.ORDER_NO = papp.ORDER_NO
		WHERE papp.VIRTUAL_SLAB_NO = #{virtualSlabNo}
		and papp.TENANT_ID = #{tenantId}
		order by papp.PICK_MODE_LEN_DIR ASC

	</select>

	<delete id="deleteByRequestId">
		delete from PM_AUTO_PD_POSITION papp where EXISTS 
		(select 1 from PM_AUTO_PD_RESULT papr where 
		papr.REQUEST_ID in 
		<foreach collection="requestIds" item="requestId" close=")"
			open="(" separator=",">
			#{requestId}
		</foreach> 
		and papp.VIRTUAL_SLAB_NO = papr.VIRTUAL_SLAB_NO)
	</delete>
</mapper>