Răsfoiți Sursa

feat: 资源地图接口添加账期

weijianghai 11 luni în urmă
părinte
comite
65db882217
21 a modificat fișierele cu 556 adăugiri și 215 ștergeri
  1. 20 7
      scripts/8000.conf
  2. 14 0
      scripts/backup-financialdb.sh
  3. 10 0
      scripts/restore-financialdb.sh
  4. 139 0
      scripts/test.conf
  5. 5 0
      src/main/java/com/nokia/financeapi/common/exception/MyRuntimeException.java
  6. 17 50
      src/main/java/com/nokia/financeapi/dao/car/CarResourceMapDao.java
  7. 252 134
      src/main/java/com/nokia/financeapi/dao/house/HouseResourceMapMapper.java
  8. 5 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetBuildingAreaStatDto.java
  9. 3 1
      src/main/java/com/nokia/financeapi/pojo/dto/GetBuildingMapDto.java
  10. 4 1
      src/main/java/com/nokia/financeapi/pojo/dto/GetBuildingOptionsDto.java
  11. 11 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetBuildingRepairStatDto.java
  12. 11 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetCarCostStatDto.java
  13. 5 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetCarMapStatDto.java
  14. 5 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetCarNoticeDto.java
  15. 5 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetCarTypeStatDto.java
  16. 11 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetDriveStatDto.java
  17. 5 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetHouseNoticeDto.java
  18. 5 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetLandBuildingStatDto.java
  19. 5 0
      src/main/java/com/nokia/financeapi/pojo/dto/GetRentOutStatDto.java
  20. 15 3
      src/main/java/com/nokia/financeapi/service/car/CarResourceMapService.java
  21. 9 19
      src/main/java/com/nokia/financeapi/service/house/HouseResourceMapService.java

+ 20 - 7
scripts/8000.conf

