<?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="org.linlinjava.jz.db.dao.HmButlerTaskParentMappers">
  <resultMap id="BaseResultMap" type="org.linlinjava.jz.db.domain.HmButlerTaskParent">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="task_type" jdbcType="INTEGER" property="taskType" />
    <result column="task_type_name" jdbcType="VARCHAR" property="taskTypeName" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
    <result column="employ_relation_id" jdbcType="BIGINT" property="employRelationId" />
    <result column="expiration_time" jdbcType="TIMESTAMP" property="expirationTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
  </resultMap>
  
  <select id="expireMonthTask" resultMap="BaseResultMap">
	select tp.* From (
		select hp.employ_relation_id,hp.order_no,max(hp.expiration_time) as expiration_time
		From hm_butler_task_parent hp  
		group by hp.employ_relation_id,hp.order_no
	) tp
		left join contract_sub cs on tp.order_no=cs.sub_order_no and cs.contract_state=0
		where
		<![CDATA[
		 tp.expiration_time<#{expirationTime,jdbcType=TIMESTAMP} 
		 and cs.contract_end_date>#{contractEndDate,jdbcType=TIMESTAMP}
		 ]]>
  </select>
  
  
</mapper>