diff --git a/zdxt-modules/zdxt-enforcement-code/src/main/resources/mapper/enforcementcode/ScanDataSituationMapper.xml b/zdxt-modules/zdxt-enforcement-code/src/main/resources/mapper/enforcementcode/ScanDataSituationMapper.xml
index 1358a385..0549fd3e 100644
--- a/zdxt-modules/zdxt-enforcement-code/src/main/resources/mapper/enforcementcode/ScanDataSituationMapper.xml
+++ b/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
-
+
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
-
- 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) = #{bo.year}
-
-
- AND QUARTER(t1.enforcement_time) = #{bo.quarter}
-
-
- AND MONTH(t1.enforcement_time) = #{bo.month}
-
-
- AND DATE_FORMAT(t1.enforcement_time,'%Y-%m-%d') >= DATE_FORMAT(#{bo.startTime},'%Y-%m-%d')
-
-
-
- AND DATE_FORMAT(t1.enforcement_time,'%Y-%m-%d') <= DATE_FORMAT(#{bo.endTime},'%Y-%m-%d')
-
- and t2.area_node is not null
- group by
- t2.area_node
- ) xz on
- t3.code = xz.code
-
- left join (
+ and t1.is_submit = 1
+ and t1.enterprise_name is not null
+ and t1.enterprise_number is not null
+
+ AND t1.enforcement_time >= STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d')
+ AND t1.enforcement_time < DATE_ADD(STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d'), INTERVAL 1 YEAR)
+
+
+ AND QUARTER(t1.enforcement_time) = #{bo.quarter}
+
+
+ AND MONTH(t1.enforcement_time) = #{bo.month}
+
+
+ AND t1.enforcement_time >= DATE(#{bo.startTime})
+
+
+ AND t1.enforcement_time < DATE_ADD(DATE(#{bo.endTime}), INTERVAL 1 DAY)
+
+ 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) = #{bo.year}
+ AND t1.enforcement_time >= STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d')
+ AND t1.enforcement_time < DATE_ADD(STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d'), INTERVAL 1 YEAR)
AND QUARTER(t1.enforcement_time) = #{bo.quarter}
@@ -101,16 +87,17 @@
AND MONTH(t1.enforcement_time) = #{bo.month}
- AND DATE_FORMAT(t1.enforcement_time,'%Y-%m-%d') >= DATE_FORMAT(#{bo.startTime},'%Y-%m-%d')
+ AND t1.enforcement_time >= DATE(#{bo.startTime})
- AND DATE_FORMAT(t1.enforcement_time,'%Y-%m-%d') <= DATE_FORMAT(#{bo.endTime},'%Y-%m-%d')
+ AND t1.enforcement_time < DATE_ADD(DATE(#{bo.endTime}), INTERVAL 1 DAY)
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
-
- 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'
-
- and t4.parent_code =#{bo.districtCode}
-
- GROUP BY t4.code
- ) ent on
- t3.code = ent.code
-
+
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) = #{bo.year}
-
-
- AND QUARTER(t1.enforcement_time) = #{bo.quarter}
-
-
- AND MONTH(t1.enforcement_time) = #{bo.month}
-
-
- AND DATE_FORMAT(t1.enforcement_time,'%y-%m-%d') >= DATE_FORMAT(#{bo.startTime},'%y-%m-%d')
-
-
- AND DATE_FORMAT(t1.enforcement_time,'%y-%m-%d') <= DATE_FORMAT(#{bo.endTime},'%y-%m-%d')
-
-
- and t4.parent_code =#{bo.districtCode}
-
- GROUP BY t4.code
- ) xz on
- t3.code = xz.code
-
- 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) = #{bo.year}
-
-
- AND QUARTER(t1.enforcement_time) = #{bo.quarter}
-
-
- AND MONTH(t1.enforcement_time) = #{bo.month}
-
-
- AND DATE_FORMAT(t1.enforcement_time,'%y-%m-%d') >= DATE_FORMAT(#{bo.startTime},'%y-%m-%d')
-
-
- AND DATE_FORMAT(t1.enforcement_time,'%y-%m-%d') <= DATE_FORMAT(#{bo.endTime},'%y-%m-%d')
-
-
- and t4.parent_code =#{bo.districtCode}
-
- 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'
+
+ AND t1.enforcement_time >= STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d')
+ AND t1.enforcement_time < DATE_ADD(STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d'), INTERVAL 1 YEAR)
+
+
+ AND QUARTER(t1.enforcement_time) = #{bo.quarter}
+
+
+ AND MONTH(t1.enforcement_time) = #{bo.month}
+
+
+ AND t1.enforcement_time >= DATE(#{bo.startTime})
+
+
+ AND t1.enforcement_time < DATE_ADD(DATE(#{bo.endTime}), INTERVAL 1 DAY)
+
+
+ and t4.parent_code =#{bo.districtCode}
+
+ 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'
+
+ AND t1.enforcement_time >= STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d')
+ AND t1.enforcement_time < DATE_ADD(STR_TO_DATE(CONCAT(#{bo.year},'-01-01'),'%Y-%m-%d'), INTERVAL 1 YEAR)
+
+
+ AND QUARTER(t1.enforcement_time) = #{bo.quarter}
+
+
+ AND MONTH(t1.enforcement_time) = #{bo.month}
+
+
+ AND t1.enforcement_time >= DATE(#{bo.startTime})
+
+
+ AND t1.enforcement_time < DATE_ADD(DATE(#{bo.endTime}), INTERVAL 1 DAY)
+
+
+ and t4.parent_code =#{bo.districtCode}
+
+ ) u
+ group by
+ code
+ ) agg on
+ t3.code = agg.code
where
t3.level = 4
and t3.is_delete = '0'