| | |
| | | import com.dji.sample.patches.xml.utils.CreateWaylineFileUtils; |
| | | import com.dji.sample.territory.pojo.TerritoryConfigPojo; |
| | | import com.dji.sample.territory.service.ITbFJService; |
| | | import com.dji.sample.wayline.dao.IWaylineJobBreakPointMapper; |
| | | import com.dji.sample.wayline.dao.IWaylineJobMapper; |
| | | 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.entity.WaylineJobBreakPointEntity; |
| | | import com.dji.sample.wayline.model.entity.WaylineJobEntity; |
| | | import com.dji.sample.wayline.model.param.CreateJobParam; |
| | | import com.dji.sample.wayline.service.IWaylineFileService; |
| | | import com.dji.sample.wayline.service.IWaylineJobBreakPointService; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.nio.file.StandardCopyOption; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.*; |
| | | |
| | | import java.io.*; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.sql.SQLException; |
| | | import java.time.ZoneId; |
| | | import java.time.ZonedDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.ExecutorService; |
| | |
| | | private PatchesConfigPojo patchesConfigPojo; |
| | | @Autowired |
| | | public IWaylineFileService waylineFileService; |
| | | |
| | | @Autowired |
| | | private IWaylineJobService waylineJobService; |
| | | @Autowired |
| | | private ITbFJService tbFJService; |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private GetPatchesMapper patchesMapper; |
| | | @Autowired |
| | | private IWaylineJobService waylineJobService; |
| | | private IWaylineJobMapper waylineJobMapper; |
| | | |
| | | @Autowired |
| | | private IWaylineJobBreakPointMapper jobBreakPointMapper; |
| | | @Autowired |
| | | private TerritoryConfigPojo territoryConfigPojo; |
| | | @Autowired |
| | |
| | | private IDeviceMapper deviceMapper; |
| | | @Autowired |
| | | private DbUploadMapper dbUploadMapper; |
| | | |
| | | /** |
| | | * 定时器,将没有规划的图斑生成航线,并将航线飞完后的成果数据进行保存推送 |
| | | * |
| | |
| | | executor.shutdown(); |
| | | } |
| | | |
| | | @Scheduled(cron = "0 45 8-18 * * ?") |
| | | public void runTask() throws SQLException { |
| | | WaylineJobEntity job = processWaylineJobs(); |
| | | if (job != null) { |
| | | // 调用其他方法进行后续处理 |
| | | handleJobId(job); |
| | | } else { |
| | | System.out.println("未找到符合条件的对象"); |
| | | } |
| | | } |
| | | // public void myTask3() throws SQLException { |
| | | // String workspaceId = "4a574db8-4ad3-48f7-9f16-3edbcd8056e1"; |
| | | // String name = getNowDay(); |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 3 17 * * ?") |
| | | public void GtdbOperation() throws Exception { |
| | | String taskId = ""; |
| | |
| | | * @return |
| | | */ |
| | | public WaylineFileEntity backWayline(MultipartFile multipartFile, String waylineName, String workspaceId, String username) { |
| | | waylineFileService.importKmzFileBack(multipartFile, workspaceId, username); |
| | | waylineFileService.importKmzFileBack(multipartFile, workspaceId, username, 1); |
| | | WaylineFileEntity entity = waylineFileService.selectByName(waylineName); |
| | | try { |
| | | waylineFileService.getObjectUrl(workspaceId, entity.getWaylineId()); |
| | |
| | | .eq(LotInfo::getWorkspaceId, workspaceId)); |
| | | return groupTasks(list); |
| | | } |
| | | |
| | | public List<List<LotInfo>> getNoPush() { |
| | | List<LotInfo> list = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>() |
| | | .eq(LotInfo::getIsPush, 0) |
| | |
| | | DeviceEntity entity= deviceMapper.selectOne(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getDeviceSn,docksn)); |
| | | return entity.getWorkspaceId(); |
| | | } |
| | | |
| | | public static void sendPostWithParameters(String name, String fileId, String time, List<Long> taskDays, List<List<Long>> taskPeriods) throws IOException { |
| | | try { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | |
| | | throw new RuntimeException("Db文件复制失败", e); // 捕获并抛出原始异常 |
| | | } |
| | | } |
| | | |
| | | public String dbSaveGt(String path, String folder, String taskId) { |
| | | try { |
| | | String fileName = taskId + ".db"; |
| | |
| | | } |
| | | return folder; |
| | | } |
| | | |
| | | private static File fileFold(String fold,String taskId) { |
| | | // 获取当前时间 |
| | | LocalDateTime currentTime = LocalDateTime.now(); |
| | |
| | | } |
| | | return folder; |
| | | } |
| | | |
| | | public static Long getCurrentTimestampPlus8Hours(long hours) { |
| | | // 获取当前时间 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | |
| | | // 将毫秒级时间戳转换为秒级时间戳 |
| | | return timestamp / 1000; |
| | | } |
| | | |
| | | public static long getNextDayEightAMTimestamp(int hour) { |
| | | // 获取当前时间 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | |
| | | // 获取第二天的日期并设置时间为08:00 |
| | | LocalDateTime nextDayEightAM = now.plusDays(1).withHour(8).withMinute(0).withSecond(0).withNano(0); |
| | | LocalDateTime nextDayEightAM = now.plusDays(1).withHour(8).withMinute(30).withSecond(0).withNano(0); |
| | | |
| | | // 根据传入的hour参数增加小时 |
| | | LocalDateTime adjustedTime = nextDayEightAM.plusHours(hour); |
| | |
| | | return zonedDateTime.toEpochSecond(); |
| | | } |
| | | |
| | | public static long getAdjustedTimestamp(int hour) { |
| | | // 获取当前时间 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | |
| | | // 根据传入的hour参数增加小时 |
| | | LocalDateTime adjustedTime = now.plusSeconds(hour); |
| | | |
| | | // 转换为时间戳(秒级) |
| | | ZonedDateTime zonedDateTime = adjustedTime.atZone(ZoneId.systemDefault()); |
| | | return zonedDateTime.toEpochSecond(); |
| | | } |
| | | public static Long addOneHourToTimestamp(Long timestampInSeconds, long hours, long min) { |
| | | // 将输入的秒级时间戳转换为Instant对象 |
| | | Instant instant = Instant.ofEpochSecond(timestampInSeconds); |
| | |
| | | // 格式化时间,生成当前时间 |
| | | return currentTime.format(DateTimeFormatter.ofPattern("MMddHHmmssSSS")); |
| | | } |
| | | |
| | | public static long getFileSize(File file) { |
| | | if (file == null || !file.exists() || !file.isFile()) { |
| | | return -1L; // 文件不存在或不是普通文件 |
| | |
| | | long size = getFileSize(file); |
| | | System.out.println("文件大小: " + size + " 字节"); |
| | | } |
| | | |
| | | public static void getFileInfo(File file){ |
| | | long size=getFileSize(file); |
| | | |
| | | } |
| | | |
| | | public WaylineJobEntity processWaylineJobs() { |
| | | // 获取昨天 00:00 和 23:59:59 的时间戳 |
| | | LocalDate yesterday = LocalDate.now().minusDays(1); |
| | | long startOfDayMillis = LocalDateTime.of(yesterday, LocalTime.MIN).toInstant(ZoneOffset.UTC).toEpochMilli(); |
| | | long endOfDayMillis = LocalDateTime.of(yesterday, LocalTime.MAX).toInstant(ZoneOffset.UTC).toEpochMilli(); |
| | | // 查询符合条件的 wayline_job_break_point 对象 |
| | | List<WaylineJobBreakPointEntity> breakPoints = jobBreakPointMapper.selectList( |
| | | new LambdaQueryWrapper<WaylineJobBreakPointEntity>() |
| | | .ge(WaylineJobBreakPointEntity::getCreateTime, startOfDayMillis) |
| | | .le(WaylineJobBreakPointEntity::getCreateTime, endOfDayMillis) |
| | | .like(WaylineJobBreakPointEntity::getJobId, "~") |
| | | .orderByAsc(WaylineJobBreakPointEntity::getCreateTime) |
| | | ); |
| | | |
| | | for (WaylineJobBreakPointEntity breakPoint : breakPoints) { |
| | | String jobId = breakPoint.getJobId(); |
| | | |
| | | // 根据 jobId 查询 wayline_job 表 |
| | | WaylineJobEntity job = waylineJobMapper.selectOne( |
| | | new LambdaQueryWrapper<WaylineJobEntity>() |
| | | .eq(WaylineJobEntity::getJobId, jobId) |
| | | ); |
| | | |
| | | // 检查 statues 是否等于 3 |
| | | if (job != null && job.getStatus() != 3) { |
| | | // 返回符合条件的对象 |
| | | return job; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private void handleJobId(WaylineJobEntity entity) throws SQLException { |
| | | Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobId(entity.getWorkspaceId(), entity.getJobId(),true); |
| | | waylineJobService.publishOneFlightTask(waylineJobDTO.get()); |
| | | } |
| | | } |