| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.component.redis.RedisOpsUtils; |
| | | import com.dji.sample.droneairport.dao.DbUploadMapper; |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.ZonedDateTime; |
| | | import java.time.*; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | String waylineName = TimerUtil.getTimeName(); |
| | | MultipartFile multipartFile = timerUtil.getFile(waylineName, lotInfosForAirport, airport.getLat(), airport.getLon()); |
| | | WaylineFileEntity waylineFile = timerUtil.backWayline(multipartFile, waylineName, airport.getWorkspaceId(), username); |
| | | Long time = getNextDayEightAMTimestamp(countDistinctTaskIdsForToday(airport.getWorkspaceId())); |
| | | Long time = getNextDayEightAMTimestamp(getDistinctTaskIdCount(airport.getWorkspaceId())); |
| | | List<List<Long>> listOfLists = new ArrayList<>(); |
| | | List<Long> sublist = new ArrayList<>(); |
| | | sublist.add(time); |
| | |
| | | WaylineFileEntity waylineFile = timerUtil.backWayline(multipartFile, waylineName, airport.getWorkspaceId(), username); |
| | | |
| | | // 将为规划的图斑状态更新为已规划 |
| | | Long time = getNextDayEightAMTimestamp(countDistinctTaskIdsForToday(airport.getWorkspaceId())); |
| | | Long time = getNextDayEightAMTimestamp(getDistinctTaskIdCount(airport.getWorkspaceId())); |
| | | List<List<Long>> listOfLists = new ArrayList<>(); |
| | | List<Long> sublist = new ArrayList<>(); |
| | | sublist.add(time); |
| | |
| | | public String findDbFilesByTaskId(String taskId) { |
| | | DbUploadEntity entity = dbUploadMapper.selectOne(new LambdaQueryWrapper<DbUploadEntity>() |
| | | .eq(DbUploadEntity::getTaskId, taskId)); |
| | | if (entity!=null){ |
| | | DbUploadDto dto=DbEntityToDto(entity); |
| | | return SM4Util.encrypt("jsimjrby3wqb7dbq",buildRequestBody(dto)); |
| | | if (entity != null) { |
| | | DbUploadDto dto = DbEntityToDto(entity); |
| | | return SM4Util.encrypt("jsimjrby3wqb7dbq", buildRequestBody(dto)); |
| | | } |
| | | return null; |
| | | |
| | |
| | | dto.setUrl(entity.getUrl()); |
| | | return dto; |
| | | } |
| | | |
| | | public void delTaskInfo(String taskId) { |
| | | taskInfoMapper.delete(new LambdaUpdateWrapper<TaskInfo>().eq(TaskInfo::getTaskId, taskId)); |
| | | } |
| | |
| | | // 调用 update 方法进行更新操作 |
| | | waylineJobMapper.update(null, updateWrapper); |
| | | } |
| | | public int countDistinctTaskIdsForToday(String workspaceId) { |
| | | // 获取当天的开始和结束时间戳 |
| | | long startOfDay = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
| | | long startOfNextDay = LocalDate.now().plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
| | | |
| | | // 查询数据库,计算不同 taskId 的数量 |
| | | return patchesMapper.selectCount(new LambdaQueryWrapper<LotInfo>() |
| | | .eq(LotInfo::getWorkspaceId, workspaceId) |
| | | .ge(LotInfo::getCreateTime, startOfDay) |
| | | .lt(LotInfo::getCreateTime, startOfNextDay) |
| | | .select(LotInfo::getTaskId) |
| | | .groupBy(LotInfo::getTaskId) |
| | | ); |
| | | /** |
| | | * 统计给定工作空间下,创建时间为当天的不同 taskId 的数量。 |
| | | * |
| | | * @param workspaceId 工作空间 ID |
| | | * @return 不同 taskId 的数量 |
| | | */ |
| | | public Integer getDistinctTaskIdCount(String workspaceId) { |
| | | // 获取当前日期的开始和结束时间 |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDateTime startTime = today.atStartOfDay(); |
| | | LocalDateTime endTime = today.plusDays(1).atStartOfDay(); |
| | | |
| | | // 转换为毫秒时间戳 |
| | | long startTimestamp = startTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
| | | long endTimestamp = endTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
| | | |
| | | // 使用 LambdaQueryWrapper 进行查询 |
| | | LambdaQueryWrapper<LotInfo> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.eq(LotInfo::getWorkspaceId, workspaceId) |
| | | .ge(LotInfo::getCreateTime, startTimestamp) |
| | | .lt(LotInfo::getCreateTime, endTimestamp); |
| | | |
| | | // 获取符合条件的所有 taskId |
| | | Set<String> taskIdSet = patchesMapper.selectList(queryWrapper).stream() |
| | | .map(LotInfo::getTaskId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | // 返回不同 taskId 的数量 |
| | | return taskIdSet.size(); |
| | | } |
| | | |
| | | |
| | | } |