rain
2024-07-31 4e8892f75a0d9b76e147cccdb1f188c272aed4c5
src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -18,7 +18,9 @@
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@@ -65,6 +67,12 @@
        if (param.getBsm() != null && !param.getBsm().isEmpty()) {
            queryWrapper.like(LotInfo::getXmc, param.getBsm());
        }
        if (param.getDkmj()!=null){
            queryWrapper.eq(LotInfo::getDkmj,param.getDkmj());
        }
        if (param.getIsPush() != null) {
            queryWrapper.eq(LotInfo::getIsPush, param.getIsPush());
        }
        // 执行分页查询
        Page<LotInfo> resultPage = mapper.selectPage(page, queryWrapper);
@@ -93,28 +101,71 @@
    @Override
    public PaginationData getPhoto(PatchesParam param, String dkbh) {
        LotInfo lotInfo=getLotinfoToDb(dkbh);
        int statue=lotInfo.getIsPush();
        if (statue==1){
            Page<MediaFileMarkEntity> page = markMapper.selectPage(new Page<MediaFileMarkEntity>(param.getPage(), param.getPageSize()),
                    new LambdaQueryWrapper<MediaFileMarkEntity>().like(MediaFileMarkEntity::getFileName, "%" + dkbh + "~" + "%"));
            List<MediaFileMarkEntity> records = page.getRecords()
                    .stream()
                    .collect(Collectors.toList());
            return new PaginationData<MediaFileMarkEntity>(records, new Pagination(page));}
        else {
            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));}
//        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));
        }
//    }
    public List<MediaFileEntity> listPohto(String dkbh, String workspaceId) {
        return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%")
                .eq(MediaFileEntity::getWorkspaceId, workspaceId));
                .eq(MediaFileEntity::getWorkspaceId, workspaceId)
                .eq(MediaFileEntity::getExamine,1));
    }
    public LotInfo getLotinfo(String dkbh, String workspaceId) {
        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)
@@ -131,9 +182,13 @@
    public LotInfo getLotinfoToDb(String dkbh) {
        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh));
    }
    public List<LotInfo> listLotinfo() {
        return mapper.selectList(null);
    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(String workspaceId) {
        return mapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getWorkspaceId,workspaceId));
    }
    @Override
    public LotInfo getPatchesFromId(String patchesId){