Просмотр исходного кода

无人机对接接口 无人机信息

S0025136190 1 год назад
Родитель
Сommit
ae1d45b75f

+ 1 - 1
Backend/sample/src/main/java/com/dji/sample/component/AuthInterceptor.java

@@ -82,7 +82,7 @@ public class AuthInterceptor implements HandlerInterceptor {
                 return true;
             }
         }
-        return false;
+        return check;
     }
 
     private boolean checkToken(HttpServletRequest request, HttpServletResponse response) {

+ 6 - 6
Backend/sample/src/main/java/com/dji/sample/manage/dao/IDeviceMapper.java

@@ -18,13 +18,13 @@ public interface IDeviceMapper extends BaseMapper<DeviceEntity> {
 
 
     @Select("<script> " +
-            "SELECT md.device_sn deviceSn" +
-            " ,md.workspace_id workspaceId"+
-            " ,mw.workspace_name workspaceName"+
+            "SELECT md.device_sn deviceSn " +
+            " ,md.workspace_id workspaceId "+
+            " ,mw.workspace_name workspaceName "+
             " ,md.nickname "+
-            " ,md.device_name deviceName"+
-            "   from manager_device md" +
-            " left join manager_workspace mw on md.worksapce_id = mw.workspace_id " +
+            " ,md.device_name deviceName "+
+            "   from manage_device md " +
+            " left join manage_workspace mw on md.workspace_id = mw.workspace_id " +
             " where 1 = 1 " +
             "<if test='workspaceName != null'> " +
             " and worksapce_name LIKE CONCAT('%', #{workspaceName},'%')" +

+ 8 - 3
Backend/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java

@@ -854,12 +854,17 @@ public class DeviceServiceImpl implements IDeviceService {
                 List<FlightTaskEntity> flightTask = flightTrackTaskService.getFlightTrack(device.getDeviceSn(),device.getWorkspaceId());
                 device.setFlightCount(flightTask.size());
                 double kilomters = 0;
+
                 for(FlightTaskEntity entity : flightTask) {
-                    double kilomter = flightTrackTaskService.getFlightKilometersByTaskId(entity.getId());
-                    kilomters = kilomters + kilomter;
+                    if(null != entity.getFlightKilometers()) {
+                        kilomters = kilomters + entity.getFlightKilometers();
+                    } else {
+                        double kilomter = flightTrackTaskService.getFlightKilometersByTaskId(entity.getId());
+                        kilomters = kilomters + kilomter;
+                    }
                 }
                 device.setFlightKilometers(kilomters);
-                //upstreamDeviceDTO.setDeviceSn(device.getDeviceSn());
+                resultList.add(device);
             }
         }
         if(status != null) {

+ 3 - 0
Backend/sample/src/main/java/com/dji/sample/map/model/entity/FlightTaskEntity.java

@@ -67,5 +67,8 @@ public class FlightTaskEntity implements Serializable {
 
     @TableField("template_type")
     private String templateType;
+
+    @TableField("flight_kilometers")
+    private Double flightKilometers;
 }
 

+ 8 - 2
Backend/sample/src/main/java/com/dji/sample/map/service/impl/FlightTrackTaskServiceImpl.java

@@ -361,6 +361,10 @@ public class FlightTrackTaskServiceImpl implements IFlightTrackTaskService {
         if(coordinates.size() > 0) {
             result = calculateTotalDistance(coordinates);
         }
+        FlightTaskEntity flightTaskEntity = new FlightTaskEntity();
+        flightTaskEntity.setId(taskId);
+        flightTaskEntity.setFlightKilometers(result);
+        mapper.updateById(flightTaskEntity);
         return result;
     }
 
@@ -386,7 +390,9 @@ public class FlightTrackTaskServiceImpl implements IFlightTrackTaskService {
         return builder.build();
     }
 
-    private  double calculateTotalDistance(List<CoordinateUtil.Coordinate> coordinates) {
+
+
+    private double calculateTotalDistance(List<CoordinateUtil.Coordinate> coordinates) {
         double totalDistance = 0.0;
 
         for (int i = 0; i < coordinates.size() - 1; i++) {
@@ -399,7 +405,7 @@ public class FlightTrackTaskServiceImpl implements IFlightTrackTaskService {
         return totalDistance;
     }
 
-    private double calculateDistance(CoordinateUtil.Coordinate start, CoordinateUtil.Coordinate end) {
+    private  double calculateDistance(CoordinateUtil.Coordinate start, CoordinateUtil.Coordinate end) {
         final int R = 6371; // 地球平均半径,单位为公里
         double lat1 = Math.toRadians(start.getLat());
         double lat2 = Math.toRadians(end.getLat());