分包合同SQL重新写
This commit is contained in:
parent
20cb95b578
commit
ada1504771
|
|
@ -87,23 +87,22 @@
|
|||
</delete>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from (
|
||||
SELECT
|
||||
bsc.id
|
||||
FROM
|
||||
bm_sub_contract bsc
|
||||
LEFT JOIN bm_subcontractor bs ON bs.id = bsc.sub_id and bs.is_active = '1'
|
||||
LEFT JOIN bm_project bp ON bp.id = bsc.pro_id and bp.is_active = '1'
|
||||
LEFT JOIN pm_organization po ON po.id = bp.company_id and po.is_active = '1'
|
||||
LEFT JOIN bm_sub_relation bsr1 on bsc.id = bsr1.sub_contract_id and bsr1.type = '1' and bsr1.is_active = '1'
|
||||
LEFT JOIN bm_sub_relation bsr2 on bsc.id = bsr2.sub_contract_id and bsr2.type = '2' and bsr2.is_active = '1'
|
||||
|
||||
LEFT JOIN sys_user su ON su.id = bsr1.`value` and su.sub_id = bsc.sub_id and su.is_active = '1'
|
||||
|
||||
LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id and btur.is_active = '1' and btur.id_number is not null
|
||||
<include refid="where" />
|
||||
GROUP BY bsc.id
|
||||
)a
|
||||
select count(1) from (
|
||||
SELECT
|
||||
bsc.id
|
||||
FROM
|
||||
bm_sub_contract bsc
|
||||
LEFT JOIN bm_subcontractor bs ON bs.id = bsc.sub_id and bs.is_active = '1'
|
||||
LEFT JOIN bm_project bp ON bp.id = bsc.pro_id and bp.is_active = '1'
|
||||
LEFT JOIN pm_organization po ON po.id = bp.company_id and po.is_active = '1'
|
||||
LEFT JOIN bm_sub_relation bsr1 on bsc.id = bsr1.sub_contract_id and bsr1.type = '1' and bsr1.is_active = '1'
|
||||
LEFT JOIN bm_sub_relation bsr2 on bsc.id = bsr2.sub_contract_id and bsr2.type = '2' and bsr2.is_active = '1'
|
||||
LEFT JOIN sys_user su ON su.id = bsr1.`value` and su.sub_id = bsc.sub_id and su.is_active = '1'
|
||||
left join bm_sub_team bst on bst.sub_id = bs.id and bst.is_active = 1
|
||||
LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id and btur.is_active = '1' and btur.id_number is not null
|
||||
<include refid="where" />
|
||||
GROUP BY bsc.id
|
||||
)a
|
||||
</select>
|
||||
|
||||
<select id="list" resultType="com.bonus.bmw.subContractor.entity.SubContractBean">
|
||||
|
|
@ -115,7 +114,6 @@ select count(1) from (
|
|||
bsc.is_complete as isComplete,
|
||||
bsc.contract_money as contractMoney,
|
||||
su.username as principal,
|
||||
|
||||
COUNT(DISTINCT btur.id) as personNumber,
|
||||
COUNT(DISTINCT bsr2.id) as fileNumber,
|
||||
GROUP_CONCAT(DISTINCT bsr2.`value`) as filePaths,
|
||||
|
|
@ -130,9 +128,8 @@ select count(1) from (
|
|||
LEFT JOIN pm_organization po ON po.id = bp.company_id and po.is_active = '1'
|
||||
LEFT JOIN bm_sub_relation bsr1 on bsc.id = bsr1.sub_contract_id and bsr1.type = '1' and bsr1.is_active = '1'
|
||||
LEFT JOIN bm_sub_relation bsr2 on bsc.id = bsr2.sub_contract_id and bsr2.type = '2' and bsr2.is_active = '1'
|
||||
|
||||
LEFT JOIN sys_user su ON su.id = bsr1.`value` and su.sub_id = bsc.sub_id and su.is_active = '1'
|
||||
|
||||
left join bm_sub_team bst on bst.sub_id = bs.id and bst.is_active = 1
|
||||
LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id and btur.is_active = '1' and btur.id_number is not null
|
||||
LEFT JOIN bm_worker_ein_history bweh ON bweh.sub_id = bsc.sub_id AND bweh.is_active='1'
|
||||
<include refid="where" />
|
||||
|
|
@ -345,4 +342,4 @@ select count(1) from (
|
|||
and btur.id_number is not null
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue