Commit 16c743b9 authored by tianbo's avatar tianbo

feat(statistics): 优化统计查询逻辑并调整SQL结构

- 修改 CommonBaseMapper.xml,增加 company_code 非空条件过滤脏数据 - 在 JGDPStatisticsServiceImpl.java 中引入 ConcurrentHashMap 缓存区域机构代码列表 - 新增 getOrgCodeListByRegionCode 方法用于获取缓存或查询机构代码列表 - 替换原有的 regionCode 查询参数为 orgCode 参数传递方式 - 更新各类统计方法实现,统一使用 orgCode 查询替代 cityCode - 调整 mapper 接口定义,删除按年/月拆分的查询接口,合并为时间段查询接口 - 重写 JGStatisticsMapper.xml 中 SQL 查询逻辑,使用 supervision_info 表关联 - 引入公用 SQL 片段 maintenanceCountSql 提高复用性 - 删除冗余 vehicleEquCount 相关查询方法及实现 - 使用 audit_pass_date 字段代替 rec_date 提高准确性 - 统一时间筛选条件格式并支持动态起止时间范围查询 - 添加 FieldMapping 注解支持 cityCode 到 companyCodes 的字段映射转换
parent 7bf0b204
package com.yeejoin.amos.boot.module.statistics.api.mapper; package com.yeejoin.amos.boot.module.statistics.api.mapper;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.dto.CountDto; import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto; import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
...@@ -11,42 +12,36 @@ import java.util.Map; ...@@ -11,42 +12,36 @@ import java.util.Map;
public interface JGStatisticsMapper { public interface JGStatisticsMapper {
List<Map<String, Object>> maintenanceCountTopTen(@Param("dpFilterParamDto") DPFilterParamDto dpFilterParamDto, @Param("regionCodeList") List<Integer> regionCodeList); List<Map<String, Object>> maintenanceCountTopTen(@Param("orgCodeList") List<String> orgCodeList);
List<Map<String, Object>> maintenanceCount(@Param("dpFilterParamDto") DPFilterParamDto dpFilterParamDto, @Param("regionCodeList") List<Integer> regionCodeList); List<Map<String, Object>> maintenanceCount(@Param("orgCodeList") List<String> orgCodeList);
List<Map<String, Object>> installEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> installEquCount(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<Map<String, Object>> maintenanceEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> maintenanceEquCount(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<Map<String, Object>> reformEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> reformEquCount(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<Map<String, Object>> transferEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> transferEquCount(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<Map<String, Object>> useEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> useEquCount(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<Map<String, Object>> changeReformEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> changeReformEquCount(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<Map<String, Object>> changeTransferEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> changeTransferEquCount(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<Map<String, Object>> changeUnitEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> changeUnitEquCount(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<Map<String, Object>> vehicleEquCount(@Param("cityCode") String cityCode, @Param("startTime") String startTime); List<Map<String, Object>> newRegEquCountByMonth(@Param("orgCode") String orgCode);
List<Map<String, Object>> newRegEquCountByMonth(@Param("cityCode") String cityCode); List<Map<String, Object>> newVehicleEquCountByMonth(@Param("orgCode") String orgCode);
List<Map<String, Object>> newVehicleEquCountByMonth(@Param("cityCode") String cityCode); List<Map<String, Object>> newRegEquCountByPeriod(@Param("orgCode") String orgCode, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
List<Map<String, Object>> newRegEquCountByYear(@Param("cityCode") String cityCode); List<Map<String, Object>> newVehicleEquCountByPeriod(@Param("orgCode") String orgCode, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
List<Map<String, Object>> newRegEquCountByLastYear(@Param("cityCode") String cityCode);
List<Map<String, Object>> newVehicleEquCountByYear(@Param("cityCode") String cityCode); String newVehicleCountByPeriod(@Param("dto") DPFilterParamDto dpFilterParamDto, @Param("startTime") DateTime startTime);
List<Map<String, Object>> newVehicleEquCountByLastYear(@Param("cityCode") String cityCode);
String newVehicleCountByYear(@Param("cityCode") String cityCode);
String newVehicleCountByMonth(@Param("cityCode") String cityCode);
long certificateCountByOrgCode(@Param("orgCode") String orgCode); long certificateCountByOrgCode(@Param("orgCode") String orgCode);
...@@ -104,5 +99,7 @@ public interface JGStatisticsMapper { ...@@ -104,5 +99,7 @@ public interface JGStatisticsMapper {
Page<Map<String, Object>> noticeCountTopPageNew(@Param("page") Page<Map<String, Object>> page, @Param("dpFilterParamForDetailDto") DPFilterParamForDetailDto dpFilterParamForDetailDto); Page<Map<String, Object>> noticeCountTopPageNew(@Param("page") Page<Map<String, Object>> page, @Param("dpFilterParamForDetailDto") DPFilterParamForDetailDto dpFilterParamForDetailDto);
List<String> getOrgCodeListByRegionCode(@Param("regionCode") String regionCode);
List<Map<String, Object>> noticeCountTopPageByUseUnitCode(@Param("unitCodeList") List<String> unitCodeList, @Param("dto") DPFilterParamForDetailDto dto); List<Map<String, Object>> noticeCountTopPageByUseUnitCode(@Param("unitCodeList") List<String> unitCodeList, @Param("dto") DPFilterParamForDetailDto dto);
} }
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
FROM privilege_company FROM privilege_company
WHERE region_seq = #{regionSeq} WHERE region_seq = #{regionSeq}
and (level != 'company' and level != 'organization') and (level != 'company' and level != 'organization')
and company_code is not null
UNION ALL UNION ALL
SELECT SELECT
c.sequence_nbr, c.sequence_nbr,
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
INNER JOIN company_tree ct ON c.parent_id = ct.sequence_nbr INNER JOIN company_tree ct ON c.parent_id = ct.sequence_nbr
WHERE NOT (c.sequence_nbr = ANY(ct.path)) WHERE NOT (c.sequence_nbr = ANY(ct.path))
and (c.level != 'company' and c.level != 'organization') and (c.level != 'company' and c.level != 'organization')
and c.company_code is not null
) )
SELECT SELECT
company_code companyCode company_code companyCode
......
...@@ -174,6 +174,9 @@ public class StCommonServiceImpl { ...@@ -174,6 +174,9 @@ public class StCommonServiceImpl {
} }
public List<String> getCompanyCodesByRegionCode(String cityCode) { public List<String> getCompanyCodesByRegionCode(String cityCode) {
if ("610000".equals(cityCode)) {
return null;
}
RegionModel region = regionCodeRegionMap.get(Integer.valueOf(cityCode)); RegionModel region = regionCodeRegionMap.get(Integer.valueOf(cityCode));
return regionCodeCompanyCodeMap.computeIfAbsent(Integer.valueOf(cityCode), k -> commonMapper.selectCompanyCodeByRegionCode(region.getSequenceNbr())); return regionCodeCompanyCodeMap.computeIfAbsent(Integer.valueOf(cityCode), k -> commonMapper.selectCompanyCodeByRegionCode(region.getSequenceNbr()));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment