2 Incheckningar 1b8cb8647c ... 4fb766149f

Upphovsman SHA1 Meddelande Datum
  weijianghai 4fb766149f 睿行数据迁移能力商店 2 månader sedan
  weijianghai 1b8cb8647c 睿行数据迁移能力商店 2 månader sedan

+ 6 - 0
pom.xml

@@ -130,6 +130,12 @@
             <artifactId>netty-all</artifactId>
             <version>4.2.0.Final</version>
         </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <version>1.8.2</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <dependencyManagement>

+ 61 - 2
src/main/java/com/nokia/finance/tasks/dao/car/CarProcedureDao.java

@@ -545,8 +545,8 @@ t107 as (
 t111 as (
 select
     case
-        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 (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 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
         when che_liang_lei_xing in ('特种车', '中型面包车(8-20座的面包车)', '大巴车') then 0
@@ -558,8 +558,8 @@ select
         else 0
     end as di_xiao_sum,
     case
-        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 (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 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 '建设部'
         when che_liang_lei_xing = '特种车' then '特种车'
@@ -1927,6 +1927,65 @@ where year_month = #{endYearMonth}
 """)
     int updateCarFeiYongMonthBaseInfo(@Param("endYearMonth") Integer endYearMonth);
 
+    /**
+     * 插入车辆费用不存在的基本信息
+     * @param endYearMonth 账期
+     */
+    @Update("""
+insert into car.car_fei_yong_month
+(
+year_month,
+che_pai_hao,
+che_liang_lai_yuan,
+che_liang_lei_xing,
+che_liang_shi_yong_xing_zhi,
+che_liang_suo_shu_dan_wei,
+first_unit,
+second_unit,
+third_unit,
+area_no,
+area_name,
+city_no,
+city_name,
+area_name2,
+area_no2,
+city_id,
+city,
+district_id,
+district,
+year_no,
+month_no,
+rui_xing,
+rui_xing_month
+)
+select
+year_month,
+che_pai_hao,
+che_liang_lai_yuan,
+che_liang_lei_xing,
+che_liang_shi_yong_xing_zhi,
+che_liang_suo_shu_dan_wei,
+first_unit,
+second_unit,
+third_unit,
+area_no,
+area_name,
+city_no,
+city_name,
+area_name2,
+area_no2,
+city_id,
+city,
+district_id,
+district,
+year_no,
+month_no,
+1 as rui_xing,
+1 as rui_xing_month
+from car.car_base_data_month a where year_month = #{endYearMonth} and not exists (select 1 from car.car_fei_yong_month b where a.year_month = b.year_month and a.che_pai_hao = b.che_pai_hao)
+""")
+    int insertCarFeiYongMonthBaseInfo(@Param("endYearMonth") Integer endYearMonth);
+
     /**
      * 判断是否有车辆基本信息、用车数据
      * @param endYearMonth 账期

+ 1 - 0
src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarFeeProcJob.java

@@ -75,6 +75,7 @@ public class CarFeeProcJob {
             carProcedureDao.updateCarZuLin(endYearMonth);
             int update1 = carProcedureDao.updateCarFeiYongMonthYunXingFeiZongFeiYong(endYearMonth);
             int update2 = carProcedureDao.updateCarFeiYongMonthBaseInfo(endYearMonth);
+            carProcedureDao.insertCarFeiYongMonthBaseInfo(endYearMonth);
             carProcedureDao.insertCarRanYouYiChang(startYearMonth, endYearMonth);
             carProcedureDao.insertCarZiYouWeiXiuYiChang(startYearMonth, endYearMonth);
             carProcedureDao.insertCarZuLinWeiXiuYiChang(startYearMonth, endYearMonth);