LEFT JOIN (SELECT social_credit_code, CASE WHEN MAX(any_data) = 1 THEN 0 ELSE 1 END AS sign FROM sys_base_enterprise_ipo GROUP BY social_credit_code HAVING sign = 0) fina on e.social_credit_code = fina.social_credit_code
</if>
<iftest="enterpriseCondition.hasMan != null">
LEFT JOIN (SELECT social_credit_code,0 as sign
FROM sys_base_enterprise_executive
GROUP BY social_credit_code
) gg on e.social_credit_code = gg.social_credit_code
</if>
<iftest="enterpriseCondition.hasYb != null or enterpriseCondition.hasNb != null or enterpriseCondition.hasDt != null or enterpriseCondition.hasGg != null ">
LEFT JOIN clb_enterprise_report_analysis cera on e.social_credit_code = cera.social_credit_code
</if>
where 1 = 1
<iftest="enterpriseCondition.socialCreditCode != null and enterpriseCondition.socialCreditCode != ''">
and e.social_credit_code = #{enterpriseCondition.socialCreditCode}
</if>
<iftest="enterpriseCondition.securitiesCode != null and enterpriseCondition.securitiesCode != ''">
and ei.securities_code = #{enterpriseCondition.securitiesCode}
</if>
<iftest="enterpriseCondition.name != null and enterpriseCondition.name != ''">
and e.name like CONCAT('%',CONCAT(#{enterpriseCondition.name},'%'))
</if>
<iftest="enterpriseCondition.organizationCode != null and enterpriseCondition.organizationCode != ''">
and e.organization_code = #{enterpriseCondition.organizationCode}
</if>
<iftest="enterpriseCondition.province != null and enterpriseCondition.province != ''">
and e.province like CONCAT('%',#{enterpriseCondition.province},'%')
</if>
<iftest="enterpriseCondition.status != null">
and e.status = #{enterpriseCondition.status}
</if>
<iftest="enterpriseCondition.industryId != null and enterpriseCondition.industryId != ''">
and eim.industry_id = #{enterpriseCondition.industryId}
</if>
<iftest="enterpriseCondition.hasFinancialData != null and enterpriseCondition.hasFinancialData == 0">
and fina.sign = #{enterpriseCondition.hasFinancialData}
</if>
<iftest="enterpriseCondition.hasFinancialData != null and enterpriseCondition.hasFinancialData != 0">
and fina.sign is null
</if>
<iftest="enterpriseCondition.hasMan != null and enterpriseCondition.hasMan == 0">
and gg.sign = #{enterpriseCondition.hasMan}
</if>
<iftest="enterpriseCondition.hasMan != null and enterpriseCondition.hasMan != 0">
and gg.sign is null
</if>
<iftest="enterpriseCondition.hasBase != null and enterpriseCondition.hasBase == 0">
and ( (
e.yn_domestic = 1
AND e.`name` IS NOT NULL AND e.`name` != ''
AND e.social_credit_code IS NOT NULL AND e.social_credit_code != ''
AND e.address IS NOT NULL AND e.address != ''
AND e.industry IS NOT NULL AND e.industry != ''
AND e.legal_person IS NOT NULL AND e.legal_person != ''
) or (
e.yn_domestic = 0
AND e.`name` IS NOT NULL AND e.`name` != ''
AND e.social_credit_code IS NOT NULL AND e.social_credit_code != ''
AND e.english_name IS NOT NULL AND e.english_name != ''
) )
</if>
<iftest="enterpriseCondition.hasBase != null and enterpriseCondition.hasBase != 0">
and ( (
e.yn_domestic = 1
AND (e.`name` IS NULL or e.`name` = ''
or e.social_credit_code IS NULL or e.social_credit_code = ''
or e.address IS NULL or e.address = ''
or e.industry IS NULL or e.industry = ''
or e.legal_person IS NULL or e.legal_person = '')
) or (
e.yn_domestic = 0
AND (e.`name` IS NULL or e.`name` = ''
or e.social_credit_code IS NULL or e.social_credit_code = ''
or e.english_name IS NULL or e.english_name = '')
) )
</if>
<iftest="enterpriseCondition.hasYb != null and enterpriseCondition.hasYb == 0">
and cera.research_report_count>0
</if>
<iftest="enterpriseCondition.hasYb != null and enterpriseCondition.hasYb != 0">
and cera.research_report_count is null
</if>
<iftest="enterpriseCondition.hasNb != null and enterpriseCondition.hasNb == 0">
and cera.annual_report_count>0
</if>
<iftest="enterpriseCondition.hasNb != null and enterpriseCondition.hasNb != 0">
and cera.annual_report_count is null
</if>
<iftest="enterpriseCondition.hasDt != null and enterpriseCondition.hasDt == 0">
and cera.dynamic_state_count>0
</if>
<iftest="enterpriseCondition.hasDt != null and enterpriseCondition.hasDt != 0">
and cera.dynamic_state_count is null
</if>
<iftest="enterpriseCondition.hasGg != null and enterpriseCondition.hasGg == 0">
and cera.announcement_count>0
</if>
<iftest="enterpriseCondition.hasGg != null and enterpriseCondition.hasGg != 0">