CarResourceMapMapper.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. package com.nokia.financeapi.dao.car;
  2. import com.nokia.financeapi.pojo.dto.GetCarMapStatDto;
  3. import com.nokia.financeapi.pojo.dto.GetCarNoticeDto;
  4. import com.nokia.financeapi.pojo.dto.GetCarTypeStatDto;
  5. import com.nokia.financeapi.pojo.dto.GetDriveStatDto;
  6. import com.nokia.financeapi.pojo.vo.GetCarMapStatVo;
  7. import com.nokia.financeapi.pojo.vo.GetCarNoticeVo;
  8. import com.nokia.financeapi.pojo.vo.GetCarTypeStatVo;
  9. import com.nokia.financeapi.pojo.vo.GetDriveStatVo;
  10. import org.apache.ibatis.annotations.Mapper;
  11. import org.apache.ibatis.annotations.Param;
  12. import org.apache.ibatis.annotations.Select;
  13. import java.util.List;
  14. @Mapper
  15. public interface CarResourceMapMapper {
  16. /**
  17. * 获取公告
  18. */
  19. @Select("""
  20. select * from car.notices
  21. where city = #{dto.city}
  22. order by create_time desc
  23. """)
  24. List<GetCarNoticeVo> getNotice(@Param("dto") GetCarNoticeDto dto);
  25. /**
  26. * 获取全省或某个地市的车辆类型统计
  27. */
  28. @Select("""
  29. <script>
  30. select
  31. count(che_liang_lei_xing = '皮卡车' or null) as pkc,
  32. count(che_liang_lei_xing = '微型面包车' or null) as wxmbc,
  33. count(che_liang_lei_xing = '越野车' or null) as yyc,
  34. count(che_liang_lei_xing = '轿车' or null) as jc,
  35. count(che_liang_lei_xing not in ('皮卡车', '微型面包车', '越野车', '轿车') or null) as qtc
  36. from
  37. car.car_base_data_month
  38. where
  39. nian_yue = (
  40. select
  41. max(nian_yue)
  42. from
  43. car.car_base_data_month)
  44. <if test="dto.city != null and dto.city != ''">
  45. and city = #{dto.city}
  46. </if>
  47. </script>
  48. """)
  49. GetCarTypeStatVo getCarTypeStat(@Param("dto") GetCarTypeStatDto dto);
  50. /**
  51. * 获取各个地市的车辆数量和低效数量统计
  52. */
  53. @Select("""
  54. with
  55. t101 as (
  56. select
  57. city,
  58. count(1) as total
  59. from
  60. car.car_base_data_month
  61. where
  62. nian_yue = (
  63. select
  64. max(nian_yue)
  65. from
  66. car.car_base_data_month)
  67. and city is not null
  68. and city != ''
  69. group by
  70. city
  71. ),
  72. t102 as (
  73. select
  74. city,
  75. count(1) as inefficiency_count
  76. from
  77. car.car_di_xiao_month
  78. where
  79. nian_yue = (
  80. select
  81. max(nian_yue)
  82. from
  83. car.car_di_xiao_month)
  84. and city is not null
  85. and city != ''
  86. group by
  87. city
  88. ),
  89. t103 as (
  90. select
  91. t101.*,
  92. t102.inefficiency_count
  93. from t101 left join t102 on t101.city = t102.city
  94. ),
  95. t104 as (
  96. select
  97. city as area_name,
  98. total,
  99. coalesce(inefficiency_count, 0) as inefficiency_count
  100. from t103
  101. )
  102. select * from t104 order by area_name
  103. """)
  104. List<GetCarMapStatVo> getCityCarMapStat();
  105. /**
  106. * 获取某个地市各区县的车辆数量和低效数量统计
  107. */
  108. @Select("""
  109. with
  110. t101 as (
  111. select
  112. district,
  113. count(1) as total
  114. from
  115. car.car_base_data_month
  116. where
  117. nian_yue = (
  118. select
  119. max(nian_yue)
  120. from
  121. car.car_base_data_month)
  122. and district is not null
  123. and district != ''
  124. and city = #{dto.city}
  125. group by
  126. district
  127. ),
  128. t102 as (
  129. select
  130. district,
  131. count(1) as inefficiency_count
  132. from
  133. car.car_di_xiao_month
  134. where
  135. nian_yue = (
  136. select
  137. max(nian_yue)
  138. from
  139. car.car_di_xiao_month)
  140. and district is not null
  141. and district != ''
  142. and city = #{dto.city}
  143. group by
  144. district
  145. ),
  146. t103 as (
  147. select
  148. t101.*,
  149. t102.inefficiency_count
  150. from t101 left join t102 on t101.district = t102.district
  151. ),
  152. t104 as (
  153. select
  154. district as area_name,
  155. total,
  156. coalesce(inefficiency_count, 0) as inefficiency_count
  157. from t103
  158. )
  159. select * from t104 order by area_name
  160. """)
  161. List<GetCarMapStatVo> getDistrictCarMapStat(@Param("dto") GetCarMapStatDto dto);
  162. /**
  163. * 获取各个地市的行驶统计
  164. */
  165. @Select("""
  166. with
  167. t101 as (
  168. select
  169. city,
  170. avg(zong_li_cheng) as mileage,
  171. avg(chu_qin_lv) as attendanceRate
  172. from
  173. car.car_li_cheng_month
  174. where
  175. year_no = (
  176. select
  177. max(year_no)
  178. from
  179. car.car_li_cheng_month)
  180. and city is not null
  181. and city != ''
  182. group by
  183. city
  184. ),
  185. t102 as (
  186. select
  187. t101.*,
  188. car.car_second_unit_sort.sort
  189. from
  190. t101
  191. left join car.car_second_unit_sort on
  192. t101.city = car.car_second_unit_sort.second_unit
  193. ),
  194. t103 as (
  195. select
  196. city as area_name,
  197. round(mileage,
  198. 2) as mileage,
  199. round(attendanceRate * 100,
  200. 2) as attendanceRate,
  201. sort
  202. from
  203. t102
  204. order by
  205. sort desc
  206. )
  207. select
  208. *
  209. from
  210. t103
  211. """)
  212. List<GetDriveStatVo> getCityDriveStat();
  213. /**
  214. * 获取某个地市各个区县的行驶统计
  215. */
  216. @Select("""
  217. with
  218. t101 as (
  219. select
  220. district,
  221. avg(zong_li_cheng) as mileage,
  222. avg(chu_qin_lv) as attendanceRate
  223. from
  224. car.car_li_cheng_month
  225. where
  226. year_no = (
  227. select
  228. max(year_no)
  229. from
  230. car.car_li_cheng_month)
  231. and district is not null
  232. and district != ''
  233. and city = #{dto.city}
  234. group by
  235. district
  236. ),
  237. t102 as (
  238. select
  239. district as area_name,
  240. round(mileage,
  241. 2) as mileage,
  242. round(attendanceRate * 100,
  243. 2) as attendanceRate
  244. from
  245. t101
  246. order by
  247. district
  248. )
  249. select
  250. *
  251. from
  252. t102
  253. """)
  254. List<GetDriveStatVo> getDistrictDriveStat(GetDriveStatDto dto);
  255. }