@@ -38,7 +38,7 @@ server {
 
     # 不动产资源地图接口
     location /house-car/house/resource-map/api {
-        proxy_pass http://172.16.107.4:39201;
+        proxy_pass http://172.16.107.4:39100;
     }
 
     # 不动产资源地图页面
@@ -49,7 +49,7 @@ server {
 
     # 不动产报告页面接口
     location /house-car/house/report/api {
-        proxy_pass http://172.16.107.4:39202;
+        proxy_pass http://172.16.107.4:39100;
     }
 
     # 不动产报告页面
@@ -60,7 +60,7 @@ server {
 
     # 车辆报告页面接口
     location /house-car/car/report/api {
-        proxy_pass http://172.16.107.4:39203;
+        proxy_pass http://172.16.107.4:39100;
     }
 
     # 车辆报告报告页面
@@ -71,7 +71,7 @@ server {
 
     # 车辆资源地图接口
     location /house-car/car/resource-map/api {
-        proxy_pass http://172.16.107.4:39204;
+        proxy_pass http://172.16.107.4:39100;
     }
 
     # 车辆资源地图页面
@@ -82,7 +82,7 @@ server {
 
     # 不动产数据稽查页面接口
     location /house-car/house/DATA-CHECK/api {
-        proxy_pass http://172.16.107.4:39205;
+        proxy_pass http://172.16.107.4:39100;
     }
 
     # 不动产数据稽查页面
@@ -93,7 +93,7 @@ server {
 
     # 不动产数据稽查页面接口
     location /house-car/house/data-check/api {
-        proxy_pass http://172.16.107.4:39205;
+        proxy_pass http://172.16.107.4:39100;
     }
 
     # 不动产数据稽查页面
@@ -146,8 +146,21 @@ server {
         proxy_pass https://127.0.0.1:8080/assets/;
      }
 
+     location /assets/ {
+        proxy_redirect off;
+        proxy_set_header Host $host:$server_port;
+        proxy_set_header X-Real-IP  $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_pass https://127.0.0.1:8080/assets/;
+     }
 
-
+     location /assets/ {
+        proxy_redirect off;
+        proxy_set_header Host $host:$server_port;
+        proxy_set_header X-Real-IP  $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_pass https://127.0.0.1:8080/assets/;
+     }
 
     #error_page  404              /404.html;
 

+ 14 - 0
scripts/backup-financialdb.sh

@@ -0,0 +1,14 @@
+#!/bin/sh
+
+echo "$(date) backup financialdb start"
+export PGPASSWORD='Finance@unicom23'
+backup_dir=/backup/postgres/financialdb/$(date +%Y%m)/$(date +%Y%m%d)/$(date +%Y%m%d%H%M%S)
+mkdir -p "${backup_dir}"
+host='127.0.0.1'
+port='5432'
+username='finance'
+dbname='financialdb'
+jobs='16'
+echo "pg_dump -h ${host} -p ${port} -U ${username} -d ${dbname} -v -O -Fd -j ${jobs} -Z9 -f ${backup_dir}"
+pg_dump -h "${host}" -p "${port}" -U "${username}" -d "${dbname}" -v -O -Fd -j "${jobs}" -Z9 -f "${backup_dir}"
+echo "$(date) backup financialdb end"

+ 10 - 0
scripts/restore-financialdb.sh

@@ -0,0 +1,10 @@
+#!/bin/sh
+
+export PGPASSWORD='NFQCgBA6YhNvgAqG6THw'
+backup_dir='financialdb'
+host='127.0.0.1'
+port='15432'
+username='postgres'
+dbname='financialdb'
+jobs='24'
+pg_restore -O -c -v -h "${host}" -p "${port}" -U "${username}" -d "${dbname}" -Fd -j "${jobs}" "${backup_dir}"

+ 139 - 0
scripts/test.conf

@@ -0,0 +1,139 @@
+server {
+    listen       12099;
+    listen  [::]:12099;
+    server_name localhost;
+
+    server_tokens off;
+    proxy_hide_header X-Powered-By;
+    proxy_hide_header Server;
+
+    # minio
+    location /house-car/oss {
+        proxy_pass http://192.168.10.7:19000;
+    }
+
+    # 百度地图
+    location /dugis-baidu {
+        proxy_pass http://192.168.10.7:19000;
+    }
+
+    # 不动产后端接口
+    location /house-car/house/api {
+        proxy_pass http://192.168.50.3:39100;
+    }
+
+    # 车辆后端接口
+    location /house-car/car/api {
+        proxy_pass http://192.168.50.3:39100;
+    }
+
+    # 不动产资源地图接口
+    location /house-car/house/resource-map/api {
+        proxy_pass http://192.168.50.3:39201;
+    }
+
+    # 不动产资源地图页面
+    location /house-car/house/resource-map {
+        rewrite ^/house-car/house/resource-map/(.*)$ /$1 break;
+        proxy_pass http://192.168.50.3:39201;
+    }
+
+    # 不动产报告页面接口
+    location /house-car/house/report/api {
+        proxy_pass http://192.168.50.3:39202;
+    }
+
+    # 不动产报告页面
+    location /house-car/house/report {
+        rewrite ^/house-car/house/report/(.*)$ /$1 break;
+        proxy_pass http://192.168.50.3:39202;
+    }
+
+    # 车辆报告页面接口
+    location /house-car/car/report/api {
+        proxy_pass http://192.168.50.3:39203;
+    }
+
+    # 车辆报告报告页面
+    location /house-car/car/report {
+        rewrite ^/house-car/car/report/(.*)$ /$1 break;
+        proxy_pass http://192.168.50.3:39203;
+    }
+
+    # 车辆资源地图接口
+    location /house-car/car/resource-map/api {
+        proxy_pass http://192.168.50.3:39204;
+    }
+
+    # 车辆资源地图页面
+    location /house-car/car/resource-map {
+        rewrite ^/house-car/car/resource-map/(.*)$ /$1 break;
+        proxy_pass http://192.168.50.3:39204;
+    }
+
+    # 不动产数据稽查页面接口
+    location /house-car/house/DATA-CHECK/api {
+        proxy_pass http://192.168.50.3:39205;
+    }
+
+    # 不动产数据稽查页面
+    location /house-car/house/DATA-CHECK {
+        rewrite ^/house-car/house/DATA-CHECK/(.*)$ /$1 break;
+        proxy_pass http://192.168.50.3:39205;
+    }
+
+    # 不动产数据稽查页面接口
+    location /house-car/house/data-check/api {
+        proxy_pass http://192.168.50.3:39205;
+    }
+
+    # 不动产数据稽查页面
+    location /house-car/house/data-check {
+        rewrite ^/house-car/house/data-check/(.*)$ /$1 break;
+        proxy_pass http://192.168.50.3:39205;
+    }
+
+    # 不动产gdc接口
+    location /house-car/house/dist/api {
+        proxy_pass http://192.168.50.3:39101;
+    }
+
+    # 不动产gdc页面
+    location /house-car/house/dist {
+        rewrite ^/house-car/house/dist/(.*)$ /$1 break;
+        proxy_pass http://192.168.50.3:39206;
+    }
+
+    #车辆系统
+    location /house-car/car/ {
+        proxy_redirect off;
+        proxy_set_header Host $host:$server_port;
+        proxy_set_header X-Real-IP  $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_pass https://127.0.0.1:8080/;
+     }
+
+     location /house-car/car/assets/ {
+        #    add_header Access-Control-Allow-Origin '*' always;
+        #    add_header Access-Control-Allow-Headers '*';
+        #    add_header Access-Control-Allow-Methods '*';
+        #    add_header Access-Control-Allow-Credentials 'false';
+        #    if ($request_method = 'OPTIONS') {
+        #        return 204;
+        #    }
+        proxy_redirect off;
+        proxy_set_header Host $host:$server_port;
+        proxy_set_header X-Real-IP  $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_pass https://127.0.0.1:8080/assets/;
+     }
+
+    #error_page  404              /404.html;
+
+    # redirect server error pages to the static page /50x.html
+    #
+    error_page   500 502 503 504  /50x.html;
+    location = /50x.html {
+        root   /usr/share/nginx/html;
+    }
+}

+ 5 - 0
src/main/java/com/nokia/financeapi/common/exception/MyRuntimeException.java

@@ -19,4 +19,9 @@ public class MyRuntimeException extends RuntimeException{
     public MyRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
         super(message, cause, enableSuppression, writableStackTrace);
     }
+    
+    @Override
+    public synchronized Throwable fillInStackTrace() {
+        return this;
+    }
 }

+ 17 - 50
src/main/java/com/nokia/financeapi/dao/car/CarResourceMapDao.java

@@ -24,7 +24,7 @@ public interface CarResourceMapDao {
     @Select("""
 select * from car.notices
 where city = #{dto.city}
-order by create_time desc
+and year_month = #{dto.endDate}
 """)
     List<GetCarNoticeVo> getNotice(@Param("dto") GetCarNoticeDto dto);
 
@@ -41,12 +41,7 @@ select
     count(che_liang_lei_xing not in ('皮卡车', '微型面包车', '越野车', '轿车') or null) as qtc
 from
     car.car_base_data_month
-where
-    year_month = (
-    select
-        max(year_month)
-    from
-        car.car_base_data_month)
+where year_month = #{dto.endDate}
     <if test="dto.city != null and dto.city != ''">
       and first_unit = #{dto.city}
     </if>
@@ -66,11 +61,7 @@ select
 from
     car.car_base_data_month
 where
-    year_month = (
-    select
-        max(year_month)
-    from
-        car.car_base_data_month)
+    year_month = #{dto.endDate}
     and city is not null
     and city != ''
 group by
@@ -83,11 +74,7 @@ select
 from
     car.car_di_xiao_month
 where
-    year_month = (
-    select
-        max(year_month)
-    from
-        car.car_di_xiao_month)
+    year_month = #{dto.endDate}
     and city is not null
     and city != ''
 group by
@@ -108,7 +95,7 @@ from t103
 )
 select * from t104 order by area_name
 """)
-    List<GetCarMapStatVo> getCityCarMapStat();
+    List<GetCarMapStatVo> getCityCarMapStat(@Param("dto") GetCarMapStatDto dto);
 
     /**
      * 获取某个地市各区县的车辆数量和低效数量统计
@@ -122,11 +109,7 @@ select
 from
     car.car_base_data_month
 where
-    year_month = (
-    select
-        max(year_month)
-    from
-        car.car_base_data_month)
+    year_month = #{dto.endDate}
     and district is not null
     and district != ''
     and city = #{dto.city}
@@ -140,11 +123,7 @@ select
 from
     car.car_di_xiao_month
 where
-    year_month = (
-    select
-        max(year_month)
-    from
-        car.car_di_xiao_month)
+    year_month = #{dto.endDate}
     and district is not null
     and district != ''
     and city = #{dto.city}
@@ -181,11 +160,8 @@ select
 from
     car.car_li_cheng_month
 where
-    year_no = (
-    select
-        max(year_no)
-    from
-        car.car_li_cheng_month)
+    year_month >= #{dto.startDate}
+    and year_month <= #{dto.endDate}
     and first_unit is not null
     and first_unit != ''
     and first_unit != '省公司本部'
@@ -220,7 +196,7 @@ select
 from
     t103
 """)
-    List<GetDriveStatVo> getCityDriveStat();
+    List<GetDriveStatVo> getCityDriveStat(@Param("dto") GetDriveStatDto dto);
 
     /**
      * 获取某个地市各个区县的行驶统计
@@ -235,11 +211,8 @@ select
 from
     car.car_li_cheng_month
 where
-    year_no = (
-    select
-        max(year_no)
-    from
-        car.car_li_cheng_month)
+    year_month >= #{dto.startDate}
+    and year_month <= #{dto.endDate}
     and second_unit is not null
     and second_unit != ''
     and first_unit = #{dto.city}
@@ -278,11 +251,8 @@ select
 from
     car.car_fei_yong_month
 where
-    year_no = (
-    select
-        max(year_no)
-    from
-        car.car_fei_yong_month)
+    year_month >= #{dto.startDate}
+    and year_month <= #{dto.endDate}
     and first_unit is not null
     and first_unit != ''
     and position('建设部' in che_liang_suo_shu_dan_wei) = 0
@@ -317,7 +287,7 @@ select
 from
     t103
 """)
-    List<GetCarCostStatVo> getCityCostStat();
+    List<GetCarCostStatVo> getCityCostStat(@Param("dto") GetCarCostStatDto dto);
 
     /**
      * 获取某个地市各个区县的费用统计
@@ -332,11 +302,8 @@ select
 from
     car.car_fei_yong_month
 where
-    year_no = (
-    select
-        max(year_no)
-    from
-        car.car_fei_yong_month)
+    year_month >= #{dto.startDate}
+    and year_month <= #{dto.endDate}
     and second_unit is not null
     and second_unit != ''
     and rui_xing = 1

+ 252 - 134
src/main/java/com/nokia/financeapi/dao/house/HouseResourceMapMapper.java

@@ -23,7 +23,7 @@ import java.util.List;
 @Mapper
 public interface HouseResourceMapMapper {
     /**
-     * 获取最新月份全省或地市的建筑面积统计
+     * 获取全省或地市的建筑面积统计
      */
     @Select("""
 <script>
@@ -43,11 +43,7 @@ select
 from
     house.building_month
 where
-    year_month = (
-    select
-        max(year_month)
-    from
-        house.building_month)
+    year_month = #{dto.endDate}
     <if test="dto.city != null and dto.city != ''">
       and city = #{dto.city}
     </if>
@@ -71,7 +67,7 @@ from t1
     GetBuildingAreaStatVo getBuildingAreaStat(@Param("dto") GetBuildingAreaStatDto dto);
 
     /**
-     * 统计最新月份各个地市的建筑和土地数量
+     * 统计各个地市的建筑和土地数量
      */
     @Select("""
 with
@@ -82,11 +78,7 @@ select
 from
     house.building_month
 where
-    year_month = (
-    select
-        max(year_month)
-    from
-        house.building_month)
+    year_month = #{dto.endDate}
     and city is not null
     and city != ''
 group by
@@ -99,11 +91,7 @@ select
 from
     house.land_month
 where
-    year_month = (
-    select
-        max(year_month)
-    from
-        house.land_month)
+    year_month = #{dto.endDate}
     and city is not null
     and city != ''
 group by
@@ -120,10 +108,10 @@ join t2 on
 order by
     t1.area_name
 """)
-    List<GetLandBuildingStatVo> getCityLandBuildingStat();
+    List<GetLandBuildingStatVo> getCityLandBuildingStat(@Param("dto") GetLandBuildingStatDto dto);
 
     /**
-     * 统计最新月份某地市各个区县的建筑和土地数量
+     * 统计某地市各个区县的建筑和土地数量
      */
     @Select("""
 <script>
@@ -138,11 +126,7 @@ where
     city = #{dto.city}
     and district is not null
     and district != ''
-    and year_month = (
-    select
-        max(year_month)
-    from
-        house.building_month)
+    and year_month = #{dto.endDate}
 group by
     district
 ),
@@ -156,11 +140,7 @@ where
     city = #{dto.city}
     and district is not null
     and district != ''
-    and year_month = (
-    select
-        max(year_month)
-    from
-        house.land_month)
+    and year_month = #{dto.endDate}
 group by
     district
 )
@@ -177,14 +157,6 @@ order by t1.area_name
 """)
     List<GetLandBuildingStatVo> getDistrictLandBuildingStat(@Param("dto") GetLandBuildingStatDto dto);
 
-    /**
-     * 获取建筑数据最新的日期
-     */
-    @Select("""
-select max(year_month) from house.building_month
-""")
-    Integer getBuildingMonthMaxDate();
-
     /**
      * 获取区县最大面积建筑
      */
@@ -319,109 +291,190 @@ limit 150
     List<GetBuildingMapVo> getBuildingByCoordinate(@Param("dto") GetBuildingMapDto dto);
 
     /**
-     * 统计最新年份各个地市的维修费
+     * 统计各个地市的维修费
      */
     @Select("""
 with
-t1 as (
+t101 as (
 select
-    area_name,
+    area_no,
     sum(case when repair_type = '零星维修' then final_cost else 0 end) as odd_sum,
     sum(final_cost) as total_sum
 from
     house.building_repair_month
 where
-    area_name is not null
-    and area_name != ''
+    area_no is not null
+    and area_no != ''
     and repair_type != '财务预提冲销'
-    and year_no = (
-    select
-        max(year_no)
-    from
-        house.building_repair_month)
+    and year_month >= #{dto.startDate}
+    and year_month <= #{dto.endDate}
 group by
-    area_name
+    area_no
 ),
-t2 as (
+t102 as (
 select
-    *,
-    case
-        when total_sum = 0 then 0
-        else odd_sum / total_sum * 100
-    end as odd_percent
+    area_no,
+    round(odd_sum / 10000, 2) as odd_sum,
+    round(total_sum / 10000, 2) as total_sum,
+    round(case when total_sum = 0 then 0 else odd_sum / total_sum * 100 end, 2) as odd_percent
 from
-    t1
+    t101
+),
+t103 as (
+select
+    a."name" as area_name,
+    coalesce(b.odd_sum, 0) as odd_sum,
+    coalesce(b.total_sum, 0) as total_sum,
+    coalesce(b.odd_percent, 0) as odd_percent
+from
+    common.organization a
+left join t102 b on
+    a.id = b.area_no
+where
+    a.grade = 1
+    and a.unhide = 1
+order by
+    a.order_num
 ),
-t3 as (
+t104 as (
 select
-    *
-from t2 left join house.second_unit_sort on t2.area_name = house.second_unit_sort.second_unit
-order by house.second_unit_sort.sort desc
+    "name" as area_name,
+    0 as odd_sum,
+    0 as total_sum,
+    0 as odd_percent
+from
+    common.organization
+where
+    grade = 1
+    and unhide = 1
+    and not exists (
+    select
+        1
+    from
+        house.building_repair_month
+    where
+        year_month >= #{dto.startDate})
+order by
+    order_num
 )
 select
-    area_name,
-    round(odd_sum / 10000,
-    2) as odd_sum,
-    round(total_sum / 10000,
-    2) as total_sum,
-    round(odd_percent,
-    2) as odd_percent
+    *
 from
-    t3
+    t103
+union all
+select
+    *
+from
+    t104
 """)
-    List<GetBuildingRepairStatVo> getSecondUnitRepairStat();
+    List<GetBuildingRepairStatVo> getSecondUnitRepairStat(@Param("dto") GetBuildingRepairStatDto dto);
 
     /**
-     * 统计最新年份某个地市的各个区县的维修费
+     * 统计某个地市的各个区县的维修费
      */
     @Select("""
 with
-t1 as (
+t101 as (
 select
-    area_name,
-    city_name,
+    area_no,
+    city_no,
     sum(case when repair_type = '零星维修' then final_cost else 0 end) as odd_sum,
     sum(final_cost) as total_sum
 from
     house.building_repair_month
 where
-    repair_type != '财务预提冲销'
-    and year_no = (
+    area_no = (
     select
-        max(year_no)
+        id
     from
-        house.building_repair_month)
-    and area_name is not null
-    and area_name != ''
-    and city_name is not null
-    and city_name != ''
-    and area_name = #{dto.city}
+        common.organization
+    where
+        "name" = #{dto.city}
+        and grade = 1
+        and unhide = 1
+    limit 1)
+    and city_no is not null
+    and city_no != ''
+    and repair_type != '财务预提冲销'
+    and year_month >= #{dto.startDate}
+    and year_month <= #{dto.endDate}
 group by
-    area_name,
-    city_name
+    area_no, city_no
 ),
-t2 as (
+t102 as (
 select
-    *,
-    case
-        when total_sum = 0 then 0
-        else odd_sum / total_sum * 100
-    end as odd_percent
+    area_no,
+    city_no,
+    round(odd_sum / 10000, 2) as odd_sum,
+    round(total_sum / 10000, 2) as total_sum,
+    round(case when total_sum = 0 then 0 else odd_sum / total_sum * 100 end, 2) as odd_percent
 from
-    t1
-)
+    t101
+),
+t103 as (
+select
+    a."name" as area_name,
+    coalesce(b.odd_sum, 0) as odd_sum,
+    coalesce(b.total_sum, 0) as total_sum,
+    coalesce(b.odd_percent, 0) as odd_percent
+from
+    common.organization a
+left join t102 b on
+    a.id = b.city_no
+where
+    a.unhide = 1
+    and a.parent_id = (
+    select
+        id
+    from
+        common.organization
+    where
+        "name" = #{dto.city}
+        and grade = 1
+        and unhide = 1
+    limit 1)
+order by
+    a.order_num
+),
+t104 as (
 select
-    city_name as area_name,
-    round(odd_sum / 10000,
-    2) as odd_sum,
-    round(total_sum / 10000,
-    2) as total_sum,
-    round(odd_percent,
-    2) as odd_percent
+    "name" as area_name,
+    0 as odd_sum,
+    0 as total_sum,
+    0 as odd_percent
 from
-    t2
+    common.organization
+where
+    unhide = 1
+    and parent_id = (
+    select
+        id
+    from
+        common.organization
+    where
+        "name" = #{dto.city}
+        and grade = 1
+        and unhide = 1
+    limit 1)
+    and not exists (
+    select
+        1
+    from
+        house.building_repair_month
+    where
+        year_month >= #{dto.startDate})
 order by
-    total_sum
+    order_num
+)
+select
+    *
+from
+    t103
+union all
+select
+    *
+from
+    t104
 """)
     List<GetBuildingRepairStatVo> getThirdUnitRepairStat(@Param("dto") GetBuildingRepairStatDto dto);
 
@@ -431,7 +484,7 @@ order by
     @Select("""
 select * from house.notices
 where city = #{dto.city}
-order by create_time desc
+and year_month = #{dto.endDate}
 """)
     List<GetHouseNoticeVo> getNotice(@Param("dto") GetHouseNoticeDto dto);
 
@@ -625,65 +678,130 @@ order by
 """)
     List<GetBuildingMapVo> getSbbBuildings(@Param("dto") GetBuildingMapDto dto);
 
+    /**
+     * 查询各个二级单位的出租收入
+     */
     @Select("""
 with
 t101 as (
 select
-    *
+    a."name" as unit,
+    b.income_all as income,
+    b.budget_finish_rate * 100 as finishing_rate
 from
-    house.rent_out_income_stat
+    common.organization a
+left join house.rent_out_income_stat b on
+    a.id = b.area_no
 where
-    (city_name is null
-        or city_name = '')
-    and year_month = (
-    select
-        max(year_month)
-    from
-        house.rent_out_income_stat)
+    a.grade = 1
+    and a.unhide = 1
+    and b.city_no = ''
+    and b.year_month = #{dto.endDate}
+order by
+    a.order_num
 ),
 t102 as (
+select
+    "name" as unit,
+    null::decimal as income,
+    null::decimal as finishing_rate
+from
+    common.organization
+where
+    grade = 1
+    and unhide = 1
+    and not exists (
+    select
+        1
+    from
+        house.rent_out_income_stat
+    where
+        year_month = #{dto.endDate})
+order by
+    order_num
+)
 select
     *
-from t101 left join house.second_unit_sort on t101.area_name = house.second_unit_sort.second_unit
-order by house.second_unit_sort.sort desc
-),
-t103 as (
+from
+    t101
+union all
 select
-area_name as unit,
-income_all as income,
-budget_finish_rate * 100 as finishing_rate
-from t102
-)
-select * from t103
+    *
+from
+    t102
 """)
     List<GetRentOutStatVo> getSecondUnitRentOutIncomeStat(@Param("dto") GetRentOutStatDto dto);
 
+    /**
+     * 查询某个二级单位下的各个三级单位的出租收入
+     */
     @Select("""
 with
 t101 as (
 select
-    *
+    a."name" as unit,
+    b.income_all as income,
+    b.budget_finish_rate * 100 as finishing_rate
 from
-    house.rent_out_income_stat
+    common.organization a
+left join house.rent_out_income_stat b on
+    a.id = b.city_no
 where
-    city_name is not null
-    and city_name != ''
-    and year_month = (
+    a.unhide = 1
+    and a.parent_id = (
     select
-        max(year_month)
+        id
     from
-        house.rent_out_income_stat)
-    and area_name = #{dto.city}
+        common.organization
+    where
+        "name" = #{dto.city}
+        and grade = 1
+        and unhide = 1
+    limit 1)
+    and b.city_no != ''
+    and b.year_month = #{dto.endDate}
+order by
+    a.order_num
 ),
 t102 as (
 select
-city_name as unit,
-income_all as income,
-budget_finish_rate * 100 as finishing_rate
-from t101
-order by income_all
+    "name" as unit,
+    null::decimal as income,
+    null::decimal as finishing_rate
+from
+    common.organization
+where
+    unhide = 1
+    and parent_id = (
+    select
+        id
+    from
+        common.organization
+    where
+        "name" = #{dto.city}
+        and grade = 1
+        and unhide = 1
+    limit 1)
+    and not exists (
+    select
+        1
+    from
+        house.rent_out_income_stat
+    where
+        year_month = #{dto.endDate}
+        and city_no != '')
+order by
+    order_num
 )
-select * from t102
+select
+    *
+from
+    t101
+union all
+select
+    *
+from
+    t102
 """)
     List<GetRentOutStatVo> getThirdUnitRentOutIncomeStat(@Param("dto") GetRentOutStatDto dto);
 }

+ 5 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetBuildingAreaStatDto.java

@@ -3,8 +3,13 @@ package com.nokia.financeapi.pojo.dto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetBuildingAreaStatDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
 }

+ 3 - 1
src/main/java/com/nokia/financeapi/pojo/dto/GetBuildingMapDto.java

@@ -4,11 +4,13 @@ import io.swagger.v3.oas.annotations.Hidden;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 
 @Data
 public class GetBuildingMapDto {
-    @Schema(description = "账期,不传默认最新", example = "202309")
+    @Schema(description = "账期", example = "202309")
+    @NotNull
     private Integer endDate;
     @Schema(description = "地市", example = "石家庄")
     private String city;

+ 4 - 1
src/main/java/com/nokia/financeapi/pojo/dto/GetBuildingOptionsDto.java

@@ -4,9 +4,12 @@ import io.swagger.v3.oas.annotations.Hidden;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetBuildingOptionsDto {
-    @Schema(description = "账期,不传默认最新", example = "202309")
+    @Schema(description = "账期", example = "202309")
+    @NotNull
     private Integer endDate;
     @Schema(description = "地市", example = "石家庄")
     private String city;

+ 11 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetBuildingRepairStatDto.java

@@ -1,10 +1,21 @@
 package com.nokia.financeapi.pojo.dto;
 
+import io.swagger.v3.oas.annotations.Hidden;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetBuildingRepairStatDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
+    /**
+     * 开始日期
+     */
+    @Hidden
+    private Integer startDate;
 }

+ 11 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetCarCostStatDto.java

@@ -1,10 +1,21 @@
 package com.nokia.financeapi.pojo.dto;
 
+import io.swagger.v3.oas.annotations.Hidden;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetCarCostStatDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
+    /**
+     * 开始日期
+     */
+    @Hidden
+    private Integer startDate;
 }

+ 5 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetCarMapStatDto.java

@@ -3,8 +3,13 @@ package com.nokia.financeapi.pojo.dto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetCarMapStatDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
 }

+ 5 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetCarNoticeDto.java

@@ -3,8 +3,13 @@ package com.nokia.financeapi.pojo.dto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetCarNoticeDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
 }

+ 5 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetCarTypeStatDto.java

@@ -3,8 +3,13 @@ package com.nokia.financeapi.pojo.dto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetCarTypeStatDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
 }

+ 11 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetDriveStatDto.java

@@ -1,10 +1,21 @@
 package com.nokia.financeapi.pojo.dto;
 
+import io.swagger.v3.oas.annotations.Hidden;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetDriveStatDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
+    /**
+     * 开始日期
+     */
+    @Hidden
+    private Integer startDate;
 }

+ 5 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetHouseNoticeDto.java

@@ -3,8 +3,13 @@ package com.nokia.financeapi.pojo.dto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetHouseNoticeDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
 }

+ 5 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetLandBuildingStatDto.java

@@ -3,8 +3,13 @@ package com.nokia.financeapi.pojo.dto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetLandBuildingStatDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
 }

