<?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.prolog.cs.base.gsp.dao.GspUpkeepCheckMapper">

	<sql id="Base_Column_List">
		ID, CODE, ENTERPRISE_ID, DC_ID, WAREHOUSE_ID, CARGO_OWNER_ID, BATCH_ID, PLAN_ID, PLAN_CODE, ITEM_ID, ITEM_CODE, LOT_NUM, LOCATOR_ID, LOCATOR_CODE, STOCK_QTY, UPKEEP_QTY, PENDING_QTY, UPKEEP_TYPE, UPKEEP_OPERATOR, STATUS, SOURCE_TYPE, UPKEEP_CONCLUSION, CHECK_CONCLUSION, RECHECK_CONCLUSION, CONCLUSION, PROCESS_OPINION, CHECK_OPERATOR, CHECK_OPINION, RECHECK_OPERATOR, RECHECK_OPINION, CHECK_WAI_GUAN, CHECK_BAO_ZHUANG, CHECK_CHEN_CHU_TIAO_JIAN, CHECK_FAN_DUO, CHECK_CHU_SHI, CHECK_JIA_SHI, CHECK_SHEN_WEN, CHECK_JIANG_WEN, CHECK_TONG_FENG, CHECK_CHU_CHEN, QUALITY_STATUS, THS_TATUS, PENDING_REASON, PLAN_UPKEEP_DATE, UPKEEP_DATE, CHECK_DATE, RECHECK_DATE, GMT_CREATE, CREATOR, CREATOR_NAME, GMT_MODIFIED, MODIFIER, MODIFIER_NAME, REMARK, PDATE_FROM, VALID_UNTIL, BLDG_ID, IS_PROTECTED, SHOW_PRODUCTION_DATE, SHOW_EXPIRED_DATE, PRODUCTION_DATE, EXPIRED_DATE, IS_NEAR_DATE, ITEM_HEALTH_CATEGORY, PLAN_STOCK_QTY, outbound_instruct, container_code, CHECK_CHONG_ZHU, CHECK_FA_MEI, CHECK_FAN_YOU, CHECK_CHAO_JIE, CHECK_BIAN_SE, CHECK_SHANG_DOU, CHECK_PO_SUN
	</sql>

	<select id="findList" resultMap="map">
		SELECT
		<include refid="Base_Column_List" />
		FROM
		GSP_UPKEEP_CHECK c
		WHERE 1=1
		<if test='type != null and type =="1"'>
			and c.STATUS = 0
		</if>
		<if test='type != null and type =="2"'>
			and c.conclusion = 2 and status &lt;&gt; 6
		</if>
		<if test="upkeepType != null  and upkeepType !=''">
			and c.UPKEEP_TYPE = #{upkeepType}
		</if>
		<if test="enterpriseId != null  and enterpriseId !=''">
			and c.enterprise_id = #{enterpriseId}
		</if>
		<if test="warehouseId != null  and warehouseId !=''">
			and c.warehouse_id = #{warehouseId}
		</if>
		<if test="cargoOwnerId != null  and cargoOwnerId !=''">
			and c.CARGO_OWNER_ID = #{cargoOwnerId}
		</if>
		<if test="itemHealthCategory != null  and itemHealthCategory !=''">
			and c.ITEM_HEALTH_CATEGORY = #{itemHealthCategory}
		</if>
		<if test="itemId != null  and itemId !=''">
			and c.ITEM_ID = #{itemId}
		</if>
		<!-- 根据执行时间来做 -->
		<if test="startTime != null ">
			and c.PLAN_UPKEEP_DATE  &gt;= #{startTime}
		</if>
		<if test="endTime != null ">
			and c.PLAN_UPKEEP_DATE &lt; #{endTime}
		</if>
		<if test="isProtected != null ">
			and c.IS_PROTECTED = #{isProtected}
		</if>
		<if test="planId != null and planId !=''">
			and c.plan_id = #{planId}
		</if>
		order by LOCATOR_CODE,ITEM_CODE,LOT_NUM asc
	</select>
</mapper>
