Browse Source

监督端-各区扫码修改

dev-V1.10.0
niujiyi 5 days ago
parent
commit
a6ebc5b28d
  1. 137
      zdxt-modules/zdxt-enforcement-code/src/main/resources/mapper/enforcementcode/ScanDataSituationMapper.xml

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

@ -21,45 +21,36 @@
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 select
t4.code as code, code,
COUNT(1) as ent_cnt SUM(is_xz) as xz_cnt,
SUM(1 - is_xz) as fxz_cnt,
COUNT(DISTINCT enterprise_key) as ent_cnt
from 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 = 3
and t4.is_delete = '0'
group by
t4.code
) ent on
t3.code = ent.code
<!-- 2) 行政执法数量(条):enforcement_registration 按区聚合-->
left join (
select select
t2.area_node as code, t2.area_node as code,
COUNT(1) as xz_cnt 1 as is_xz,
COALESCE(NULLIF(TRIM(t1.enterprise_number),''), NULLIF(TRIM(t1.enterprise_name),'')) as enterprise_key
from from
enforcement_registration t1 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.is_delete = 0 t1.is_delete = 0
and t1.is_submit = 1 and t1.is_submit = 1
and t1.enterprise_name is not null and t1.enterprise_name is not null
and t1.enterprise_number is not null and t1.enterprise_number is not null
<!--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}
@ -68,31 +59,26 @@
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})
<!--and DATE_FORMAT(t1.enforcement_time,'%Y-%m') = DATE_FORMAT(#{bo.enforcementTime},'%Y-%m')-->
</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 union all
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
) u
group by group by
t2.area_node code
) fxz on ) agg on
t3.code = fxz.code t3.code = agg.code
where where
t3.level = 3 t3.level = 3
and t3.is_delete = '0' and t3.is_delete = '0'
@ -163,35 +150,24 @@
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 ( left join (
select select
t4.code as code, code,
COUNT(1) as ent_cnt SUM(is_xz) as xz_cnt,
SUM(1 - is_xz) as fxz_cnt,
COUNT(DISTINCT enterprise_key) as ent_cnt
from 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 select
t4.code as code, t4.code as code,
COUNT(1) as xz_cnt 1 as is_xz,
COALESCE(NULLIF(TRIM(t1.enterprise_number),''), NULLIF(TRIM(t1.enterprise_name),'')) as enterprise_key
from from
enforcement_registration t1 enforcement_registration t1
join dashboard_area_info t4 on join dashboard_area_info t4 on
@ -201,11 +177,11 @@
and t1.is_submit = 1 and t1.is_submit = 1
and t1.enterprise_name is not null and t1.enterprise_name is not null
and t1.enterprise_number is not null and t1.enterprise_number is not null
AND t4.level = 4 and t4.level = 4
and t4.is_delete = '0' and t4.is_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}
@ -214,22 +190,19 @@
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>
<if test="bo.districtCode!=null and bo.districtCode!=''"> <if test="bo.districtCode!=null and bo.districtCode!=''">
and t4.parent_code =#{bo.districtCode} and t4.parent_code =#{bo.districtCode}
</if> </if>
GROUP BY t4.code union all
) xz on
t3.code = xz.code
<!-- 3) 非行政执法数量:non_enforcement_registration 自带 enterprise_address,直接匹配街道名-->
left join (
select select
t4.code as code, t4.code 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
join dashboard_area_info t4 on join dashboard_area_info t4 on
@ -238,9 +211,9 @@
t1.has_delete = 0 t1.has_delete = 0
and t4.level = 4 and t4.level = 4
and t4.is_delete = '0' and t4.is_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}
@ -249,17 +222,19 @@
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>
<if test="bo.districtCode!=null and bo.districtCode!=''"> <if test="bo.districtCode!=null and bo.districtCode!=''">
and t4.parent_code =#{bo.districtCode} and t4.parent_code =#{bo.districtCode}
</if> </if>
GROUP BY t4.code ) u
) fxz on group by
t3.code = fxz.code 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