JOIN (select unit_code,max(accept_date) from tz_jyjc_opening_application
where 1=1
<iftest=" tzBaseEnterpriseInfoDto.jyjcStatus!=null and tzBaseEnterpriseInfoDto.jyjcStatus!='' ">
and status = #{tzBaseEnterpriseInfoDto.jyjcStatus}
</if>
<iftest=" tzBaseEnterpriseInfoDto.jyjcType!=null and tzBaseEnterpriseInfoDto.jyjcType!='' ">
and open_biz_type = #{tzBaseEnterpriseInfoDto.jyjcType}
</if>
group by unit_code,open_biz_type) t1
ON t1.unit_code = use_code
</if>
<where>
<!-- <if-->
<!-- test="tzBaseEnterpriseInfoDto.unitType!=null and tzBaseEnterpriseInfoDto.unitType!='' and tzBaseEnterpriseInfoDto.unitType!='使用单位' ">-->
<!-- -->
<!-- AND unit_type LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.unitType},'%')-->
<!-- </if>-->
<iftest="tzBaseEnterpriseInfoDto.unitType.indexOf('检验检测机构') !=-1 and tzBaseEnterpriseInfoDto.jyjcStatus!=null and tzBaseEnterpriseInfoDto.jyjcStatus!=''">
use_unit_code in
(select distinct unit_code from tz_jyjc_opening_application
where
status = #{tzBaseEnterpriseInfoDto.jyjcStatus}
<iftest=" tzBaseEnterpriseInfoDto.jyjcType!=null and tzBaseEnterpriseInfoDto.jyjcType!='' ">
and open_biz_type = #{tzBaseEnterpriseInfoDto.jyjcType}
</if>
)
</if>
<iftest="unitTypeList != null and !unitTypeList.isEmpty()">
AND (
<foreachcollection="unitTypeList"item="item"separator=" OR ">