|
@@ -183,7 +183,7 @@ set
|
|
|
a.last_month = b.year_month
|
|
|
and a.che_pai_hao = b.che_pai_hao
|
|
|
)
|
|
|
- else to_date(year_month::varchar, 'YYYYMM')
|
|
|
+ else (select min(data_date) from car.car_base_data_day b where a.year_month = b.year_month and a.che_pai_hao = b.che_pai_hao and b.year_month = #{endYearMonth})
|
|
|
end,
|
|
|
car_move = case
|
|
|
when (
|
|
@@ -250,7 +250,7 @@ set
|
|
|
a.last_month = b.year_month
|
|
|
and a.che_pai_hao = b.che_pai_hao
|
|
|
and a.first_unit != b.first_unit
|
|
|
- )) then to_date(year_month::varchar, 'YYYYMM')
|
|
|
+ )) then (select min(data_date) from car.car_base_data_day b where a.year_month = b.year_month and a.che_pai_hao = b.che_pai_hao and a.first_unit = b.first_unit and b.year_month = #{endYearMonth})
|
|
|
else (
|
|
|
select
|
|
|
car_move_yj_date
|
|
@@ -326,6 +326,24 @@ where year_month = #{endYearMonth}
|
|
|
""")
|
|
|
int updateCarBaseDataMonthChange(@Param("endYearMonth") Integer endYearMonth);
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新车辆报废是否有效
|
|
|
+ * @param endYearMonth 账期
|
|
|
+ */
|
|
|
+ @Update("""
|
|
|
+update
|
|
|
+ car.car_bao_fei a
|
|
|
+set
|
|
|
+ valid = 0
|
|
|
+from
|
|
|
+ car.car_bao_fei_invalid b
|
|
|
+where
|
|
|
+ a.che_pai_hao = b.che_pai_hao
|
|
|
+ and a.bao_fei_ri_qi = b.bao_fei_ri_qi
|
|
|
+ and a.month_id = #{endYearMonth}
|
|
|
+""")
|
|
|
+ int updateCarBaoFeiValid(@Param("endYearMonth") Integer endYearMonth);
|
|
|
+
|
|
|
/**
|
|
|
* 更新车辆行驶里程月数据工作日
|
|
|
* @param endYearMonth 账期
|
|
@@ -351,8 +369,8 @@ where
|
|
|
update
|
|
|
car.car_li_cheng_month
|
|
|
set
|
|
|
- ri_jun_li_cheng = zong_li_cheng / workday,
|
|
|
- chu_qin_lv = xing_shi_tian_shu / workday::numeric
|
|
|
+ ri_jun_li_cheng = case when workday > 0 then zong_li_cheng / workday end,
|
|
|
+ chu_qin_lv = case when workday > 0 then xing_shi_tian_shu / workday::numeric end
|
|
|
where
|
|
|
year_month = #{endYearMonth}
|
|
|
""")
|
|
@@ -367,18 +385,20 @@ update
|
|
|
car.car_li_cheng_month a
|
|
|
set
|
|
|
di_xiao = case
|
|
|
+ when (select exists(select 1 from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.month_id = #{endYearMonth} and b.valid = 1)) then 0
|
|
|
+ when (select not exists(select 1 from car.car_base_data_month b where b.che_pai_hao = a.che_pai_hao and b.year_month = a.year_month)) then 0
|
|
|
+ when bao_fei = 1 then 0
|
|
|
when first_unit = '省公司本部' then 0
|
|
|
when position('建设部' in che_liang_suo_shu_dan_wei) > 0 then 0
|
|
|
when che_liang_lei_xing in ('特种车', '中型面包车(8-20座的面包车)', '大巴车') then 0
|
|
|
when che_liang_shi_yong_xing_zhi in ('特种车', '负责人用车') then 0
|
|
|
when (select exists(select 1 from car_theme.wz_f_spc_car b where a.che_pai_hao = b.card_num and b.is_spec = '1')) then 0
|
|
|
- when (select exists(select 1 from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.year_month <= #{endYearMonth} and b.valid = 1)) then 0
|
|
|
- when bao_fei = 1 then 0
|
|
|
when chu_qin_lv < 0.5 and ri_jun_li_cheng < 20 then 1
|
|
|
else 0
|
|
|
end,
|
|
|
di_xiao_exclude_reason = case
|
|
|
- when (select exists(select 1 from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.year_month <= #{endYearMonth} and b.valid = 1)) then (select max(b.year_month) from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.year_month <= #{endYearMonth}) || '报废'
|
|
|
+ when (select exists(select 1 from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.month_id = #{endYearMonth} and b.valid = 1)) then (select max(b.year_month) from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.month_id = #{endYearMonth}) || '报废'
|
|
|
+ when (select not exists(select 1 from car.car_base_data_month b where b.che_pai_hao = a.che_pai_hao and b.year_month = a.year_month)) then '车辆基本信息已删除'
|
|
|
when first_unit = '省公司本部' then '省公司本部'
|
|
|
when position('建设部' in che_liang_suo_shu_dan_wei) > 0 then '建设部'
|
|
|
when che_liang_lei_xing = '特种车' then '特种车'
|
|
@@ -545,7 +565,7 @@ t107 as (
|
|
|
t111 as (
|
|
|
select
|
|
|
case
|
|
|
- when (select exists(select 1 from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.year_month <= a.stat_year_month)) then 0
|
|
|
+ when (select exists(select 1 from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.month_id = a.stat_year_month and b.valid = 1)) then 0
|
|
|
when (select not exists(select 1 from car.car_base_data_month b where b.che_pai_hao = a.che_pai_hao and b.year_month = a.stat_year_month)) then 0
|
|
|
when first_unit = '省公司本部' then 0
|
|
|
when position('建设部' in che_liang_suo_shu_dan_wei) > 0 then 0
|
|
@@ -558,7 +578,7 @@ select
|
|
|
else 0
|
|
|
end as di_xiao_sum,
|
|
|
case
|
|
|
- when (select exists(select 1 from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.year_month <= a.stat_year_month and b.valid = 1)) then (select max(b.year_month) from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.year_month <= a.stat_year_month) || '报废'
|
|
|
+ when (select exists(select 1 from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.month_id = a.stat_year_month and b.valid = 1)) then (select max(b.year_month) from car.car_bao_fei b where b.che_pai_hao = a.che_pai_hao and b.month_id = a.stat_year_month) || '报废'
|
|
|
when (select not exists(select 1 from car.car_base_data_month b where b.che_pai_hao = a.che_pai_hao and b.year_month = a.stat_year_month)) then '车辆基本信息已删除'
|
|
|
when first_unit = '省公司本部' then '省公司本部'
|
|
|
when position('建设部' in che_liang_suo_shu_dan_wei) > 0 then '建设部'
|
|
@@ -2045,7 +2065,7 @@ where
|
|
|
car.car_bao_fei b
|
|
|
where
|
|
|
b.che_pai_hao = a.che_pai_hao
|
|
|
- and b.year_month <= a.year_month and b.valid = 1)
|
|
|
+ and b.month_id = a.year_month and b.valid = 1)
|
|
|
and year_month = #{endYearMonth}
|
|
|
),
|
|
|
t102 as (
|
|
@@ -2237,7 +2257,7 @@ where
|
|
|
car.car_bao_fei b
|
|
|
where
|
|
|
b.che_pai_hao = a.che_pai_hao
|
|
|
- and b.year_month <= a.year_month and b.valid = 1)
|
|
|
+ and b.month_id = a.year_month and b.valid = 1)
|
|
|
and year_month = #{endYearMonth}
|
|
|
),
|
|
|
t102 as (
|
|
@@ -2385,7 +2405,7 @@ where
|
|
|
car.car_bao_fei b
|
|
|
where
|
|
|
b.che_pai_hao = a.che_pai_hao
|
|
|
- and b.year_month <= a.year_month and b.valid = 1)
|
|
|
+ and b.month_id = a.year_month and b.valid = 1)
|
|
|
and year_month = #{endYearMonth}
|
|
|
),
|
|
|
t102 as (
|