(select count(distinct ibjui.record) from idx_biz_jg_use_info ibjui, idx_biz_jg_inspection_detection_info di where ibjui."RECORD" = di."RECORD" and ibjui.project_contraption_id=pc.sequence_nbr and di."INSPECT_TYPE" <![CDATA[<>]]> '') as inspectNum,
<whentest="inspectionType == 'AZJDJY'">
(select count(1) from idx_biz_jg_use_info ibjui where ibjui.project_contraption_id= pc.sequence_nbr) as totalNum
and pc.usc_unit_credit_code=#{companyCode}
from
and pc.is_into_management = true
idx_biz_jg_project_contraption pc
and (pc.use_registration_code is null or pc.use_registration_code = '' )
where
</when>
1=1
<otherwise>
<choose>
<choose>
<whentest="inspectionType == 'AZJDJY'">
<whentest="equCategory == '8300'">
and pc.usc_unit_credit_code=#{companyCode}
and pc.use_unit_credit_code=#{companyCode}
and pc.is_into_management = true
and pc.is_into_management = true
and (pc.use_registration_code is null or pc.use_registration_code = '' )
and pc.use_registration_code <![CDATA[<>]]> ''
</when>
</when>
<otherwise>
<otherwise>
<choose>
and pc.use_unit_credit_code=#{companyCode}
<whentest="equCategory == '8300'">
and pc.is_into_management = true
and pc.use_unit_credit_code=#{companyCode}
and exists (select 1 from idx_biz_jg_use_info ibjui, idx_biz_jg_inspection_detection_info di where ibjui."RECORD" = di."RECORD" and ibjui.project_contraption_id=pc.sequence_nbr and di."INSPECT_TYPE" <![CDATA[<>]]> '' )
and pc.is_into_management = true
</otherwise>
and pc.use_registration_code <![CDATA[<>]]> ''
</choose>
</when>
</otherwise>
<otherwise>
</choose>
and pc.use_unit_credit_code=#{companyCode}
and not EXISTS (SELECt 1 FROM tz_jyjc_inspection_application a where a.status='6611' and a.application_unit_code=#{companyCode} and a.project_contraption_id = pc.sequence_nbr)
and pc.is_into_management = true
and (pc.project_contraption_parent_id is null or pc.project_contraption_parent_id = '')
</otherwise>
and pc.equ_category = #{equCategory}
</choose>
</otherwise>
</choose>
and not EXISTS (SELECt 1 FROM tz_jyjc_inspection_application a where a.status='6611' and a.application_unit_code=#{companyCode} and a.project_contraption_id = pc.sequence_nbr)
and (pc.project_contraption_parent_id is null or pc.project_contraption_parent_id = '')
and pc.equ_category = #{equCategory}
) s
<where>
<iftest="inspectionType == 'DQJY' and equCategory != '8300'">