Browse Source

监督端-各区扫码修改

dev-V1.10.0
niujiyi 3 hours ago
parent
commit
a6ebc5b28d
  1. 285
      zdxt-modules/zdxt-enforcement-code/src/main/resources/mapper/enforcementcode/ScanDataSituationMapper.xml

285
zdxt-modules/zdxt-enforcement-code/src/main/resources/mapper/enforcementcode/ScanDataSituationMapper.xml

@ -21,78 +21,64 @@
select select
t3.code as district_code, t3.code as district_code,
t3.name as district_name, t3.name as district_name,
coalesce (ent.ent_cnt,0) as enterprise_count, coalesce (agg.ent_cnt,0) as enterprise_count,
coalesce (xz.xz_cnt,0) as xzzf_count, coalesce (agg.xz_cnt,0) as xzzf_count,
coalesce (fxz.fxz_cnt,0) as fxzzf_count coalesce (agg.fxz_cnt,0) as fxzzf_count
from from
dashboard_area_info t3 dashboard_area_info t3
<!-- 1) 商事主体数量(户):通过企业地址截取区名归集,不再走 sys_dept.dept_id--> <!-- 两类执法数据各扫描一次:同时得到执法数量与去重后的执法企业数 -->
left join ( left join (
select
code,
SUM(is_xz) as xz_cnt,
SUM(1 - is_xz) as fxz_cnt,
COUNT(DISTINCT enterprise_key) as ent_cnt
from
(
select select
t4.code as code, t2.area_node as code,
COUNT(1) as ent_cnt 1 as is_xz,
COALESCE(NULLIF(TRIM(t1.enterprise_number),''), NULLIF(TRIM(t1.enterprise_name),'')) as enterprise_key
from from
enterprise_information t1 enforcement_registration t1
join dashboard_area_info t4 on inner join sys_dept t2 on
t1.enterprise_address like CONCAT('%' ,t4.name,'%') t1.bureau_dept_id = t2.dept_id
where where
t1.is_delete = 0 t1.is_delete = 0
and t4.level = 3 and t1.is_submit = 1
and t4.is_delete = '0' and t1.enterprise_name is not null
group by and t1.enterprise_number is not null
t4.code <if test = "bo.year != null">
) ent on AND t1.enforcement_time &gt;= STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d')
t3.code = ent.code AND t1.enforcement_time &lt; DATE_ADD(STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d'), INTERVAL 1 YEAR)
<!-- 2) 行政执法数量(条):enforcement_registration 按区聚合--> </if>
left join ( <if test = "bo.quarter != null">
select AND QUARTER(t1.enforcement_time) = #{bo.quarter}
t2.area_node as code, </if>
COUNT(1) as xz_cnt <if test = "bo.month != null">
from AND MONTH(t1.enforcement_time) = #{bo.month}
enforcement_registration t1 </if>
left join sys_dept t2 on <if test = "bo.startTime != null">
t1.bureau_dept_id = t2.dept_id AND t1.enforcement_time &gt;= DATE(#{bo.startTime})
where </if>
t1.is_delete = 0 <if test = "bo.endTime != null">
and t1.is_submit = 1 AND t1.enforcement_time &lt; DATE_ADD(DATE(#{bo.endTime}), INTERVAL 1 DAY)
and t1.enterprise_name is not null </if>
and t1.enterprise_number is not null and t2.area_node is not null
<!--and year(t1.enforcement_time) = '2026'--> union all
<if test = "bo.year != null">
AND YEAR(t1.enforcement_time) = #{bo.year}
</if>
<if test = "bo.quarter != null">
AND QUARTER(t1.enforcement_time) = #{bo.quarter}
</if>
<if test = "bo.month != null">
AND MONTH(t1.enforcement_time) = #{bo.month}
</if>
<if test = "bo.startTime != null">
AND DATE_FORMAT(t1.enforcement_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{bo.startTime},'%Y-%m-%d')
<!--and DATE_FORMAT(t1.enforcement_time,'%Y-%m') = DATE_FORMAT(#{bo.enforcementTime},'%Y-%m')-->
</if>
<if test = "bo.endTime != null">
AND DATE_FORMAT(t1.enforcement_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{bo.endTime},'%Y-%m-%d')
</if>
and t2.area_node is not null
group by
t2.area_node
) xz on
t3.code = xz.code
<!-- 3) 非行政执法数量:non_enforcement_registration 按区聚合-->
left join (
select select
t2.area_node as code, t2.area_node as code,
COUNT(1) as fxz_cnt 0 as is_xz,
COALESCE(NULLIF(TRIM(t1.enterprise_number),''), NULLIF(TRIM(t1.enterprise_name),'')) as enterprise_key
from from
non_enforcement_registration t1 non_enforcement_registration t1
left join sys_dept t2 on inner join sys_dept t2 on
t1.bureau_dept_id = t2.dept_id t1.bureau_dept_id = t2.dept_id
where where
t1.has_delete = 0 t1.has_delete = 0
<!--and year(t1.enforcement_time) = '2026'-->
<if test = "bo.year != null"> <if test = "bo.year != null">
AND YEAR(t1.enforcement_time) = #{bo.year} AND t1.enforcement_time &gt;= STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d')
AND t1.enforcement_time &lt; DATE_ADD(STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d'), INTERVAL 1 YEAR)
</if> </if>
<if test = "bo.quarter != null"> <if test = "bo.quarter != null">
AND QUARTER(t1.enforcement_time) = #{bo.quarter} AND QUARTER(t1.enforcement_time) = #{bo.quarter}
@ -101,16 +87,17 @@
AND MONTH(t1.enforcement_time) = #{bo.month} AND MONTH(t1.enforcement_time) = #{bo.month}
</if> </if>
<if test = "bo.startTime != null"> <if test = "bo.startTime != null">
AND DATE_FORMAT(t1.enforcement_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{bo.startTime},'%Y-%m-%d') AND t1.enforcement_time &gt;= DATE(#{bo.startTime})
</if> </if>
<if test = "bo.endTime != null"> <if test = "bo.endTime != null">
AND DATE_FORMAT(t1.enforcement_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{bo.endTime},'%Y-%m-%d') AND t1.enforcement_time &lt; DATE_ADD(DATE(#{bo.endTime}), INTERVAL 1 DAY)
</if> </if>
and t2.area_node is not null and t2.area_node is not null
group by ) u
t2.area_node group by
) fxz on code
t3.code = fxz.code ) agg on
t3.code = agg.code
where where
t3.level = 3 t3.level = 3
and t3.is_delete = '0' and t3.is_delete = '0'
@ -163,103 +150,91 @@
select select
t3.code as street_code, t3.code as street_code,
t3.name as street_name, t3.name as street_name,
coalesce (ent.ent_cnt,0) as enterprise_count, coalesce (agg.ent_cnt,0) as enterprise_count,
coalesce (xz.xz_cnt,0) as xzzf_count, coalesce (agg.xz_cnt,0) as xzzf_count,
coalesce (fxz.fxz_cnt,0) as fxzzf_count coalesce (agg.fxz_cnt,0) as fxzzf_count
from from
dashboard_area_info t3 dashboard_area_info t3
<!-- 1) 商事主体数量:enterprise_information 企业地址匹配街道名--> <!-- 两类执法数据各扫描一次,地址匹配街道名,同时得到执法数量与去重后的执法企业数 -->
left join (
select
t4.code as code,
COUNT(1) as ent_cnt
from
enterprise_information t1
join dashboard_area_info t4 on
t1.enterprise_address like CONCAT('%' ,t4.name,'%')
where
t1.is_delete = 0
and t4.level = 4
and t4.is_delete = '0'
<if test="bo.districtCode!=null and bo.districtCode!=''">
and t4.parent_code =#{bo.districtCode}
</if>
GROUP BY t4.code
) ent on
t3.code = ent.code
<!-- 2) 行政执法数量:enforcement_registration 自带 enterprise_address,直接匹配街道名-->
left join ( left join (
select select
t4.code as code, code,
COUNT(1) as xz_cnt SUM(is_xz) as xz_cnt,
SUM(1 - is_xz) as fxz_cnt,
COUNT(DISTINCT enterprise_key) as ent_cnt
from from
enforcement_registration t1 (
join dashboard_area_info t4 on select
t1.enterprise_address like CONCAT('%',t4.name,'%') t4.code as code,
where 1 as is_xz,
t1.is_delete = 0 COALESCE(NULLIF(TRIM(t1.enterprise_number),''), NULLIF(TRIM(t1.enterprise_name),'')) as enterprise_key
and t1.is_submit = 1 from
and t1.enterprise_name is not null enforcement_registration t1
and t1.enterprise_number is not null join dashboard_area_info t4 on
AND t4.level = 4 t1.enterprise_address like CONCAT('%',t4.name,'%')
and t4.is_delete = '0' where
<!--and year(t1.enforcement_time) ='2026'--> t1.is_delete = 0
<if test = "bo.year != null"> and t1.is_submit = 1
AND YEAR(t1.enforcement_time) = #{bo.year} and t1.enterprise_name is not null
</if> and t1.enterprise_number is not null
<if test = "bo.quarter != null"> and t4.level = 4
AND QUARTER(t1.enforcement_time) = #{bo.quarter} and t4.is_delete = '0'
</if> <if test = "bo.year != null">
<if test = "bo.month != null"> AND t1.enforcement_time &gt;= STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d')
AND MONTH(t1.enforcement_time) = #{bo.month} AND t1.enforcement_time &lt; DATE_ADD(STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d'), INTERVAL 1 YEAR)
</if> </if>
<if test = "bo.startTime != null"> <if test = "bo.quarter != null">
AND DATE_FORMAT(t1.enforcement_time,'%y-%m-%d') &gt;= DATE_FORMAT(#{bo.startTime},'%y-%m-%d') AND QUARTER(t1.enforcement_time) = #{bo.quarter}
</if> </if>
<if test = "bo.endTime != null"> <if test = "bo.month != null">
AND DATE_FORMAT(t1.enforcement_time,'%y-%m-%d') &lt;= DATE_FORMAT(#{bo.endTime},'%y-%m-%d') AND MONTH(t1.enforcement_time) = #{bo.month}
</if> </if>
<if test="bo.districtCode!=null and bo.districtCode!=''"> <if test = "bo.startTime != null">
and t4.parent_code =#{bo.districtCode} AND t1.enforcement_time &gt;= DATE(#{bo.startTime})
</if> </if>
GROUP BY t4.code <if test = "bo.endTime != null">
) xz on AND t1.enforcement_time &lt; DATE_ADD(DATE(#{bo.endTime}), INTERVAL 1 DAY)
t3.code = xz.code </if>
<!-- 3) 非行政执法数量:non_enforcement_registration 自带 enterprise_address,直接匹配街道名--> <if test="bo.districtCode!=null and bo.districtCode!=''">
left join ( and t4.parent_code =#{bo.districtCode}
select </if>
t4.code as code, union all
COUNT(1) as fxz_cnt select
from t4.code as code,
non_enforcement_registration t1 0 as is_xz,
join dashboard_area_info t4 on COALESCE(NULLIF(TRIM(t1.enterprise_number),''), NULLIF(TRIM(t1.enterprise_name),'')) as enterprise_key
t1.enterprise_address like CONCAT('%',t4.name,'%') from
where non_enforcement_registration t1
t1.has_delete = 0 join dashboard_area_info t4 on
and t4.level = 4 t1.enterprise_address like CONCAT('%',t4.name,'%')
and t4.is_delete = '0' where
<!--and year(t1.enforcement_time) ='2026'--> t1.has_delete = 0
<if test = "bo.year != null"> and t4.level = 4
AND YEAR(t1.enforcement_time) = #{bo.year} and t4.is_delete = '0'
</if> <if test = "bo.year != null">
<if test = "bo.quarter != null"> AND t1.enforcement_time &gt;= STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d')
AND QUARTER(t1.enforcement_time) = #{bo.quarter} AND t1.enforcement_time &lt; DATE_ADD(STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d'), INTERVAL 1 YEAR)
</if> </if>
<if test = "bo.month != null"> <if test = "bo.quarter != null">
AND MONTH(t1.enforcement_time) = #{bo.month} AND QUARTER(t1.enforcement_time) = #{bo.quarter}
</if> </if>
<if test = "bo.startTime != null"> <if test = "bo.month != null">
AND DATE_FORMAT(t1.enforcement_time,'%y-%m-%d') &gt;= DATE_FORMAT(#{bo.startTime},'%y-%m-%d') AND MONTH(t1.enforcement_time) = #{bo.month}
</if> </if>
<if test = "bo.endTime != null"> <if test = "bo.startTime != null">
AND DATE_FORMAT(t1.enforcement_time,'%y-%m-%d') &lt;= DATE_FORMAT(#{bo.endTime},'%y-%m-%d') AND t1.enforcement_time &gt;= DATE(#{bo.startTime})
</if> </if>
<if test="bo.districtCode!=null and bo.districtCode!=''"> <if test = "bo.endTime != null">
and t4.parent_code =#{bo.districtCode} AND t1.enforcement_time &lt; DATE_ADD(DATE(#{bo.endTime}), INTERVAL 1 DAY)
</if> </if>
GROUP BY t4.code <if test="bo.districtCode!=null and bo.districtCode!=''">
) fxz on and t4.parent_code =#{bo.districtCode}
t3.code = fxz.code </if>
) u
group by
code
) agg on
t3.code = agg.code
where where
t3.level = 4 t3.level = 4
and t3.is_delete = '0' and t3.is_delete = '0'

Loading…
Cancel
Save