Browse Source

监督端-各区扫码修改

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

Loading…
Cancel
Save