LEFT JOIN ( SELECT allow_id, COUNT( id ) AS materialCount FROM t_contractor_allow_material GROUP BY allow_id ) AS material ON tca.id = material.allow_id
LEFT JOIN ( SELECT allow_id, COUNT( id ) AS protectiveCount FROM t_contractor_allow_protective GROUP BY allow_id ) AS protective ON tca.id = protective.allow_id
LEFT JOIN ( SELECT allow_id, COUNT( id ) AS trainingRecordCount FROM t_contractor_allow_person WHERE training_record IS NOT NULL GROUP BY allow_id ) AS trainingRecord ON tca.id = trainingRecord.allow_id
where tca.org_id IN (select org.org_id from t_sys_org org where org.parent_ids like concat('%',#{param.orgId},'%') or org.org_id = #{param.orgId})
<!--where tca.org_id IN (select org.org_id from t_sys_org org where org.parent_ids like concat('%',#{param.orgId},'%') or org.org_id = #{param.orgId})-->
WHERE EXISTS (
SELECT 1
FROM unnest(string_to_array(tca.org_id, ',')) AS org(id)
JOIN t_sys_org o ON org.id = o.org_id
WHERE
o.parent_ids LIKE concat('%',#{param.orgId},'%')
OR o.org_id = #{param.orgId}
)
and tca.status = '0'
<iftest="param.contractorName != null and param.contractorName != ''">
AND tci.name like concat('%',#{param.contractorName},'%')
LEFT JOIN t_contractor_project AS tcp ON tcp.id = tcdp.proj_id
left JOIN (SELECT plan_id,count(id) as hazardCount FROM t_contractor_daily_plan_inspect_result_hazard GROUP BY plan_id) as hazard on hazard.plan_id = tcdp.id
left join (SELECT plan_id,count(id) as inspectCount FROM t_contractor_daily_plan_inspect GROUP BY plan_id) as inspect on inspect.plan_id = tcdp.id
<where>
<!--<where>
tcdp.status != '1'
and tcdp.org_id IN (select org.org_id from t_sys_org org where org.parent_ids like concat('%',#{param.orgId},'%') or org.org_id = #{param.orgId})
<if test="param.contractorName != null and param.contractorName != ''">
...
...
@@ -54,6 +54,25 @@
AND tcdp.process_status like concat('%',#{param.processStatus},'%')
</if>
order by tcdp.update_date desc
</where>
</where>-->
WHERE EXISTS (
SELECT 1
FROM unnest(string_to_array(tcdp.org_id, ',')) AS org(id)
JOIN t_sys_org o ON org.id = o.org_id
WHERE
o.parent_ids LIKE concat('%',#{param.orgId},'%')
OR o.org_id = #{param.orgId}
)
and tcdp.status != '1'
<iftest="param.contractorName != null and param.contractorName != ''">
AND tci.name like concat('%',#{param.contractorName},'%')
</if>
<iftest="param.projectName != null and param.projectName != ''">
AND tcp.name like concat('%',#{param.projectName},'%')
</if>
<iftest="param.processStatus != null and param.processStatus != ''">
AND tcdp.process_status like concat('%',#{param.processStatus},'%')