+ 5 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetRentOutStatDto.java

@@ -3,8 +3,13 @@ package com.nokia.financeapi.pojo.dto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GetRentOutStatDto {
     @Schema(description = "地市,不传默认全省", example = "石家庄")
     private String city;
+    @Schema(description = "账期", example = "202307")
+    @NotNull
+    private Integer endDate;
 }

+ 15 - 3
src/main/java/com/nokia/financeapi/service/car/CarResourceMapService.java

@@ -15,6 +15,8 @@ import com.nokia.financeapi.pojo.vo.GetDriveStatVo;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
 
 @Service
@@ -43,25 +45,35 @@ public class CarResourceMapService {
             List<GetCarMapStatVo> vo = carResourceMapDao.getDistrictCarMapStat(dto);
             return R.ok(vo);
         }
-        List<GetCarMapStatVo> vo = carResourceMapDao.getCityCarMapStat();
+        List<GetCarMapStatVo> vo = carResourceMapDao.getCityCarMapStat(dto);
         return R.ok(vo);
     }
 
     public R<List<GetDriveStatVo>> getDriveStat(GetDriveStatDto dto) {
+        Integer endDate = dto.getEndDate();
+        LocalDate endLocalDate = LocalDate.parse(endDate + "01", DateTimeFormatter.ofPattern("yyyyMMdd"));
+        LocalDate startLocalDate = endLocalDate.withDayOfYear(1);
+        Integer startDate = Integer.valueOf(startLocalDate.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        dto.setStartDate(startDate);
         if (StringUtils.hasText(dto.getCity())) {
             List<GetDriveStatVo> vo = carResourceMapDao.getDistrictDriveStat(dto);
             return R.ok(vo);
         }
-        List<GetDriveStatVo> vo = carResourceMapDao.getCityDriveStat();
+        List<GetDriveStatVo> vo = carResourceMapDao.getCityDriveStat(dto);
         return R.ok(vo);
     }
 
     public R<List<GetCarCostStatVo>> getCarCostStat(GetCarCostStatDto dto) {
+        Integer endDate = dto.getEndDate();
+        LocalDate endLocalDate = LocalDate.parse(endDate + "01", DateTimeFormatter.ofPattern("yyyyMMdd"));
+        LocalDate startLocalDate = endLocalDate.withDayOfYear(1);
+        Integer startDate = Integer.valueOf(startLocalDate.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        dto.setStartDate(startDate);
         if (StringUtils.hasText(dto.getCity())) {
             List<GetCarCostStatVo> vo = carResourceMapDao.getDistrictCostStat(dto);
             return R.ok(vo);
         }
-        List<GetCarCostStatVo> vo = carResourceMapDao.getCityCostStat();
+        List<GetCarCostStatVo> vo = carResourceMapDao.getCityCostStat(dto);
         return R.ok(vo);
     }
 }

+ 9 - 19
src/main/java/com/nokia/financeapi/service/house/HouseResourceMapService.java

@@ -58,7 +58,7 @@ public class HouseResourceMapService {
             List<GetLandBuildingStatVo> vo = houseResourceMapMapper.getDistrictLandBuildingStat(dto);
             return R.ok(vo);
         }
-        List<GetLandBuildingStatVo> vo = houseResourceMapMapper.getCityLandBuildingStat();
+        List<GetLandBuildingStatVo> vo = houseResourceMapMapper.getCityLandBuildingStat(dto);
         return R.ok(vo);
     }
 
