and (ibjpc.project_contraption_parent_id is null or ibjpc.project_contraption_parent_id = '')
AND EXISTS (
SELECT 1
FROM idx_biz_jg_use_info ui
WHERE ui."PROJECT_CONTRAPTION_ID" = ibjpc.sequence_nbr
AND (ui."EQU_STATE" is null or ui."EQU_STATE" <![CDATA[<>]]> '3' )
and (ibjpc.EQU_STATE <![CDATA[<>]]> '3' or ibjpc."EQU_STATE" is null)
and not exists
(
select 1 from tzs_jg_change_registration_reform a where (a.audit_status
<![CDATA[ <> ]]>
'使用单位待提交' and a.audit_status
<![CDATA[ <> ]]>
'一级受理已驳回' and a.audit_status
<![CDATA[ <> ]]>
'使用单位已撤回' and a.audit_status
<![CDATA[ <> ]]>
'已作废')
and a.use_unit_credit_code = #{dto.originalUseUnitCreditCode}
and a.project_contraption_id = ibjpc.sequence_nbr
UNION
select b.project_contraption_id from tzs_jg_change_registration_unit a, tzs_jg_change_registration_unit_eq b where a.sequence_nbr = b.unit_change_registration_id and ((a.status
<![CDATA[ <> ]]>
'使用单位待提交' and a.status
<![CDATA[ <> ]]>
'一级受理已驳回' and a.status
<![CDATA[ <> ]]>
'使用单位已撤回' and a.status
<![CDATA[ <> ]]>
'已作废')
or a.status = '已完成')
and a.use_unit_credit_code =#{dto.originalUseUnitCreditCode}
and b.project_contraption_id = ibjpc.sequence_nbr
UNION select project_contraption_id from tzs_jg_enable_disable a where (a.audit_status
<![CDATA[ <> ]]>
'已驳回' and a.audit_status
<![CDATA[ <> ]]>
'已撤回' and a.audit_status
<![CDATA[ <> ]]>
'待提交' and a.audit_status
<![CDATA[ <> ]]>
'已作废')
and a.use_unit_credit_code = #{dto.originalUseUnitCreditCode}
and a.project_contraption_id = ibjpc.sequence_nbr
UNION select project_contraption_id from tzs_jg_maintain_notice a where (a.notice_status
<![CDATA[ <> ]]>
'6614' and a.notice_status
<![CDATA[ <> ]]>
'6615' and a.notice_status
<![CDATA[ <> ]]>
'6610' and a.notice_status
<![CDATA[ <> ]]>
'6617')
and a.use_unit_credit_code = #{dto.originalUseUnitCreditCode}
and a.project_contraption_id = ibjpc.sequence_nbr
UNION select project_contraption_id from tzs_jg_reform_notice a where (a.notice_status
<![CDATA[ <> ]]>
'6614' and a.notice_status
<![CDATA[ <> ]]>
'6615' and a.notice_status
<![CDATA[ <> ]]>
'6610' and a.notice_status
<![CDATA[ <> ]]>
'6617')
and a.use_unit_credit_code = #{dto.originalUseUnitCreditCode}
and a.project_contraption_id = ibjpc.sequence_nbr
UNION
select project_contraption_id from tzs_jg_scrap_cancel a where (a.audit_status
<![CDATA[ <> ]]>
'使用单位已撤回' and a.audit_status
<![CDATA[ <> ]]>
'一级受理已驳回' and a.audit_status
<![CDATA[ <> ]]>
'使用单位待提交' and a.audit_status
<![CDATA[ <> ]]>
'已作废')
and a.use_unit_code = #{dto.originalUseUnitCreditCode}
and a.project_contraption_id = ibjpc.sequence_nbr
)
<iftest="dto.equList != null and dto.equList != ''">
and tjurm.equ_list = #{dto.equList}
</if>
<iftest="dto.equListCode != null and dto.equListCode != ''">
and tjurm.equ_list_code = #{dto.equListCode}
</if>
<iftest="dto.equCategory != null and dto.equCategory != ''">
and tjurm.equ_category = #{dto.equCategory}
</if>
<iftest="dto.equCategoryCode != null and dto.equCategoryCode != ''">
and tjurm.equ_category_code = #{dto.equCategoryCode}
</if>
<iftest="dto.equDefineCode != null and dto.equDefineCode != ''">
and tjurm.equ_define = #{dto.equDefineCode}
</if>
<iftest="dto.equDefineCode != null and dto.equDefineCode != ''">
and tjurm.equ_define_code = #{dto.equDefineCode}
</if>
<iftest="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
and tjurm.use_registration_code like concat('%',#{dto.useRegistrationCode},'%')
</if>
<iftest="dto.certificateStatus != null and dto.certificateStatus != ''">
and tjurm.certificate_status = #{dto.certificateStatus}
</if>
<iftest="dto.projectContraption != null and dto.projectContraption != ''">
and ibjpc.project_contraption like concat('%',#{dto.projectContraption},'%')
</if>
<iftest="dto.projectContraptionNo != null and dto.projectContraptionNo != ''">
and ibjpc.project_contraption_no like concat('%', #{dto.projectContraptionNo},'%')
</if>
ORDER BY
<iftest="sort != null">
ibjpc.${sort.field} ${sort.sortType},
</if>
ibjpc.rec_date DESC
<iftest="dto.equList != null and dto.equList != ''">
and tjurm.equ_list = #{dto.equList}
</if>
<iftest="dto.equListCode != null and dto.equListCode != ''">
and tjurm.equ_list_code = #{dto.equListCode}
</if>
<iftest="dto.equCategory != null and dto.equCategory != ''">
and tjurm.equ_category = #{dto.equCategory}
</if>
<iftest="dto.equCategoryCode != null and dto.equCategoryCode != ''">
and tjurm.equ_category_code = #{dto.equCategoryCode}
</if>
<iftest="dto.equDefineCode != null and dto.equDefineCode != ''">
and tjurm.equ_define = #{dto.equDefineCode}
</if>
<iftest="dto.equDefineCode != null and dto.equDefineCode != ''">
and tjurm.equ_define_code = #{dto.equDefineCode}
</if>
<iftest="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
and tjurm.use_registration_code like concat('%',#{dto.useRegistrationCode},'%')
</if>
<iftest="dto.certificateStatus != null and dto.certificateStatus != ''">
and tjurm.certificate_status = #{dto.certificateStatus}
</if>
<iftest="dto.projectContraption != null and dto.projectContraption != ''">
and ibjpc.project_contraption like concat('%',#{dto.projectContraption},'%')
</if>
<iftest="dto.projectContraptionNo != null and dto.projectContraptionNo != ''">
and ibjpc.project_contraption_no like concat('%', #{dto.projectContraptionNo},'%')