<?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,pass_user_name 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  ,  null as goods_type , null as feed_img_url, null as 'carryImgUrl' 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  ,  null as goods_type , null as feed_img_url, pic_url as 'carryImgUrl' FROM  `bill_pcr`

   UNION
   SELECT NULL AS qualified_date,pass_user_name 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  ,  null as goods_type , null as feed_img_url, null as 'carryImgUrl' 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 ,  null as goods_type , null as feed_img_url, null as 'carryImgUrl'

    FROM  `bill_isolate`

      UNION
   SELECT NULL AS qualified_date, 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 ,
    5  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 ,  null as goods_type , null as feed_img_url,pic_url  as 'carryImgUrl' FROM  `bill_sampling`

       UNION
   SELECT   NULL AS qualified_date,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 ,6 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 , null as goods_type , null as feed_img_url, null as 'carryImgUrl' FROM `bill_clean_before`



      UNION
   SELECT   NULL AS qualified_date, pass_user_name,NULL AS pcr_type,process_id ,id,farm_id ,admission_user_id ,   test_location, null as  check_date,   test_location_id
      ,bill_status  ,NULL AS isolate_end_date ,7 AS `type`   , NULL AS isolate_day_num   ,NULL AS isolate_real_day_num, NULL AS isolate_real_end_date ,img_url,null as  img_status,NULL AS clean_time ,NULL AS dry_time,NULL AS dry_tem , goods_type ,feed_img_url, null as 'carryImgUrl'
     FROM `bill_goods_inventory`

    ) a  WHERE  a.process_id  = #{processId} and test_location_id  = #{locationId} AND bill_status &gt; 0 order by a.check_date desc


    </select>

    <select id="listAll" resultType="com.huimv.receive.entity.vo.ProcessVo">
        SELECT a.*,b.vistit_type vistitType,b.vistit_date vistitDate,b.id admissionId,b.car_num carNum from base_process a INNER JOIN bill_personnel_admission b
on a.id=b.process_id
  ${ew.customSqlSegment}
    </select>
</mapper>