@@ -112,14 +112,6 @@ public class HouseResourceMapService {
 
     public R<List<GetBuildingMapVo>> getBuildingMap(GetBuildingMapDto dto, String token) {
         Integer endDate = dto.getEndDate();
-        // 账期为空则取最新的账期
-        if (dto.getEndDate() == null) {
-            endDate = houseResourceMapMapper.getBuildingMonthMaxDate();
-        }
-        if (endDate == null) {
-            return R.ok();
-        }
-        dto.setEndDate(endDate);
         LocalDate endLocalDate = LocalDate.parse(endDate + "01", DateTimeFormatter.ofPattern("yyyyMMdd"));
         LocalDate startLocalDate = endLocalDate.withDayOfYear(1);
         Integer startDate = Integer.valueOf(startLocalDate.format(DateTimeFormatter.ofPattern("yyyyMM")));
@@ -157,11 +149,16 @@ public class HouseResourceMapService {
     }
 
     public R<List<GetBuildingRepairStatVo>> getBuildingRepairStat(@Valid GetBuildingRepairStatDto dto) {
-        if (StringUtils. hasText(dto.getCity())) {
+        Integer endDate = dto.getEndDate();
+        LocalDate endLocalDate = LocalDate.parse(endDate + "01", DateTimeFormatter.ofPattern("yyyyMMdd"));
+        LocalDate startLocalDate = endLocalDate.withDayOfYear(1);
+        Integer startDate = Integer.valueOf(startLocalDate.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        dto.setStartDate(startDate);
+        if (StringUtils.hasText(dto.getCity())) {
             List<GetBuildingRepairStatVo> vo = houseResourceMapMapper.getThirdUnitRepairStat(dto);
             return R.ok(vo);
         }
-        List<GetBuildingRepairStatVo> vo = houseResourceMapMapper.getSecondUnitRepairStat();
+        List<GetBuildingRepairStatVo> vo = houseResourceMapMapper.getSecondUnitRepairStat(dto);
         return R.ok(vo);
     }
 
@@ -184,18 +181,11 @@ public class HouseResourceMapService {
 
     public R<List<GetBuildingOptionsVo>> getBuildingOptions(GetBuildingOptionsDto dto, String token) {
         Integer endDate = dto.getEndDate();
-        // 账期为空则取最新的账期
-        if (dto.getEndDate() == null) {
-            endDate = houseResourceMapMapper.getBuildingMonthMaxDate();
-        }
-        if (endDate == null) {
-            return R.ok();
-        }
-        dto.setEndDate(endDate);
         LocalDate endLocalDate = LocalDate.parse(endDate + "01", DateTimeFormatter.ofPattern("yyyyMMdd"));
         LocalDate startLocalDate = endLocalDate.withDayOfYear(1);
         Integer startDate = Integer.valueOf(startLocalDate.format(DateTimeFormatter.ofPattern("yyyyMM")));
         dto.setStartDate(startDate);
+        dto.setStartDate(startDate);
         if ("省本部".equals(dto.getCity())) {
             List<GetBuildingOptionsVo> vo = houseResourceMapMapper.getSbbBuildingOptions(dto);
             for (GetBuildingOptionsVo t : vo) {