瀏覽代碼

大数据中台,永久基本农田

zhaozhan 1 年之前
父節點
當前提交
be9d369d63

+ 2 - 1
src/main/java/com/sooka/sponest/data/digitalresource/mapper/DigitalResourcesBigDataMapper.java

@@ -1,5 +1,6 @@
 package com.sooka.sponest.data.digitalresource.mapper;
 
+import com.ruoyi.system.api.domain.SysDictData;
 import com.sooka.sponest.data.app.domain.VisuForestCloudMapVO;
 import com.sooka.sponest.data.digitalforest.domain.CenterdataTForestGrid;
 import com.sooka.sponest.data.digitalforest.domain.bo.VisuForestCloudEventTypeBO;
@@ -80,7 +81,7 @@ public interface DigitalResourcesBigDataMapper {
      * @return
      */
 
-    List<Map<String, Object>> selectFarmBasicFarmlandCount(CenterdataTFarmBasicFarmland centerdataTFarmBasicFarmland);
+    List<Map<String, Object>> selectFarmBasicFarmlandCount(List<SysDictData> list);
     List<Map<String, Object>> selectDept(CenterdataTFarmBasicFarmland centerdataTFarmBasicFarmland);
 
     /**

+ 2 - 16
src/main/java/com/sooka/sponest/data/digitalresource/service/impl/ResourceBigDataServiceImpl.java

@@ -2,6 +2,7 @@ package com.sooka.sponest.data.digitalresource.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.ruoyi.common.datascope.annotation.DataScopeMutiDept;
+import com.ruoyi.common.security.utils.DictUtils;
 import com.sooka.sponest.data.app.domain.VisuForestCloudMapVO;
 import com.sooka.sponest.data.base.service.impl.BaseServiceImpl;
 import com.sooka.sponest.data.digitalforest.domain.CenterdataTForestGrid;
@@ -18,8 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -154,20 +153,7 @@ public class ResourceBigDataServiceImpl extends BaseServiceImpl implements IReso
     @DataScopeMutiDept(deptAlias = "d")
     @Override
     public List<Map<String, Object>> selectFarmBasicFarmlandCount(CenterdataTFarmBasicFarmland centerdataTFarmBasicFarmland) {
-        setSookaDataBase(centerdataTFarmBasicFarmland);
-        List<Map<String, Object>> listMap=new ArrayList<>();
-        digitalResourcesBigDataMapper.selectDept(centerdataTFarmBasicFarmland).forEach(item ->{
-            CenterdataTFarmBasicFarmland farmBasicFarmland = new CenterdataTFarmBasicFarmland();
-            farmBasicFarmland.setDeptId(Long.parseLong(String.valueOf(item.get("dept_id"))));
-            setSookaDataBase(farmBasicFarmland);
-            Map<String, Object> map = new HashMap<>();
-            map.put("deptName",item.get("dept_name"));
-            digitalResourcesBigDataMapper.selectFarmBasicFarmlandCount(farmBasicFarmland).forEach(items ->{
-                map.put(String.valueOf(items.get("name")),items.get("value")) ;
-            });
-            listMap.add(map);
-        });
-        return listMap;
+        return deptLevelUtil.getDeptLevel(digitalResourcesBigDataMapper.selectFarmBasicFarmlandCount(DictUtils.getDictCache("farm_field_attribute")));
     }
     /**
      * 地质灾害易发区

+ 48 - 43
src/main/resources/mapper/digitalresource/DigitalResourcesBigDataMapper.xml

@@ -297,51 +297,56 @@
         group by dict.dict_value
     </select>
 
-    <select id="selectDept" parameterType="CenterdataTFarmBasicFarmland" resultType="java.util.Map">
+    <select id="selectDept" parameterType="list" resultType="java.util.Map">
         select d.dept_id,d.dept_name from ${database_system}.sys_dept d where dept_type="sys_dept_type_17"
     </select>
     <select id="selectFarmBasicFarmlandCount" parameterType="CenterdataTFarmBasicFarmland" resultType="java.util.Map">
-        select dict.dict_label name,IFNULL(sum(a.area),0) value from ${database_system}.sys_dict_data dict
-            left join ( select a.* from centerdata_t_farm_basic_farmland a
-            left join ${database_system}.sys_dept d on  a.dept_id=d.dept_id
-            where (a.dept_id =#{deptId}  or FIND_IN_SET( #{deptId}, d.ancestors )) ${params.dataScope}
-            )a on a.attribute = dict.dict_value
-        where dict.dict_type = 'farm_field_attribute'
-        group by dict.dict_label
-    </select>
+        select
+        a.dept_id deptId,d.ancestors,
+        <foreach item="item" collection="list" open="" separator="," close="">
+            ifnull(MAX(CASE WHEN a.attribute = #{item.dictValue} THEN a.area END) ,0) AS #{item.dictLabel}
+        </foreach>
+        FROM
+        centerdata_t_farm_basic_farmland a
+        LEFT JOIN onest_system.sys_dept d ON a.dept_id = d.dept_id
+        LEFT JOIN onest_system.sys_dict_data dict ON a.attribute = dict.dict_value
+        WHERE
+        dict.dict_type = 'farm_field_attribute'
+        GROUP BY a.id
+   </select>
 
-    <select id="getHydraulicPatrolTask" parameterType="CenterdataTHydraulicPatrolTask" resultType="java.util.Map">
-        SELECT t1.deptId, t1.ancestors,t1.patrolTrajectory,ifnull(TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM FORMAT(t2.length/1000,2))),0) realLength FROM (
-        select a.id,a.create_time,a.dept_id deptId ,d.ancestors ancestors,
-        a.patrol_trajectory patrolTrajectory
-        from centerdata_t_hydraulic_patrol_task a
-        left join ${database_system}.sys_dept d on a.dept_id = d.dept_id
-        <where>
-            <if test="type != null  and type != ''">and a.type = #{type}</if>
-            ${params.dataScope}
-        </where>
-        ) t1
-        LEFT JOIN (
-        SELECT task_id, sum( c.juli ) length FROM (
-        SELECT a.task_id,
-        IFNULL( st_distance_sphere ( point ( a.longitude, a.latitude ), point ( b.longitude, b.latitude ) ), 0 ) AS juli
-        FROM (
-        SELECT a.*,(@i := @i + 1) AS xh FROM (
-        SELECT a.task_id,b.longitude,b.latitude
-        FROM centerdata_t_hydraulic_patrol_plan_record a
-        LEFT JOIN centerdata_t_hydraulic_patrol_track b ON b.record_id = a.id
-        ORDER BY b.create_time) a,(SELECT @i := 1) AS itable
-        ) a
-        LEFT JOIN (
-        SELECT a.*,(@j := @j + 1) AS xh FROM(
-        SELECT a.task_id,b.longitude,b.latitude
-        FROM centerdata_t_hydraulic_patrol_plan_record a
-        LEFT JOIN centerdata_t_hydraulic_patrol_track b ON b.record_id = a.id
-        ORDER BY b.create_time) a,(SELECT @j := 0) AS itable
-        ) b ON a.xh = b.xh AND a.task_id = b.task_id
-        ) c
-        GROUP BY task_id
-        ) t2 ON t2.task_id = t1.id
-        ORDER BY t1.create_time DESC
-    </select>
+   <select id="getHydraulicPatrolTask" parameterType="CenterdataTHydraulicPatrolTask" resultType="java.util.Map">
+       SELECT t1.deptId, t1.ancestors,t1.patrolTrajectory,ifnull(TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM FORMAT(t2.length/1000,2))),0) realLength FROM (
+       select a.id,a.create_time,a.dept_id deptId ,d.ancestors ancestors,
+       a.patrol_trajectory patrolTrajectory
+       from centerdata_t_hydraulic_patrol_task a
+       left join ${database_system}.sys_dept d on a.dept_id = d.dept_id
+       <where>
+           <if test="type != null  and type != ''">and a.type = #{type}</if>
+           ${params.dataScope}
+       </where>
+       ) t1
+       LEFT JOIN (
+       SELECT task_id, sum( c.juli ) length FROM (
+       SELECT a.task_id,
+       IFNULL( st_distance_sphere ( point ( a.longitude, a.latitude ), point ( b.longitude, b.latitude ) ), 0 ) AS juli
+       FROM (
+       SELECT a.*,(@i := @i + 1) AS xh FROM (
+       SELECT a.task_id,b.longitude,b.latitude
+       FROM centerdata_t_hydraulic_patrol_plan_record a
+       LEFT JOIN centerdata_t_hydraulic_patrol_track b ON b.record_id = a.id
+       ORDER BY b.create_time) a,(SELECT @i := 1) AS itable
+       ) a
+       LEFT JOIN (
+       SELECT a.*,(@j := @j + 1) AS xh FROM(
+       SELECT a.task_id,b.longitude,b.latitude
+       FROM centerdata_t_hydraulic_patrol_plan_record a
+       LEFT JOIN centerdata_t_hydraulic_patrol_track b ON b.record_id = a.id
+       ORDER BY b.create_time) a,(SELECT @j := 0) AS itable
+       ) b ON a.xh = b.xh AND a.task_id = b.task_id
+       ) c
+       GROUP BY task_id
+       ) t2 ON t2.task_id = t1.id
+       ORDER BY t1.create_time DESC
+   </select>
 </mapper>