hanfucheng 11 kuukautta sitten
vanhempi
commit
6a6b673a3c

+ 10 - 0
src/main/java/com/sooka/sponest/data/digitalforest/controller/ForestViewNewController.java

@@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.sooka.sponest.data.digitalforest.domain.*;
 import com.sooka.sponest.data.digitalforest.service.IForestViewNewService;
+import com.sooka.sponest.data.digitalwater.domain.CenterdataTHydraulicPatrolTask;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -88,4 +89,13 @@ public class ForestViewNewController extends BaseController {
         return R.ok(iForestViewNewService.selectCyryList(centerdataTForestCyry));
     }
 
+    /*
+    * 按人员查询巡护任务
+    */
+    @ApiOperation(value = "按人员查询巡护任务", notes = "按人员查询巡护任务")
+    @GetMapping("/selectTaskList")
+    public R selectTaskList(CenterdataTHydraulicPatrolTask task) {
+        return R.ok(iForestViewNewService.selectTaskList(task));
+    }
+
 }

+ 3 - 0
src/main/java/com/sooka/sponest/data/digitalforest/mapper/ForestViewNewMapper.java

@@ -1,6 +1,7 @@
 package com.sooka.sponest.data.digitalforest.mapper;
 
 import com.sooka.sponest.data.digitalforest.domain.*;
+import com.sooka.sponest.data.digitalwater.domain.CenterdataTHydraulicPatrolTask;
 
 import java.util.List;
 import java.util.Map;
@@ -24,4 +25,6 @@ public interface ForestViewNewMapper {
     List<Map<String, Object>> selectLycyzczList(CenterdataTForestLycyzcz centerdataTForestLycyzcz);
 
     List<Map<String, Object>> selectCyryList(CenterdataTForestCyry centerdataTForestCyry);
+
+    List<Map<String, Object>> selectTaskList(CenterdataTHydraulicPatrolTask task);
 }

+ 3 - 0
src/main/java/com/sooka/sponest/data/digitalforest/service/IForestViewNewService.java

@@ -2,6 +2,7 @@ package com.sooka.sponest.data.digitalforest.service;
 
 import com.sooka.sponest.data.base.service.IBaseService;
 import com.sooka.sponest.data.digitalforest.domain.*;
+import com.sooka.sponest.data.digitalwater.domain.CenterdataTHydraulicPatrolTask;
 
 import java.util.List;
 import java.util.Map;
@@ -27,4 +28,6 @@ public interface IForestViewNewService extends IBaseService {
     Map<String, Object> selectLycyzczList(CenterdataTForestLycyzcz centerdataTForestLycyzcz);
 
     List<Map<String, Object>> selectCyryList(CenterdataTForestCyry centerdataTForestCyry);
+
+    List<Map<String, Object>> selectTaskList(CenterdataTHydraulicPatrolTask task);
 }

+ 46 - 0
src/main/java/com/sooka/sponest/data/digitalforest/service/impl/ForestViewNewServiceImpl.java

@@ -1,10 +1,14 @@
 package com.sooka.sponest.data.digitalforest.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.datascope.annotation.DataScopeMutiDept;
+import com.ruoyi.common.security.utils.DictUtils;
 import com.sooka.sponest.data.base.service.impl.BaseServiceImpl;
 import com.sooka.sponest.data.digitalforest.domain.*;
 import com.sooka.sponest.data.digitalforest.mapper.ForestViewNewMapper;
 import com.sooka.sponest.data.digitalforest.service.IForestViewNewService;
+import com.sooka.sponest.data.digitalwater.domain.CenterdataTHydraulicPatrolTask;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -92,4 +96,46 @@ public class ForestViewNewServiceImpl extends BaseServiceImpl implements IForest
         return forestViewNewMapper.selectCyryList(centerdataTForestCyry);
     }
 
+    @DataScopeMutiDept(deptAlias = "d")
+    @Override
+    public List<Map<String, Object>> selectTaskList(CenterdataTHydraulicPatrolTask task) {
+        setSookaDataBase(task);
+        List<Map<String,Object>> list = forestViewNewMapper.selectTaskList(task);
+        list.forEach(item -> {
+            item.put("rangLabel",DictUtils.getDictDataByValue("forest_lin_level",item.get("rank").toString()));
+            item.put("periodLabel",DictUtils.getDictDataByValue("centerdataplanning_cycle",item.get("period").toString()));
+            if (StringUtils.isNotBlank(item.get("patrolTrajectory").toString())) {
+                item.put("planLength",getPlanLength(item.get("patrolTrajectory").toString()));
+            }
+        });
+        return list;
+    }
+
+
+    private String getPlanLength(String patrolTrajectory) {
+        double juli = 0.0;
+        JSONArray jsonArray = JSONArray.parseArray(patrolTrajectory);
+        for (int i = 0; i < jsonArray.size(); i++) {
+            if (i == 0) {
+                continue;
+            }
+            // 纬度
+            double lat1 = Math.toRadians(jsonArray.getJSONObject(i - 1).getDouble("lat"));
+            double lat2 = Math.toRadians(jsonArray.getJSONObject(i).getDouble("lat"));
+            // 经度
+            double lng1 = Math.toRadians(jsonArray.getJSONObject(i - 1).getDouble("lng"));
+            double lng2 = Math.toRadians(jsonArray.getJSONObject(i).getDouble("lng"));
+            // 纬度之差
+            double a = lat1 - lat2;
+            // 经度之差
+            double b = lng1 - lng2;
+            // 计算两点距离的公式
+            double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
+                    Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
+            // 弧长乘地球半径, 返回单位: 千米
+            juli += s * 6378.137;
+        }
+        return String.format("%.2f", juli);
+    }
+
 }

+ 22 - 1
src/main/resources/mapper/digitalforest/ForestViewNewMapper.xml

@@ -160,9 +160,30 @@
             round(CAST( IFNULL( sum( CAST(zgpjrs AS CHAR)*CAST(zgldbc AS CHAR) ), 0 ) AS CHAR )/CAST( IFNULL( sum( zgpjrs ), 0 ) AS CHAR ),2) average
         FROM
             centerdata_t_forest_cyry a
-            LEFT JOIN onest_system.sys_dept d ON a.dept_id = d.dept_id
+            LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
         WHERE
             a.`year` = YEAR ( CURRENT_DATE )
             ${params.dataScope}
     </select>
+
+    <select id="selectTaskList" parameterType="CenterdataTHydraulicPatrolTask" resultType="map">
+        SELECT
+               a.task_name taskName,
+               IFNULL(Round(sum(b.distance) / 1000, 2), 0) distance,
+               c.`name` planName,
+               c.period,
+               c.rank,
+               c.cycle_frequency cycleFrequency,
+               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
+                 LEFT JOIN centerdata_t_hydraulic_patrol_plan_record b ON a.id = b.task_id
+                 LEFT JOIN centerdata_t_hydraulic_patrol_plan c ON a.plan_id = c.id
+        WHERE a.type = #{type}
+          AND b.user_id = #{userId}
+            ${params.dataScope}
+        GROUP BY a.id
+        ORDER BY
+            a.create_time DESC
+    </select>
 </mapper>