From 914a1a800b7f8758cfd4d08704e8bbd0cf3e83be Mon Sep 17 00:00:00 2001
From: aix <vip_xiaobin810@163.com>
Date: Mon, 15 Jul 2024 14:05:19 +0800
Subject: [PATCH] 航线云台俯仰角事件
---
src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java | 111 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 77 insertions(+), 34 deletions(-)
diff --git a/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java b/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
index 3f2c128..f1ba312 100644
--- a/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
+++ b/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -1,12 +1,14 @@
package com.dji.sample.patches.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dji.sample.common.model.Pagination;
import com.dji.sample.common.model.PaginationData;
import com.dji.sample.media.dao.IFileMapper;
+import com.dji.sample.media.dao.IMarkMapper;
import com.dji.sample.media.model.MediaFileEntity;
+import com.dji.sample.media.model.MediaFileMarkEntity;
import com.dji.sample.patches.dao.GetPatchesMapper;
import com.dji.sample.patches.model.Param.PatchesParam;
import com.dji.sample.patches.model.entity.LotInfo;
@@ -16,8 +18,9 @@
import org.springframework.stereotype.Service;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Objects;
+import java.util.Map;
import java.util.stream.Collectors;
@Service
@@ -26,6 +29,8 @@
private GetPatchesMapper mapper;
@Autowired
private IFileMapper fileMapper;
+ @Autowired
+ private IMarkMapper markMapper;
/**
* 分页获取数据的接口实现。
@@ -88,52 +93,90 @@
return mapper.deleteById(id);
}
-
- /**
- * 根据条件获取照片的分页数据
- *
- * @param param 包含分页信息和查询条件的参数对象
- * @param dkbh 查询条件中带有地块编号关键字,用于文件名的模糊搜索
- * @return 返回照片的分页数据,包括分页信息和照片实体列表
- */
@Override
- public PaginationData<MediaFileEntity> getPhoto(PatchesParam param, String dkbh) {
- Page<MediaFileEntity> page = fileMapper.selectPage(new Page<MediaFileEntity>(param.getPage(), param.getPageSize()),
- new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "~" + "%"));
- List<MediaFileEntity> records = page.getRecords()
- .stream()
- .collect(Collectors.toList());
- return new PaginationData<MediaFileEntity>(records, new Pagination(page));
+ public PaginationData getPhoto(PatchesParam param, String dkbh) {
+ LotInfo lotInfo = getLotinfoToDb(dkbh);
+ int statue = lotInfo.getIsPush();
+
+ if (statue == 1) {
+ List<MediaFileMarkEntity> allResults = markMapper.selectList(
+ new LambdaQueryWrapper<MediaFileMarkEntity>().like(MediaFileMarkEntity::getFileName, "%" + dkbh + "~" + "%"));
+
+ // 去重处理
+ Map<String, MediaFileMarkEntity> uniqueFileMap = new LinkedHashMap<>();
+ List<MediaFileMarkEntity> uniqueResults = allResults.stream()
+ .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null)
+ .collect(Collectors.toList());
+
+ // 计算分页信息
+ int total = uniqueResults.size();
+ int start = (param.getPage() - 1) * param.getPageSize();
+ int end = Math.min(start + param.getPageSize(), total);
+
+ // 获取当前页的结果
+ List<MediaFileMarkEntity> pageResults = uniqueResults.subList(start, end);
+
+ // 创建临时的 Page 对象
+ Page<MediaFileMarkEntity> resultPage = new Page<>(param.getPage(), param.getPageSize());
+ resultPage.setRecords(pageResults);
+ resultPage.setTotal(total);
+
+ // 返回分页数据
+ return new PaginationData<>(pageResults, new Pagination(resultPage));
+ } else {
+ List<MediaFileEntity> allResults = fileMapper.selectList(
+ new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "~" + "%"));
+
+ // 去重处理
+ Map<String, MediaFileEntity> uniqueFileMap = new LinkedHashMap<>();
+ List<MediaFileEntity> uniqueResults = allResults.stream()
+ .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null)
+ .collect(Collectors.toList());
+
+ // 计算分页信息
+ int total = uniqueResults.size();
+ int start = (param.getPage() - 1) * param.getPageSize();
+ int end = Math.min(start + param.getPageSize(), total);
+
+ // 获取当前页的结果
+ List<MediaFileEntity> pageResults = uniqueResults.subList(start, end);
+
+ // 创建临时的 Page 对象
+ Page<MediaFileEntity> resultPage = new Page<>(param.getPage(), param.getPageSize());
+ resultPage.setRecords(pageResults);
+ resultPage.setTotal(total);
+
+ // 返回分页数据
+ return new PaginationData<>(pageResults, new Pagination(resultPage));
+ }
}
- /**
- * 根据条件获取照片的分页数据
- *
- * @param workspaceId 工作空间的ID,用于指定查询的工作空间
- * @param dkbh 查询条件中带有地块编号关键字,用于文件名的模糊搜索
- * @return 返回照片的分页数据,包括分页信息和照片实体列表
- */
+
+
public List<MediaFileEntity> listPohto(String dkbh, String workspaceId) {
return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%")
.eq(MediaFileEntity::getWorkspaceId, workspaceId));
}
-
- /**
- * 根据地块编号和工作空间ID获取地块信息。
- *
- * @param dkbh 地块编号,用于查询特定定单的地块信息。
- * @param workspaceId 工作空间ID,用于查询属于特定工作空间的地块信息。
- * @return 返回匹配给定地块编号和工作空间ID的地块信息对象。如果找不到匹配的记录,则返回null。
- */
public LotInfo getLotinfo(String dkbh, String workspaceId) {
return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)
.eq(LotInfo::getWorkspaceId, workspaceId));
}
-
+ public void patchesPushed(String taskId, String dkbh, String workspaceId) {
+ LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
+ updateWrapper.set(LotInfo::getIsPush, 1)
+ .eq(LotInfo::getWorkspaceId, workspaceId)
+ .eq(LotInfo::getDkbh, dkbh)
+ .eq(LotInfo::getTaskId, taskId);
+ mapper.update(null, updateWrapper);
+ }
public LotInfo getLotinfoToDb(String dkbh) {
return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh));
}
-
+ public List<LotInfo> getLotInfosByIds(List<Integer> ids) {
+ LambdaQueryWrapper<LotInfo> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.in(LotInfo::getId, ids);
+ return mapper.selectList(queryWrapper);
+ }
public List<LotInfo> listLotinfo() {
return mapper.selectList(null);
}
--
Gitblit v1.9.3