1、背景
业务部门需大数据平台按照所提需求提供企业数据接口,基于神软大数据治理平台 -高级动态SQL功能 ,满足业务需求,如下:
(1)业务系统需求:
输入:
enterpriseName :企业名称部分信息,模糊查询,示例:科技,必填 。
province :企业地址所在的省份,精准查询结果,示例:北京,非必填 。
status : 企业的经营状态,精准查询结果,非必填 。
capitalLowBound :企业注册资本金额的下限值,单位万元,要求注册资本>=capitalLowBound,非必填 ,示例:200。
capitalHighBound :企业注册资本金额的上限值,单位万元,要求注册资本<capitalHighBound,非必填,示例:500。
输出:
返回两部分汇总数据
1.符合搜索条件的省份数据汇总,例如符合的搜索条件企业,北京有10家,上海有5家,广东有3家。返回内容:
北京:10
上海:5
广东:3
2.符合搜索条件的企业经营状态汇总,例如符合的搜索条件企业,存续状态有10家,注销状态5家,吊销状态有3家。返回内容:
存续:10
注销:5
吊销:3
1和2的内容是并行的关系,各自汇总,求:
省份:北京:3
省份:上海:6
状态:存续:5
状态:注销:4
(2)大数据治理平台配置:
SQL示例:
bash
SELECT m1.SFZT,m1.ZDATA,m1.NUM FROM
(SELECT
'省份' AS sfzt,
t2.SHORT_NAME AS zdata,
COUNT(1) AS num
FROM
ICASC.T_ENTERPRISE t1 LEFT JOIN ICASC.T_ADMIN_DIVISION_CODE t2 ON t1.PROVINCE_CODE=t2.TYPE_CODE
<where>
t1.NAME LIKE '%${enterpriseName}%'
<if test="province != null and province != ''">
and t2.SHORT_NAME = '${province}'
</if>
<if test="status != null and status != ''">
and t1.NEW_STATUS_CODE = '${status}'
</if>
<if test="capitalLowBound != null and capitalLowBound != ''">
and t1.REGIST_CAPI_NEW >= ${capitalLowBound}
</if>
<if test="capitalHighBound != null and capitalHighBound != ''">
and t1.REGIST_CAPI_NEW < ${capitalHighBound}
</if>
</where>
GROUP BY t2.SHORT_NAME
UNION ALL
SELECT
'状态'AS sfzt,
t3.STATUS AS zdata,
COUNT(1) AS num
FROM ICASC.T_ENTERPRISE t3 LEFT JOIN ICASC.T_ADMIN_DIVISION_CODE t4 ON t3.PROVINCE_CODE=t4.TYPE_CODE
<where>
t3.NAME LIKE '%${enterpriseName}%'
<if test="province != null and province != ''">
and t4.SHORT_NAME = '${province}'
</if>
<if test="status != null and status != ''">
and t3.NEW_STATUS_CODE = '${status}'
</if>
<if test="capitalLowBound != null and capitalLowBound != ''">
and t3.REGIST_CAPI_NEW >= ${capitalLowBound}
</if>
<if test="capitalHighBound != null and capitalHighBound != ''">
and t3.REGIST_CAPI_NEW < ${capitalHighBound}
</if>
</where>
GROUP BY t3.NEW_STATUS_CODE,t3.STATUS) m1 ORDER BY m1.SFZT,m1.NUM