|
@@ -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);
|
|
|
}
|