| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.component.redis.RedisOpsUtils; |
| | | import com.dji.sample.droneairport.dao.DbUploadMapper; |
| | | import com.dji.sample.droneairport.dao.DeviceExpanSionMapper; |
| | | import com.dji.sample.droneairport.model.Entity.DbUploadEntity; |
| | | import com.dji.sample.droneairport.model.Entity.DeviceExpanSionEntity; |
| | | import com.dji.sample.droneairport.model.dto.*; |
| | | import com.dji.sample.droneairport.model.param.ReturnTaskParam; |
| | |
| | | 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.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.dji.sample.droneairport.utils.TaskAllocator.assignTasks; |
| | | import static com.dji.sample.patches.utils.TimerUtil.getCurrentTimestampPlus8Hours; |
| | | import static com.dji.sample.patches.utils.TimerUtil.getNextDayEightAMTimestamp; |
| | | |
| | | @Service |
| | | public class RegistServiceImpl implements RegistService { |
| | |
| | | private IWaylineJobMapper waylineJobMapper; |
| | | @Autowired |
| | | private IWaylineFileMapper fileMapper; |
| | | @Autowired |
| | | private DbUploadMapper dbUploadMapper; |
| | | |
| | | public String registPort(DeviceExpanSionEntity airport) { |
| | | try { |
| | | RegistDto registDto = airportEntityToDto(airport); |
| | | // 构建请求体 |
| | | String jsonBody = buildRequestBody(registDto); |
| | | // 设置请求头 |
| | | String base64 = SM4Util.encrypt("jsimjrby3wqb7dbq", jsonBody); |
| | | // 设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | |
| | | headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL)); |
| | | headers.set("Accept-Language", "zh-CN,zh;q=0.9"); |
| | | headers.setConnection("keep-alive"); |
| | | headers.set("x-lc-token", AuthUtil.getToken()); |
| | | headers.set("x-lc-secret", Utils.hexToBase64(Utils.encrypt("jsimjrby3wqb7dbq", "044D6061FC08A19D3F32CEAA8CF6679B40500008FD741FC26DE7E50AEBF3A9115D47274437730EADEDAEF0CCC4853C5F0B35B30C6AEA83A5F6FBCA4ABEAC9E3B98"))); |
| | | headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MjA2NTg3NDMsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDcwNTg3NDMsImlhdCI6MTcyMDY1ODc0MywidXNlcm5hbWUiOiJhZG1pbkRQIn0.CrRFYUTK357HleqrrfL7nLdwFJw5Bcv3ms33n_Or8eM"); |
| | | headers.set("x-lc-token", ""); |
| | | // 构建请求实体 |
| | | HttpEntity<String> requestEntity = new HttpEntity<>(base64, headers); |
| | | // 发送请求 |
| | | ResponseEntity<String> response = restTemplate.exchange( |
| | | "https://xcx.geoway.com.cn:8033/v1/droneAirport/RegistService", |
| | | "http://localhost:6789/droneAirport/test", |
| | | HttpMethod.POST, |
| | | requestEntity, |
| | | String.class); |
| | |
| | | } |
| | | } |
| | | |
| | | private String buildRequestBody(RegistDto dto) { |
| | | // private String buildRequestBody(RegistDto dto) { |
| | | // try { |
| | | // return objectMapper.writeValueAsString(dto); |
| | | // } catch (JsonProcessingException e) { |
| | | // throw new RuntimeException("数据有误", e); |
| | | // } |
| | | // } |
| | | |
| | | public <T> String buildRequestBody(T obj) { |
| | | try { |
| | | return objectMapper.writeValueAsString(dto); |
| | | return objectMapper.writeValueAsString(obj); |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException("数据有误", e); |
| | | throw new RuntimeException("对象转换为JSON字符串时发生错误", e); |
| | | } |
| | | } |
| | | |
| | |
| | | // 构建请求体 |
| | | String jsonBody = buildRequestBody(dto); |
| | | String base64 = SM4Util.encrypt("jsimjrby3wqb7dbq", jsonBody); |
| | | String secret = enSM2("jsimjrby3wqb7dbq", "044D6061FC08A19D3F32CEAA8CF6679B40500008FD741FC26DE7E50AEBF3A9115D47274437730EADEDAEF0CCC4853C5F0B35B30C6AEA83A5F6FBCA4ABEAC9E3B98"); |
| | | // 设置请求头 |
| | | |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL)); |
| | | headers.set("Accept-Language", "zh-CN,zh;q=0.9"); |
| | | headers.setConnection("keep-alive"); |
| | | headers.set("x-lc-token", AuthUtil.getToken()); |
| | | headers.set("x-lc-secret", secret); |
| | | |
| | | headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MjA2NTg3NDMsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDcwNTg3NDMsImlhdCI6MTcyMDY1ODc0MywidXNlcm5hbWUiOiJhZG1pbkRQIn0.CrRFYUTK357HleqrrfL7nLdwFJw5Bcv3ms33n_Or8eM"); |
| | | headers.set("x-lc-token", ""); |
| | | // 构建请求实体 |
| | | HttpEntity<String> requestEntity = new HttpEntity<>(base64, headers); |
| | | |
| | | // 发送请求 |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | String response = restTemplate.postForObject("https://xcx.geoway.com.cn:8033/v1/droneAirport/addDevice", requestEntity, String.class); |
| | | ResponseEntity<String> response = restTemplate.exchange( |
| | | "http://localhost:6789/droneAirport/test", |
| | | HttpMethod.POST, |
| | | requestEntity, |
| | | String.class); |
| | | registPort(airport); |
| | | return response; |
| | | return response.getBody(); |
| | | |
| | | } catch (Exception e) { |
| | | // 异常处理 |
| | |
| | | return SM4Screct; |
| | | } |
| | | |
| | | // @Override |
| | | // public ResponseResult authorization(String base64, String Secret) throws Exception { |
| | | // String sm4Secrect = deSM2(Secret, "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D"); |
| | | // String decryptedJson = SM4Util.decrypt(sm4Secrect, base64); |
| | | // JSONObject jsonObject = new JSONObject(decryptedJson); |
| | | // String deviceId = jsonObject.getStr("deviceid"); |
| | | // boolean online = redisService.checkDeviceOnline(deviceId); |
| | | // if (online) { |
| | | // return ResponseResult.success(200, "无人机机场授权成功!", "", ""); |
| | | // } |
| | | // return ResponseResult.error(500, "无人机机场授权失败!"); |
| | | // } |
| | | @Override |
| | | public ResponseResult authorization(String base64, String Secret) throws Exception { |
| | | String sm4Secrect = deSM2(Secret, "23E57DA1E4AB865CCBC325B668762207DEF74345B782237808AE0BABDF26734D"); |
| | | String decryptedJson = SM4Util.decrypt(sm4Secrect, base64); |
| | | JSONObject jsonObject = new JSONObject(decryptedJson); |
| | | String deviceId = jsonObject.getStr("deviceid"); |
| | | boolean online = redisService.checkDeviceOnline(deviceId); |
| | | if (online) { |
| | | return ResponseResult.success(200, "无人机机场授权成功!", "", ""); |
| | | public void noAuthorization(String sn) { |
| | | AuthorDto dto = new AuthorDto(); |
| | | dto.setSn(sn); |
| | | dto.setStatus(0); |
| | | String jsonBody = buildRequestBody(dto); |
| | | String base64 = SM4Util.encrypt("jsimjrby3wqb7dbq", jsonBody); |
| | | // 设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL)); |
| | | headers.set("Accept-Language", "zh-CN,zh;q=0.9"); |
| | | headers.setConnection("keep-alive"); |
| | | headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MjA2NTg3NDMsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDcwNTg3NDMsImlhdCI6MTcyMDY1ODc0MywidXNlcm5hbWUiOiJhZG1pbkRQIn0.CrRFYUTK357HleqrrfL7nLdwFJw5Bcv3ms33n_Or8eM"); |
| | | headers.set("x-lc-token", ""); |
| | | // 构建请求实体 |
| | | HttpEntity<String> requestEntity = new HttpEntity<>(base64, headers); |
| | | // 发送请求 |
| | | ResponseEntity<String> response = restTemplate.exchange( |
| | | "http://localhost:6789/droneAirport/test", |
| | | HttpMethod.POST, |
| | | requestEntity, |
| | | String.class); |
| | | } |
| | | return ResponseResult.error(500, "无人机机场授权失败!"); |
| | | |
| | | @Override |
| | | public void Authorization(String sn) { |
| | | AuthorDto dto = new AuthorDto(); |
| | | dto.setSn(sn); |
| | | dto.setStatus(1); |
| | | String jsonBody = buildRequestBody(dto); |
| | | String base64 = SM4Util.encrypt("jsimjrby3wqb7dbq", jsonBody); |
| | | // 设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL)); |
| | | headers.set("Accept-Language", "zh-CN,zh;q=0.9"); |
| | | headers.setConnection("keep-alive"); |
| | | headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MjA2NTg3NDMsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDcwNTg3NDMsImlhdCI6MTcyMDY1ODc0MywidXNlcm5hbWUiOiJhZG1pbkRQIn0.CrRFYUTK357HleqrrfL7nLdwFJw5Bcv3ms33n_Or8eM"); |
| | | headers.set("x-lc-token", ""); |
| | | // 构建请求实体 |
| | | HttpEntity<String> requestEntity = new HttpEntity<>(base64, headers); |
| | | // 发送请求 |
| | | ResponseEntity<String> response = restTemplate.exchange( |
| | | "http://localhost:6789/droneAirport/test", |
| | | HttpMethod.POST, |
| | | requestEntity, |
| | | String.class); |
| | | } |
| | | |
| | | @Override |
| | |
| | | for (TaskListDto taskListDto : tasklist) { |
| | | LotInfo lotInfo = convertToLotInfo(taskListDto); |
| | | lotInfo.setTaskId(taskId); |
| | | lotInfo.setType(0); |
| | | lotInfo.setType(1); |
| | | lotInfo.setTaskName(addTaskDto.getBizidname()); |
| | | lotInfo.setUserName(username); |
| | | lotInfos.add(lotInfo); |
| | |
| | | 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 = getCurrentTimestampPlus8Hours(14); |
| | | Long time = getNextDayEightAMTimestamp(countDistinctTaskIdsForToday(airport.getWorkspaceId())); |
| | | List<List<Long>> listOfLists = new ArrayList<>(); |
| | | List<Long> sublist = new ArrayList<>(); |
| | | sublist.add(time); |
| | |
| | | List<Long> lists1 = new ArrayList<>(); |
| | | lists1.add(time); |
| | | String times = TimerUtil.convertTimestampToFormattedString(time); |
| | | param.setJobId(taskId); |
| | | param.setJobId(SM4Util.encrypt("jsimjrby3wqb7dbq", taskId)); |
| | | timerUtil.sendPostWithParameters(waylineName, waylineFile.getWaylineId(), times, lists1, listOfLists, taskId + "~" + airport.getWorkspaceId(), airport.getDockSn()); |
| | | timerUtil.updatePatchesStatu(lotInfosForAirport); |
| | | } |
| | |
| | | for (TaskListDto taskListDto : tasklist) { |
| | | LotInfo lotInfo = convertToLotInfo(taskListDto); |
| | | lotInfo.setTaskId(taskId); |
| | | lotInfo.setType(0); |
| | | lotInfo.setType(1); |
| | | lotInfo.setTaskName(Bizidname); |
| | | lotInfo.setUserName(username); |
| | | lotInfos.add(lotInfo); |
| | |
| | | WaylineFileEntity waylineFile = timerUtil.backWayline(multipartFile, waylineName, airport.getWorkspaceId(), username); |
| | | |
| | | // 将为规划的图斑状态更新为已规划 |
| | | Long time = getCurrentTimestampPlus8Hours(14); |
| | | Long time = getNextDayEightAMTimestamp(countDistinctTaskIdsForToday(airport.getWorkspaceId())); |
| | | List<List<Long>> listOfLists = new ArrayList<>(); |
| | | List<Long> sublist = new ArrayList<>(); |
| | | sublist.add(time); |
| | |
| | | |
| | | @Override |
| | | public ResponseResult queryTaskStatus(String taskid) { |
| | | WaylineJobEntity jobEntity = waylineJobMapper.selectOne(new LambdaQueryWrapper<WaylineJobEntity>().eq(WaylineJobEntity::getJobId, taskid)); |
| | | if (jobEntity == null) { |
| | | List<WaylineJobEntity> jobEntity = waylineJobMapper.selectList(new LambdaQueryWrapper<WaylineJobEntity>().like(WaylineJobEntity::getJobId, taskid)); |
| | | |
| | | if (jobEntity == null || jobEntity.isEmpty()) { |
| | | return ResponseResult.error(201, "查询无人机机场任务状态失败!"); |
| | | } |
| | | int code = jobEntity.getStatus(); |
| | | |
| | | //1: 待执行; 2: 执行中; 3: 完成; 4: 取消; 5: 失败 |
| | | if (code == 1) { |
| | | return ResponseResult.success(200, "查询无人机机场任务状态成功!", "", ""); |
| | | } else if (code == 2) { |
| | | return ResponseResult.success(202, "查询无人机机场任务状态成功!", "", ""); |
| | | } else if (code == 3) { |
| | | return ResponseResult.success(203, "查询无人机机场任务状态成功!", "", ""); |
| | | } else if (code == 4) { |
| | | return ResponseResult.success(204, "查询无人机机场任务状态成功!", "", ""); |
| | | } else if (code == 5) { |
| | | return ResponseResult.success(205, "查询无人机机场任务状态成功!", "", ""); |
| | | } |
| | | return null; |
| | | } |
| | | // 检查是否所有 status 都等于 4 |
| | | boolean allStatusAreFour = jobEntity.stream() |
| | | .allMatch(job -> job.getStatus() == 4); |
| | | |
| | | private static final String BASE_DIR = "src/main/resources/tmp"; |
| | | // 检查是否所有 status 都等于 3 |
| | | boolean allStatusAreThree = jobEntity.stream() |
| | | .allMatch(job -> job.getStatus() == 3); |
| | | |
| | | if (allStatusAreFour) { |
| | | return ResponseResult.error(204, "查询无人机机场任务状态成功!"); |
| | | } else if (allStatusAreThree) { |
| | | return ResponseResult.error(200, "查询无人机机场任务状态成功!"); |
| | | } else { |
| | | return ResponseResult.error(202, "查询无人机机场任务状态成功!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据任务 ID 查找对应的 DB 文件路径 |
| | |
| | | * @param taskId 任务 ID |
| | | * @return 匹配的 DB 文件路径列表 |
| | | */ |
| | | public List<String> findDbFilesByTaskId(String taskId) { |
| | | List<String> dbFilePaths = new ArrayList<>(); |
| | | File baseDir = new File(BASE_DIR); |
| | | 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)); |
| | | } |
| | | return null; |
| | | |
| | | // 检查基础目录是否存在 |
| | | if (!baseDir.exists() || !baseDir.isDirectory()) { |
| | | throw new IllegalStateException("Base directory does not exist or is not a directory."); |
| | | // File baseDir = new File(BASE_DIR); |
| | | // |
| | | // // 检查基础目录是否存在并且是目录 |
| | | // if (!baseDir.exists() || !baseDir.isDirectory()) { |
| | | // throw new IllegalStateException("Base directory does not exist or is not a directory."); |
| | | // } |
| | | // |
| | | // // 构建文件路径 |
| | | // File targetDir = new File(baseDir, taskId); |
| | | // File dbFile = new File(targetDir, ".db"); |
| | | // |
| | | // // 如果文件存在,则返回文件路径 |
| | | // if (dbFile.exists()) { |
| | | // return dbFile.getAbsolutePath(); |
| | | // } |
| | | // |
| | | // return null; // 或者抛出异常,视需求而定 |
| | | } |
| | | |
| | | // 遍历基础目录下的所有文件夹 |
| | | File[] subDirs = baseDir.listFiles(File::isDirectory); |
| | | if (subDirs != null) { |
| | | for (File subDir : subDirs) { |
| | | // 如果文件夹名称包含任务 ID,则查找该文件夹中的 DB 文件 |
| | | if (subDir.getName().contains(taskId)) { |
| | | File[] files = subDir.listFiles((dir, name) -> name.endsWith(".db")); |
| | | if (files != null) { |
| | | for (File file : files) { |
| | | dbFilePaths.add(file.getAbsolutePath()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return dbFilePaths; |
| | | } |
| | | |
| | | public void delPatchesByTaskId(String taskId) { |
| | | patchesMapper.delete(new LambdaUpdateWrapper<LotInfo>().eq(LotInfo::getTaskId, taskId)); |
| | | } |
| | | |
| | | public DbUploadDto DbEntityToDto(DbUploadEntity entity) { |
| | | DbUploadDto dto = new DbUploadDto(); |
| | | dto.setAttachmentCount(entity.getAttachmentCount()); |
| | | dto.setCount(entity.getCount()); |
| | | dto.setSign(entity.getDataSign()); |
| | | dto.setExtension(entity.getExtension()); |
| | | dto.setHash(entity.getHash()); |
| | | dto.setRegioncode(entity.getRegioncode()); |
| | | dto.setTaskId(entity.getTaskId()); |
| | | dto.setKey(entity.getDecrypt()); |
| | | dto.setTimestamp(entity.getTimestamp()); |
| | | dto.setSize(entity.getSize()); |
| | | dto.setUrl(entity.getUrl()); |
| | | return dto; |
| | | } |
| | | public void delTaskInfo(String taskId) { |
| | | taskInfoMapper.delete(new LambdaUpdateWrapper<TaskInfo>().eq(TaskInfo::getTaskId, taskId)); |
| | | } |
| | | |
| | | private String buildRequestBody(AddDeviceDto dto) { |
| | | try { |
| | | return objectMapper.writeValueAsString(dto); |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException("数据有误", e); |
| | | } |
| | | } |
| | | // private String buildRequestBody(AddDeviceDto dto) { |
| | | // try { |
| | | // return objectMapper.writeValueAsString(dto); |
| | | // } catch (JsonProcessingException e) { |
| | | // throw new RuntimeException("数据有误", e); |
| | | // } |
| | | // } |
| | | |
| | | public String getWorkspaceId(String devicesn) { |
| | | DeviceEntity entity = deviceMapper.selectOne(new LambdaQueryWrapper<DeviceEntity>() |
| | |
| | | int mode; |
| | | int sne = osdDockReceiver.getModeCode().getVal(); |
| | | if (sne==0){ |
| | | mode=1; |
| | | } |
| | | else { |
| | | mode = 0; |
| | | } else { |
| | | mode=2; |
| | | } |
| | | DroneStateDto.DroneStateDtoBuilder builder = DroneStateDto.builder(); |
| | |
| | | // 调用 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) |
| | | ); |
| | | } |
| | | |
| | | } |