Pārlūkot izejas kodu

feat: 车辆资源地图调整group by为单位字段

weijianghai 1 gadu atpakaļ
vecāks
revīzija
75134519ba

+ 30 - 27
src/main/java/com/nokia/financeapi/dao/car/CarResourceMapMapper.java

@@ -48,7 +48,7 @@ where
     from
         car.car_base_data_month)
     <if test="dto.city != null and dto.city != ''">
-      and city = #{dto.city}
+      and di_shi = #{dto.city}
     </if>
 </script>
 """)
@@ -175,7 +175,7 @@ select * from t104 order by area_name
 with
 t101 as (
 select
-    city,
+    di_shi,
     avg(zong_li_cheng) as mileage,
     avg(chu_qin_lv) as attendanceRate
 from
@@ -186,10 +186,12 @@ where
         max(year_no)
     from
         car.car_li_cheng_month)
-    and city is not null
-    and city != ''
+    and di_shi is not null
+    and di_shi != ''
+    and di_shi != '省公司本部'
+    and position('建设部' in che_liang_suo_shu_dan_wei) = 0
 group by
-    city
+    di_shi
 ),
 t102 as (
 select
@@ -198,11 +200,11 @@ select
 from
     t101
 left join car.car_second_unit_sort on
-    t101.city = car.car_second_unit_sort.second_unit
+    t101.di_shi = car.car_second_unit_sort.second_unit
 ),
 t103 as (
 select
-    city as area_name,
+    di_shi as area_name,
     round(mileage,
     2) as mileage,
     round(attendanceRate * 100,
@@ -227,7 +229,7 @@ from
 with
 t101 as (
 select
-    district,
+    er_ji_dan_wei,
     avg(zong_li_cheng) as mileage,
     avg(chu_qin_lv) as attendanceRate
 from
@@ -238,15 +240,15 @@ where
         max(year_no)
     from
         car.car_li_cheng_month)
-    and district is not null
-    and district != ''
-    and city = #{dto.city}
+    and er_ji_dan_wei is not null
+    and er_ji_dan_wei != ''
+    and di_shi = #{dto.city}
 group by
-    district
+    er_ji_dan_wei
 ),
 t102 as (
 select
-    district as area_name,
+    er_ji_dan_wei as area_name,
     round(mileage,
     2) as mileage,
     round(attendanceRate * 100,
@@ -254,7 +256,7 @@ select
 from
     t101
 order by
-    district
+    er_ji_dan_wei
 )
 select
     *
@@ -270,7 +272,7 @@ from
 with
 t101 as (
 select
-    city,
+    di_shi,
     sum(zong_fei_yong) as cost_sum,
     avg(zong_fei_yong) as cost_avg
 from
@@ -281,11 +283,12 @@ where
         max(year_no)
     from
         car.car_fei_yong_month)
-    and city is not null
-    and city != ''
+    and di_shi is not null
+    and di_shi != ''
+    and position('建设部' in che_liang_suo_shu_dan_wei) = 0
     and rui_xing = 1
 group by
-    city
+    di_shi
 ),
 t102 as (
 select
@@ -294,11 +297,11 @@ select
 from
     t101
 left join car.car_second_unit_sort on
-    t101.city = car.car_second_unit_sort.second_unit
+    t101.di_shi = car.car_second_unit_sort.second_unit
 ),
 t103 as (
 select
-    city as area_name,
+    di_shi as area_name,
     round(cost_sum,
     2) as cost_sum,
     round(cost_avg,
@@ -323,7 +326,7 @@ from
 with
 t101 as (
 select
-    district,
+    er_ji_dan_wei,
     sum(zong_fei_yong) as cost_sum,
     avg(zong_fei_yong) as cost_avg
 from
@@ -334,16 +337,16 @@ where
         max(year_no)
     from
         car.car_fei_yong_month)
-    and district is not null
-    and district != ''
+    and er_ji_dan_wei is not null
+    and er_ji_dan_wei != ''
     and rui_xing = 1
-    and city = #{dto.city}
+    and di_shi = #{dto.city}
 group by
-    district
+    er_ji_dan_wei
 ),
 t102 as (
 select
-    district as area_name,
+    er_ji_dan_wei as area_name,
     round(cost_sum,
     2) as cost_sum,
     round(cost_avg,
@@ -351,7 +354,7 @@ select
 from
     t101
 order by
-    district
+    er_ji_dan_wei
 )
 select
     *