src/main/java/com/dji/sample/manage/controller/LoginController.java
@@ -2,6 +2,7 @@ import com.dji.sample.common.error.CommonErrorEnum; import com.dji.sample.common.model.ResponseResult; import com.dji.sample.log.aspect.SysLogAnnotation; import com.dji.sample.manage.model.dto.UserDTO; import com.dji.sample.manage.model.dto.UserLoginDTO; import com.dji.sample.manage.service.IUserService; @@ -26,6 +27,7 @@ private IUserService userService; @PostMapping("/login") @SysLogAnnotation(operModul = "账户管理", operType = "登录", operDesc = "用户登录") public ResponseResult login(@RequestBody UserLoginDTO loginDTO) { String username = loginDTO.getUsername(); src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java
@@ -117,7 +117,17 @@ //相机已经在直播中,请勿重复开启直播 if(receiveReply.getResult() == 513003) { LiveDTO live = new LiveDTO(); live.setUrl(liveParam.getUrl().replace("rtmp", "https").replace("735","700") + ".flv"); // live.setUrl(liveParam.getUrl().replace("rtmp", "https").replace("735","700") + ".flv"); LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl()); live.setUrl(new StringBuilder() .append("http://") .append(gb28181.getServerIP()) .append(":8880/rtp/") .append(gb28181.getAgentID()) .append("_") .append(gb28181.getChannel()) .append(".live.flv") .toString()); return ResponseResult.success(live); } @@ -134,15 +144,27 @@ // live.setUrl(liveParam.getUrl().replace("rtmp", "webrtc")); live.setUrl(liveParam.getUrl().replace("rtmp", "https").replace("735","700") + ".flv"); break; // case GB28181: // LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl()); // live.setUrl(new StringBuilder() // .append("webrtc://") // .append(gb28181.getServerIP()) // .append("/live/") // .append(gb28181.getAgentID()) // .append("@") // .append(gb28181.getChannel()) // .toString()); // break; case GB28181: LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl()); live.setUrl(new StringBuilder() .append("webrtc://") .append("http://") .append(gb28181.getServerIP()) .append("/live/") .append(":8880/rtp/") .append(gb28181.getAgentID()) .append("@") .append("_") .append(gb28181.getChannel()) .append(".live.flv") .toString()); break; case RTSP: src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -56,7 +56,6 @@ * @return */ @GetMapping("/listPatches") @SysLogAnnotation(operModul = "图斑", operType = "查询", operDesc = "查询图斑的全部信息") public ResponseResult<PaginationData<LotInfo>> page(@RequestParam Integer page, @RequestParam(name = "page_size", defaultValue = "10") Integer pageSize, @RequestParam String workspaceId, @@ -147,10 +146,12 @@ try { timerUtil.myTask(); // timerUtil.myTask2(); return ResponseResult.success(); // timerUtil.myTask3(); } catch (Exception e) { throw new RuntimeException("db存储发送出现异常"+e); } return ResponseResult.success(); } // @GetMapping ("/tests") // public ResponseResult use() { src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -14,9 +14,11 @@ import com.dji.sample.territory.pojo.TerritoryConfigPojo; import com.dji.sample.territory.service.ITbFJService; import com.dji.sample.wayline.model.dto.WaylineFileDTO; import com.dji.sample.wayline.model.dto.WaylineJobDTO; import com.dji.sample.wayline.model.entity.WaylineFileEntity; import com.dji.sample.wayline.model.param.CreateJobParam; import com.dji.sample.wayline.service.IWaylineFileService; import com.dji.sample.wayline.service.IWaylineJobBreakPointService; import com.dji.sample.wayline.service.IWaylineJobService; import org.springframework.beans.factory.annotation.Autowired; @@ -42,10 +44,7 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.stream.Collectors; @@ -76,7 +75,8 @@ private IWaylineJobService waylineJobService; @Autowired private TerritoryConfigPojo territoryConfigPojo; @Autowired private IWaylineJobBreakPointService jobBreakPointService; /** * 定时器,将没有规划的图斑生成航线,并将航线飞完后的成果数据进行保存推送 @@ -93,9 +93,7 @@ List<List<LotInfo>> lists = getNoPlan(workspaceId); List<List<LotInfo>> convertedLists = convertToLists(lists); for (List<LotInfo> list : convertedLists) { long timestamp = System.currentTimeMillis(); time = addOneHourToTimestamp(time); String waylineName = "云飞行调查" + timestamp; String waylineName = getNowTimeName(); //根据获取的图斑集合获得kmz航线文件 MultipartFile multipartFile = null; try { @@ -113,8 +111,9 @@ List<Long> lists1 = new ArrayList<>(); lists1.add(time); String times = convertTimestampToFormattedString(time); sendPostWithParameters("云飞行计划" + timestamp, waylineFile.getWaylineId(), times, lists1, listOfLists); sendPostWithParameters(waylineName, waylineFile.getWaylineId(), times, lists1, listOfLists); updatePatchesStatu(list); time = addOneHourToTimestamp(time); } } @@ -130,6 +129,17 @@ } }); executor.shutdown(); } public void myTask3() throws SQLException { String workspaceId = "4a574db8-4ad3-48f7-9f16-3edbcd8056e1"; String name = getNowDay(); List<String> jobs = waylineJobService.selectJobIdByName(name); List<String> jobIds = jobBreakPointService.selectHaveBreak(jobs); for (String jobid : jobIds) { Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobId(workspaceId, jobid, true); waylineJobService.publishOneFlightTask(waylineJobDTO.get()); } } /** @@ -533,7 +543,7 @@ ZonedDateTime zonedDateTime = instant.atZone(ZoneId.systemDefault()); // 加上一小时 ZonedDateTime zonedDateTimePlusOneHour = zonedDateTime.plusHours(1); ZonedDateTime zonedDateTimePlusOneHour = zonedDateTime.plusHours(1).plusMinutes(30); // 将ZonedDateTime对象转换回秒级时间戳 return zonedDateTimePlusOneHour.toInstant().getEpochSecond(); @@ -552,4 +562,26 @@ return chinaTime.format(formatter); } public static String getNowTimeName() { LocalDateTime currentTime = LocalDateTime.now(); // 格式化时间,生成当前时间 return "云飞行计划" + currentTime.format(DateTimeFormatter.ofPattern("MMddHHmmssSS")); } public static String getNowDay() { LocalDateTime currentTime = LocalDateTime.now(); // 格式化时间,生成当前时间 return "云飞行计划" + currentTime.format(DateTimeFormatter.ofPattern("MMdd")); } public static void main(String[] args) { // 获取当前时间 LocalDateTime currentTime = LocalDateTime.now(); // 格式化时间,生成文件夹名字 String folderName = currentTime.format(DateTimeFormatter.ofPattern("MMddHHmmssSS")); System.out.println(folderName); } } src/main/java/com/dji/sample/wayline/service/IWaylineJobBreakPointService.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.dji.sample.wayline.model.entity.WaylineJobBreakPointEntity; import java.util.List; /** * @PROJECT_NAME: drone * @DESCRIPTION: @@ -12,4 +14,5 @@ public interface IWaylineJobBreakPointService extends IService<WaylineJobBreakPointEntity> { public boolean addWaylineJobBreakPoint(WaylineJobBreakPointEntity entity); List<String> selectHaveBreak(List<String> ids); } src/main/java/com/dji/sample/wayline/service/IWaylineJobService.java
@@ -148,6 +148,7 @@ */ void flightTaskResourceGet(CommonTopicReceiver receiver, MessageHeaders headers); List<String> selectJobIdByName (String name); /** * Set the media files for this job to upload immediately. * @param workspaceId src/main/java/com/dji/sample/wayline/service/impl/WaylineJobBreakPointServiceImpl.java
@@ -1,5 +1,7 @@ package com.dji.sample.wayline.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dji.sample.wayline.dao.IWaylineJobBreakPointMapper; import com.dji.sample.wayline.model.entity.WaylineJobBreakPointEntity; @@ -7,6 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; /** * @PROJECT_NAME: drone @@ -26,4 +31,15 @@ int insertId = mapper.insert(entity); return insertId>0; } @Override public List<String> selectHaveBreak(List<String> ids) { LambdaQueryWrapper<WaylineJobBreakPointEntity> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.select(WaylineJobBreakPointEntity::getJobId).in(WaylineJobBreakPointEntity::getJobId, ids); List<WaylineJobBreakPointEntity> entities = mapper.selectList(queryWrapper); // 将查询结果转换为List<Long> return entities.stream() .map(WaylineJobBreakPointEntity::getJobId) .collect(Collectors.toList()); } } src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -149,7 +149,7 @@ .rthAltitude(param.getRthAltitude()) .mediaCount(0) .build(); if (StringUtils.hasText(param.getJobId())){ if (StringUtils.hasText(param.getJobId())) { jobEntity.setJobId(param.getJobId()); } return insertWaylineJob(jobEntity); @@ -517,7 +517,7 @@ } @Override public Optional<WaylineJobDTO> getJobByJobId(String workspaceId, String jobId,Boolean isBreakPoint) { public Optional<WaylineJobDTO> getJobByJobId(String workspaceId, String jobId, Boolean isBreakPoint) { WaylineJobEntity jobEntity = mapper.selectOne( new LambdaQueryWrapper<WaylineJobEntity>() .eq(WaylineJobEntity::getWorkspaceId, workspaceId) @@ -566,7 +566,7 @@ @Override public PaginationData<WaylineJobDTO> getJobsByWorkspaceIdNew(String workspaceId, long page, long pageSize, WaylineJobQueryParam waylineJobQueryParam, String order) { Page<WaylineJobEntity> pageData = mapper.getPageNew(new Page<WaylineJobEntity>(page, pageSize), waylineJobQueryParam, workspaceId,order); Page<WaylineJobEntity> pageData = mapper.getPageNew(new Page<WaylineJobEntity>(page, pageSize), waylineJobQueryParam, workspaceId, order); List<WaylineJobDTO> records = pageData.getRecords() .stream() @@ -575,7 +575,7 @@ // 是否需要断点续飞 records.forEach(wjd -> wjd.setBreakPoint(waylineJobBreakPointService.count( new LambdaQueryWrapper<WaylineJobBreakPointEntity>().eq(WaylineJobBreakPointEntity::getJobId,wjd.getJobId())) > 0)); new LambdaQueryWrapper<WaylineJobBreakPointEntity>().eq(WaylineJobBreakPointEntity::getJobId, wjd.getJobId())) > 0)); return new PaginationData<WaylineJobDTO>(records, new Pagination(pageData)); @@ -652,6 +652,18 @@ messageSender.publish(topic, builder.build()); } @Override public List<String> selectJobIdByName(String name) { List<WaylineJobEntity> waylineJobs = mapper.selectList(new LambdaQueryWrapper<WaylineJobEntity>() .select(WaylineJobEntity::getJobId) .like(WaylineJobEntity::getName, name)); return waylineJobs.stream() .map(WaylineJobEntity::getJobId) .collect(Collectors.toList()); } @Override public void uploadMediaHighestPriority(String workspaceId, String jobId) { @@ -800,10 +812,10 @@ if (flyToRes.getCode() == ResponseResult.CODE_SUCCESS) { //第一个点指令飞行成功后,把数组存到redis中 JSONObject jsonObject = new JSONObject(); jsonObject.put("targetList",targetList); jsonObject.put("payloadIndex",flyAreaParam.getPayloadIndex()); jsonObject.put("curIndex",0); RedisOpsUtils.set("tuban:"+sn,jsonObject); jsonObject.put("targetList", targetList); jsonObject.put("payloadIndex", flyAreaParam.getPayloadIndex()); jsonObject.put("curIndex", 0); RedisOpsUtils.set("tuban:" + sn, jsonObject); } break; } @@ -953,22 +965,22 @@ @Override public WaylineJobCountDTO patrolStatistics(String workspaceId, String queryTime,String deviceSn) { public WaylineJobCountDTO patrolStatistics(String workspaceId, String queryTime, String deviceSn) { WaylineJobCountDTO waylineJobCountDTO = new WaylineJobCountDTO(); List<DroneFlightLogEntity> list = flightLogMapper.patrolStatistics(workspaceId,queryTime,deviceSn); 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 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)); waylineJobCountDTO.setTotalDuration(String.format("%02d h %02d min", h, m)); List<String> deviceSns = list.stream().map(DroneFlightLogEntity::getDeviceSn).distinct().collect(Collectors.toList()); double sum = 0.0; for (String sn : deviceSns) { Double totalFlightDistance = new LambdaQueryChainWrapper<>(flightLogMapper) .eq(DroneFlightLogEntity::getDeviceSn, sn).orderByDesc(DroneFlightLogEntity::getEndTime).last("limit 1").one().getTotalFlightDistance(); if (totalFlightDistance!= null){ sum+=totalFlightDistance; if (totalFlightDistance != null) { sum += totalFlightDistance; } } waylineJobCountDTO.setTotalDistance((int) sum);