<?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.huimv.receive.mapper.BaseProcessMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.huimv.receive.entity.BaseProcess">
        <id column="id" property="id" />
        <result column="dest_name" property="destName" />
        <result column="dest_id" property="destId" />
        <result column="admission_user_name" property="admissionUserName" />
        <result column="admission_user_id" property="admissionUserId" />
        <result column="sub_date" property="subDate" />
        <result column="update_date" property="updateDate" />
        <result column="current_location" property="currentLocation" />
        <result column="current_location_id" property="currentLocationId" />
        <result column="farm_id" property="farmId" />
        <result column="process_type" property="processType" />
    </resultMap>
    <select id="pageByLocationId" resultType="com.huimv.receive.entity.vo.BaseProcessByLocationVo">

   select *from (
     SELECT   NULL AS qualified_date,NULL AS pass_user_name,NULL AS pcr_type,process_id ,id,farm_id ,admission_user_id ,test_location,check_date,test_location_id
      ,bill_status  ,NULL AS isolate_end_date ,1 AS `type`   , NULL AS isolate_day_num   ,NULL AS isolate_real_day_num, NULL AS isolate_real_end_date ,img_url,img_status,clean_time ,NULL AS dry_time,NULL AS dry_tem  FROM `bill_clean`

   UNION
   SELECT qualified_date,pass_user_name,pcr_type, process_id ,id,farm_id,admission_user_id ,test_location,check_date,test_location_id   ,bill_status
   ,NULL AS isolate_end_date ,2 AS `type` ,NULL AS isolate_day_num ,NULL AS isolate_real_day_num, NULL AS isolate_real_end_date , img_url,   img_status ,NULL AS clean_time ,NULL AS dry_time,NULL AS dry_tem  FROM  `bill_pcr`

   UNION
   SELECT NULL AS qualified_date,NULL AS pass_user_name, NULL AS pcr_type, process_id ,id,farm_id,admission_user_id ,test_location,check_date,test_location_id
    ,bill_status  ,NULL AS isolate_end_date ,3  AS `type` ,NULL AS isolate_day_num ,NULL AS isolate_real_day_num,  NULL AS  isolate_real_end_date, img_url, img_status ,NULL AS clean_time  ,dry_time,dry_tem FROM  `bill_dry`
    UNION

   SELECT  NULL AS qualified_date,pass_user_name,  NULL AS pcr_type, process_id ,id,farm_id,admission_user_id , isolate_location AS test_location,
   isolate_start_date AS check_date ,
   isolate_location_id AS test_location_id  ,
   bill_status,
      isolate_end_date ,   4 AS `type` ,isolate_day_num  ,isolate_real_day_num, isolate_real_end_date , NULL AS img_url, NULL AS  img_status ,NULL AS clean_time ,NULL AS dry_time,NULL AS dry_tem

    FROM  `bill_isolate`) a  where  a.process_id  = #{processId} and test_location_id  = #{locationId} order by a.check_date desc

    </select>

</mapper>
