Bläddra i källkod

feat: 低效增加受灾工作日扣减

weijianghai 5 månader sedan
förälder
incheckning
5646b4e71d
1 ändrade filer med 23 tillägg och 4 borttagningar
  1. 23 4
      src/main/java/com/nokia/finance/tasks/dao/car/CarProcedureDao.java

+ 23 - 4
src/main/java/com/nokia/finance/tasks/dao/car/CarProcedureDao.java

@@ -334,7 +334,7 @@ where year_month = #{endYearMonth}
 update
     car.car_li_cheng_month a
 set
-    workday = b.workday
+    workday = b.workday - coalesce((select c.workday from car.car_stop_workday c where a.year_month = c.year_month and a.che_pai_hao = c.che_pai_hao), 0)
 from
     car.workdays b
 where
@@ -479,9 +479,9 @@ select
     select
         sum(workday)
     from
-        t101 b
+        t101
     where
-        b.year_month >= (
+        year_month >= (
             case
                 when a.car_move_yj_date is not null then to_char((a.car_move_yj_date + interval '3 month')::date,
             'YYYYMM')::int4
@@ -489,7 +489,26 @@ select
             'YYYYMM')::int4
             else #{startYearMonth}
         end
-        )) as workday_sum,
+        )) - coalesce((
+    select
+        sum(workday)
+    from
+        car.car_stop_workday
+    where
+        year_month >= (
+            case
+                when a.car_move_yj_date is not null then to_char((a.car_move_yj_date + interval '3 month')::date,
+            'YYYYMM')::int4
+            when a.car_new_date is not null then to_char((a.car_new_date + interval '3 month')::date,
+            'YYYYMM')::int4
+            else #{startYearMonth}
+        end
+        )
+            and year_month >= #{startYearMonth}
+            and year_month <= #{endYearMonth}
+            and che_pai_hao = a.che_pai_hao
+        ),
+    0) as workday_sum,
     *
 from
     t103 a