(tzjia.plan_inspection_date is not null and tzjia.status = '6616')
</when>
<otherwise>
1=1
</otherwise>
</choose>
)
</if>
<iftest="jyjcInspectionApplicationModel.bizType != null and jyjcInspectionApplicationModel.bizType != ''">
and tzjia.biz_type = #{jyjcInspectionApplicationModel.bizType}
</if>
<iftest="jyjcInspectionApplicationModel.inspectionUnitName != null and jyjcInspectionApplicationModel.inspectionUnitName != ''">
and tzjia.inspection_unit_name like concat('%',#{jyjcInspectionApplicationModel.inspectionUnitName},'%')
</if>
<iftest="jyjcInspectionApplicationModel.applicationUnitName != null and jyjcInspectionApplicationModel.applicationUnitName != ''">
and tzjia.application_unit_name like concat('%',#{jyjcInspectionApplicationModel.applicationUnitName},'%')
</if>
<choose>
<whentest="client == 'company'">
<choose>
<whentest="companyCode == '126100004352004822'">
and (tzjia.inspection_unit_code = #{companyCode} or tzjia.inspection_unit_code = '12100000400001774F')
</when>
<otherwise>
<choose>
<whentest="agencyClassify == 'JYJGFL_SBGY'">
and (
tzjia.inspection_unit_code = #{companyCode}
or EXISTS (select 1 from tz_base_enterprise_info e where e.regulatory_labels like '%一级管控(承压)%' and e.use_unit_code = tzjia.inspection_unit_code and tzjia.equip_classify in ('1000','2000','8000'))
or EXISTS (select 1 from tz_base_enterprise_info e where e.regulatory_labels like '%一级管控(承压)%' and e.use_unit_code = tzjia.use_unit_credit_code and tzjia.equip_classify in ('1000','2000','8000'))
)
</when>
<otherwise>
and (tzjia.inspection_unit_code = #{companyCode})
</otherwise>
</choose>
</otherwise>
</choose>
</when>
<otherwise>
AND tzjia.instance_id <![CDATA[<>]]> ''
AND EXISTS (
SELECT 1
FROM unnest(string_to_array(ed.orgBranchCodes, ',')) AS elem