|
|
@@ -635,33 +635,31 @@
|
|
635
|
635
|
order by t.stat_year desc, t.stat_month desc, t.town_dept_id asc, t.village_dept_id asc
|
|
636
|
636
|
</select>
|
|
637
|
637
|
|
|
638
|
|
- <!--
|
|
639
|
|
- 养殖主体数量明细:农牧户主表驱动;相关计数用相关子查询(仅对本页行求值,利于跨年分页);
|
|
640
|
|
- ORDER BY 对齐 uk(stat_year,stat_month,village_dept_id)。
|
|
641
|
|
- -->
|
|
642
|
638
|
<!--
|
|
643
|
639
|
养殖主体数量明细:
|
|
644
|
|
- 键集 = 农牧户 ∪ 合作社(村×年月);无农牧户仅有合作社时仍出列,农牧户/家庭牧场/养殖大户为 0。
|
|
645
|
|
- 家庭牧场、养殖大户按同键左关联计数。排序年、月倒序,便于 PageHelper 跨多年翻页。
|
|
|
640
|
+ 键集 = 农牧户 ∪ 合作社 ∪ 家庭牧场 ∪ 养殖大户(村×年月);
|
|
|
641
|
+ 任一组织形式有数据即可出列,其余数量为 0。排序年、月倒序,PageHelper 支持跨多年翻页。
|
|
646
|
642
|
-->
|
|
647
|
643
|
<select id="selectBreedingEntityQuantityList"
|
|
648
|
644
|
resultType="com.ruoyi.web.modules.screen.domain.vo.HomeScreenBreedingEntityQuantityListItemVo">
|
|
649
|
645
|
select k.stat_year as statYear,
|
|
650
|
646
|
k.stat_month as statMonth,
|
|
651
|
|
- coalesce(h.town_dept_id, c.town_dept_id) as townDeptId,
|
|
652
|
|
- coalesce(h.town_name, c.town_name) as townName,
|
|
|
647
|
+ coalesce(h.town_dept_id, c.town_dept_id, f.town_dept_id, l.town_dept_id) as townDeptId,
|
|
|
648
|
+ coalesce(h.town_name, c.town_name, f.town_name, l.town_name) as townName,
|
|
653
|
649
|
k.village_dept_id as villageDeptId,
|
|
654
|
|
- coalesce(h.village_name, c.village_name) as villageName,
|
|
|
650
|
+ coalesce(h.village_name, c.village_name, f.village_name, l.village_name) as villageName,
|
|
655
|
651
|
coalesce(h.household_count, 0) as farmerHouseholdCount,
|
|
656
|
652
|
coalesce(c.cooperative_count, 0) as cooperativeCount,
|
|
657
|
653
|
coalesce(f.family_ranch_count, 0) as familyRanchCount,
|
|
658
|
654
|
coalesce(l.large_farmer_count, 0) as largeLivestockFarmerCount
|
|
659
|
655
|
from (
|
|
660
|
|
- select stat_year, stat_month, village_dept_id
|
|
661
|
|
- from biz_farmer_household
|
|
|
656
|
+ select stat_year, stat_month, village_dept_id from biz_farmer_household
|
|
662
|
657
|
union
|
|
663
|
|
- select stat_year, stat_month, village_dept_id
|
|
664
|
|
- from biz_cooperative_development
|
|
|
658
|
+ select stat_year, stat_month, village_dept_id from biz_cooperative_development
|
|
|
659
|
+ union
|
|
|
660
|
+ select stat_year, stat_month, village_dept_id from biz_family_ranch
|
|
|
661
|
+ union
|
|
|
662
|
+ select stat_year, stat_month, village_dept_id from biz_large_livestock_farmer
|
|
665
|
663
|
) k
|
|
666
|
664
|
left join biz_farmer_household h
|
|
667
|
665
|
on h.stat_year = k.stat_year
|
|
|
@@ -682,7 +680,13 @@
|
|
682
|
680
|
and c.stat_month = k.stat_month
|
|
683
|
681
|
and c.village_dept_id = k.village_dept_id
|
|
684
|
682
|
left join (
|
|
685
|
|
- select stat_year, stat_month, village_dept_id, count(*) as family_ranch_count
|
|
|
683
|
+ select stat_year,
|
|
|
684
|
+ stat_month,
|
|
|
685
|
+ village_dept_id,
|
|
|
686
|
+ max(town_dept_id) as town_dept_id,
|
|
|
687
|
+ max(town_name) as town_name,
|
|
|
688
|
+ max(village_name) as village_name,
|
|
|
689
|
+ count(*) as family_ranch_count
|
|
686
|
690
|
from biz_family_ranch
|
|
687
|
691
|
group by stat_year, stat_month, village_dept_id
|
|
688
|
692
|
) f
|
|
|
@@ -690,7 +694,13 @@
|
|
690
|
694
|
and f.stat_month = k.stat_month
|
|
691
|
695
|
and f.village_dept_id = k.village_dept_id
|
|
692
|
696
|
left join (
|
|
693
|
|
- select stat_year, stat_month, village_dept_id, count(*) as large_farmer_count
|
|
|
697
|
+ select stat_year,
|
|
|
698
|
+ stat_month,
|
|
|
699
|
+ village_dept_id,
|
|
|
700
|
+ max(town_dept_id) as town_dept_id,
|
|
|
701
|
+ max(town_name) as town_name,
|
|
|
702
|
+ max(village_name) as village_name,
|
|
|
703
|
+ count(*) as large_farmer_count
|
|
694
|
704
|
from biz_large_livestock_farmer
|
|
695
|
705
|
group by stat_year, stat_month, village_dept_id
|
|
696
|
706
|
) l
|
|
|
@@ -705,13 +715,14 @@
|
|
705
|
715
|
and k.stat_month = #{statMonth}
|
|
706
|
716
|
</if>
|
|
707
|
717
|
<if test="townDeptId != null">
|
|
708
|
|
- and coalesce(h.town_dept_id, c.town_dept_id) = #{townDeptId}
|
|
|
718
|
+ and coalesce(h.town_dept_id, c.town_dept_id, f.town_dept_id, l.town_dept_id) = #{townDeptId}
|
|
709
|
719
|
</if>
|
|
710
|
720
|
<if test="villageDeptId != null">
|
|
711
|
721
|
and k.village_dept_id = #{villageDeptId}
|
|
712
|
722
|
</if>
|
|
713
|
723
|
</where>
|
|
714
|
724
|
order by k.stat_year desc, k.stat_month desc,
|
|
715
|
|
- coalesce(h.town_dept_id, c.town_dept_id) asc, k.village_dept_id asc
|
|
|
725
|
+ coalesce(h.town_dept_id, c.town_dept_id, f.town_dept_id, l.town_dept_id) asc,
|
|
|
726
|
+ k.village_dept_id asc
|
|
716
|
727
|
</select>
|
|
717
|
728
|
</mapper>
|