Commit f69ac10f authored by suhuiguang's avatar suhuiguang

fix(jg): 单位变更

1.管道单位变更选择装置慢初版
parent 7f9b932c
......@@ -508,129 +508,60 @@
<select id="queryForUnitByProjectContraptionPage"
resultType="com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption">
SELECT distinct
ibjpc.*,
(SELECT ei.sequence_nbr from idx_biz_jg_use_info ui
LEFT JOIN tz_base_enterprise_info ei ON ei.use_unit_code = ui."ESTATE_UNIT_CREDIT_CODE"
WHERE ui."PROJECT_CONTRAPTION_ID" = ibjpc.sequence_nbr ORDER BY ui."REC_DATE" DESC LIMIT 1) AS estateUnitName
FROM
idx_biz_jg_project_contraption ibjpc
LEFT JOIN tzs_jg_use_registration_manage tjurm ON ibjpc.use_registration_code = tjurm.use_registration_code
WHERE
EXISTS (
SELECT
1
ibjpc.sequence_nbr,
ibjpc.project_contraption,
ibjpc.project_contraption_no,
ibjpc.use_unit_credit_code,
ibjpc.use_unit_name,
ibjpc.usc_unit_credit_code,
ibjpc.usc_unit_name,
ibjpc.equ_list_name,
ibjpc.equ_list,
ibjpc.equ_category_name,
ibjpc.equ_category,
ibjpc.equ_define_name,
ibjpc.equ_define,
ibjpc.content,
ibjpc.rec_date,
ibjpc.rec_user_id,
ibjpc.pipeline_length,
ibjpc.org_code,
ibjpc.org_name,
ibjpc.province,
ibjpc.city,
ibjpc.county,
ibjpc.street,
ibjpc.address,
ibjpc.province_name,
ibjpc.city_name,
ibjpc.county_name,
ibjpc.street_name,
ibjpc.create_date,
ibjpc.create_user_name,
ibjpc.supervisory_code,
ibjpc.use_registration_code,
ibjpc.is_into_management,
ibjpc.data_source,
ibjpc.equ_code,
ibjpc.use_date,
(SELECT ei.sequence_nbr from idx_biz_jg_use_info ui
LEFT JOIN tz_base_enterprise_info ei ON ei.use_unit_code = ui."ESTATE_UNIT_CREDIT_CODE"
WHERE ui."PROJECT_CONTRAPTION_ID" = ibjpc.sequence_nbr ORDER BY ui."REC_DATE" DESC LIMIT 1) AS estateUnitName
FROM
idx_biz_jg_use_info ibjui
INNER JOIN (
select DISTINCT record from (
select
equ_id as record
from
tzs_jg_use_registration a,
tzs_jg_use_registration_eq b
where
a.sequence_nbr = b.equip_transfer_id
and a.is_delete = 0
and (a.status <![CDATA[ <> ]]> '使用单位待提交' and a.status <![CDATA[ <> ]]> '一级受理已驳回' and a.status <![CDATA[ <> ]]> '使用单位已撤回' and a.status <![CDATA[ <> ]]> '已作废')
UNION
select
equ_id as record
from
tzs_jg_change_registration_reform a,
tzs_jg_change_registration_reform_eq b
where
a.sequence_nbr = b.equip_transfer_id
and (a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '一级受理已驳回' and a.audit_status <![CDATA[ <> ]]> '使用单位已撤回' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
equ_id as record
from
tzs_jg_change_registration_transfer a,
tzs_jg_change_registration_transfer_eq b
where
a.sequence_nbr = b.equip_transfer_id
and (a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '一级受理已驳回' and a.audit_status <![CDATA[ <> ]]> '使用单位已撤回' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
equ_id as record
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[ <> ]]> '已作废')
UNION
select
equ_id as record
from
tzs_jg_enable_disable a,
tzs_jg_enable_disable_eq b
where
a.sequence_nbr = b.enable_disable_apply_id
and (a.audit_status <![CDATA[ <> ]]> '已驳回' and a.audit_status <![CDATA[ <> ]]> '已撤回' and a.audit_status <![CDATA[ <> ]]> '待提交' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
equ_id as record
from
tzs_jg_installation_notice a,
tzs_jg_installation_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and (a.notice_status <![CDATA[ <> ]]> '6614' and a.notice_status <![CDATA[ <> ]]> '6615' and a.notice_status <![CDATA[ <> ]]> '6610' and a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
equ_id as record
from
tzs_jg_maintain_notice a,
tzs_jg_maintain_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and (a.notice_status <![CDATA[ <> ]]> '6614' and a.notice_status <![CDATA[ <> ]]> '6615' and a.notice_status <![CDATA[ <> ]]> '6610' and a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
equ_id as record
from
tzs_jg_reform_notice a,
tzs_jg_reform_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and (a.notice_status <![CDATA[ <> ]]> '6614' and a.notice_status <![CDATA[ <> ]]> '6615' and a.notice_status <![CDATA[ <> ]]> '6610' and a.notice_status <![CDATA[ <> ]]> '6617')
UNION
select
equ_id as record
from
tzs_jg_scrap_cancel a,
tzs_jg_scrap_cancel_eq b
where
a.sequence_nbr = b.equip_transfer_id
and (a.audit_status <![CDATA[ <> ]]> '使用单位已撤回' and a.audit_status <![CDATA[ <> ]]> '一级受理已驳回' and a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION
select
equ_id as record
from
tzs_jg_transfer_notice a,
tzs_jg_transfer_notice_eq b
where
a.sequence_nbr = b.equip_transfer_id
and (a.notice_status <![CDATA[ <> ]]> '6614' and a.notice_status <![CDATA[ <> ]]> '6615' and a.notice_status <![CDATA[ <> ]]> '6610' and a.notice_status <![CDATA[ <> ]]> '6617')
) temp
) a ON ibjui."RECORD" = a.record
idx_biz_jg_project_contraption ibjpc
LEFT JOIN tzs_jg_use_registration_manage tjurm ON ibjpc.use_registration_code = tjurm.use_registration_code
WHERE
ibjpc.sequence_nbr = ibjui."PROJECT_CONTRAPTION_ID"
)
and ibjpc.use_unit_credit_code = #{dto.originalUseUnitCreditCode}
and ibjpc.is_delete = 0
and tjurm.is_delete = 0
and (ibjpc.project_contraption_parent_id is null or ibjpc.project_contraption_parent_id = '')
AND NOT EXISTS (
SELECT 1
FROM idx_biz_jg_use_info ui
WHERE ui."PROJECT_CONTRAPTION_ID" = ibjpc.sequence_nbr
GROUP BY ui."PROJECT_CONTRAPTION_ID"
HAVING COUNT(*) > 0
AND COUNT(*) = SUM(CASE WHEN ui."EQU_STATE" = '3' THEN 1 ELSE 0 END)
)
ibjpc.use_unit_credit_code = #{dto.originalUseUnitCreditCode}
and ibjpc.is_delete = 0
and tjurm.is_delete = 0
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' )
)
<if test="dto.equList != null and dto.equList != ''">
and tjurm.equ_list = #{dto.equList}
</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment