123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- package com.nokia.financeapi.dao.car;
- import com.nokia.financeapi.pojo.dto.GetCarMapStatDto;
- import com.nokia.financeapi.pojo.dto.GetCarNoticeDto;
- import com.nokia.financeapi.pojo.dto.GetCarTypeStatDto;
- import com.nokia.financeapi.pojo.dto.GetDriveStatDto;
- import com.nokia.financeapi.pojo.vo.GetCarMapStatVo;
- import com.nokia.financeapi.pojo.vo.GetCarNoticeVo;
- import com.nokia.financeapi.pojo.vo.GetCarTypeStatVo;
- import com.nokia.financeapi.pojo.vo.GetDriveStatVo;
- import org.apache.ibatis.annotations.Mapper;
- import org.apache.ibatis.annotations.Param;
- import org.apache.ibatis.annotations.Select;
- import java.util.List;
- @Mapper
- public interface CarResourceMapMapper {
- /**
- * 获取公告
- */
- @Select("""
- select * from car.notices
- where city = #{dto.city}
- order by create_time desc
- """)
- List<GetCarNoticeVo> getNotice(@Param("dto") GetCarNoticeDto dto);
- /**
- * 获取全省或某个地市的车辆类型统计
- */
- @Select("""
- <script>
- select
- count(che_liang_lei_xing = '皮卡车' or null) as pkc,
- count(che_liang_lei_xing = '微型面包车' or null) as wxmbc,
- count(che_liang_lei_xing = '越野车' or null) as yyc,
- count(che_liang_lei_xing = '轿车' or null) as jc,
- count(che_liang_lei_xing not in ('皮卡车', '微型面包车', '越野车', '轿车') or null) as qtc
- from
- car.car_base_data_month
- where
- nian_yue = (
- select
- max(nian_yue)
- from
- car.car_base_data_month)
- <if test="dto.city != null and dto.city != ''">
- and city = #{dto.city}
- </if>
- </script>
- """)
- GetCarTypeStatVo getCarTypeStat(@Param("dto") GetCarTypeStatDto dto);
- /**
- * 获取各个地市的车辆数量和低效数量统计
- */
- @Select("""
- with
- t101 as (
- select
- city,
- count(1) as total
- from
- car.car_base_data_month
- where
- nian_yue = (
- select
- max(nian_yue)
- from
- car.car_base_data_month)
- and city is not null
- and city != ''
- group by
- city
- ),
- t102 as (
- select
- city,
- count(1) as inefficiency_count
- from
- car.car_di_xiao_month
- where
- nian_yue = (
- select
- max(nian_yue)
- from
- car.car_di_xiao_month)
- and city is not null
- and city != ''
- group by
- city
- ),
- t103 as (
- select
- t101.*,
- t102.inefficiency_count
- from t101 left join t102 on t101.city = t102.city
- ),
- t104 as (
- select
- city as area_name,
- total,
- coalesce(inefficiency_count, 0) as inefficiency_count
- from t103
- )
- select * from t104 order by area_name
- """)
- List<GetCarMapStatVo> getCityCarMapStat();
- /**
- * 获取某个地市各区县的车辆数量和低效数量统计
- */
- @Select("""
- with
- t101 as (
- select
- district,
- count(1) as total
- from
- car.car_base_data_month
- where
- nian_yue = (
- select
- max(nian_yue)
- from
- car.car_base_data_month)
- and district is not null
- and district != ''
- and city = #{dto.city}
- group by
- district
- ),
- t102 as (
- select
- district,
- count(1) as inefficiency_count
- from
- car.car_di_xiao_month
- where
- nian_yue = (
- select
- max(nian_yue)
- from
- car.car_di_xiao_month)
- and district is not null
- and district != ''
- and city = #{dto.city}
- group by
- district
- ),
- t103 as (
- select
- t101.*,
- t102.inefficiency_count
- from t101 left join t102 on t101.district = t102.district
- ),
- t104 as (
- select
- district as area_name,
- total,
- coalesce(inefficiency_count, 0) as inefficiency_count
- from t103
- )
- select * from t104 order by area_name
- """)
- List<GetCarMapStatVo> getDistrictCarMapStat(@Param("dto") GetCarMapStatDto dto);
- /**
- * 获取各个地市的行驶统计
- */
- @Select("""
- with
- t101 as (
- select
- city,
- avg(zong_li_cheng) as mileage,
- avg(chu_qin_lv) as attendanceRate
- from
- car.car_li_cheng_month
- where
- year_no = (
- select
- max(year_no)
- from
- car.car_li_cheng_month)
- and city is not null
- and city != ''
- group by
- city
- ),
- t102 as (
- select
- t101.*,
- car.car_second_unit_sort.sort
- from
- t101
- left join car.car_second_unit_sort on
- t101.city = car.car_second_unit_sort.second_unit
- ),
- t103 as (
- select
- city as area_name,
- round(mileage,
- 2) as mileage,
- round(attendanceRate * 100,
- 2) as attendanceRate,
- sort
- from
- t102
- order by
- sort desc
- )
- select
- *
- from
- t103
- """)
- List<GetDriveStatVo> getCityDriveStat();
- /**
- * 获取某个地市各个区县的行驶统计
- */
- @Select("""
- with
- t101 as (
- select
- district,
- avg(zong_li_cheng) as mileage,
- avg(chu_qin_lv) as attendanceRate
- from
- car.car_li_cheng_month
- where
- year_no = (
- select
- max(year_no)
- from
- car.car_li_cheng_month)
- and district is not null
- and district != ''
- and city = #{dto.city}
- group by
- district
- ),
- t102 as (
- select
- district as area_name,
- round(mileage,
- 2) as mileage,
- round(attendanceRate * 100,
- 2) as attendanceRate
- from
- t101
- order by
- district
- )
- select
- *
- from
- t102
- """)
- List<GetDriveStatVo> getDistrictDriveStat(GetDriveStatDto dto);
- }
|