shenyijian
2023-11-21 bee596030bf9f9d395d65fbe17be57c52fa0af04
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -900,18 +900,18 @@
    @Override
    public WaylineJobCountDTO patrolStatistics(String workspaceId, String queryTime) {
    public WaylineJobCountDTO patrolStatistics(String workspaceId, String queryTime,String deviceSn) {
        WaylineJobCountDTO waylineJobCountDTO = new WaylineJobCountDTO();
      List<DroneFlightLogEntity>  list =  flightLogMapper.patrolStatistics(workspaceId,queryTime);
      List<DroneFlightLogEntity>  list =  flightLogMapper.patrolStatistics(workspaceId,queryTime,deviceSn);
        if (!CollectionUtils.isEmpty(list)) {
            waylineJobCountDTO.setTotalNumber(list.size());
            long totalTime = list.stream().filter(task -> task.getEndTime()!= null && task.getStartTime()!= null).mapToLong(s -> s.getEndTime() - s.getStartTime()).sum() / 1000;
            long h = totalTime / 3600;
            long m = (totalTime % 3600) / 60;
            waylineJobCountDTO.setTotalDuration( String.format("%02d h %02d min", h, m));
            List<String> deviceSn = list.stream().map(DroneFlightLogEntity::getDeviceSn).distinct().collect(Collectors.toList());
            List<String> deviceSns = list.stream().map(DroneFlightLogEntity::getDeviceSn).distinct().collect(Collectors.toList());
            double sum = 0.0;
            for (String sn : deviceSn) {
            for (String sn : deviceSns) {
                Double totalFlightDistance = new LambdaQueryChainWrapper<>(flightLogMapper)
                        .eq(DroneFlightLogEntity::getDeviceSn, sn).orderByDesc(DroneFlightLogEntity::getEndTime).last("limit 1").one().getTotalFlightDistance();
               if (totalFlightDistance!= null){