From 2db1aa88e8ab53096a936163d686b90d8e056a99 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Wed, 21 Aug 2024 23:18:33 +0800
Subject: [PATCH] 国土对接返回信息加密

---
 src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java |  119 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 94 insertions(+), 25 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 44db0c9..1207548 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,7 +1,6 @@
 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;
@@ -18,9 +17,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -67,6 +64,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);
@@ -95,32 +98,83 @@
 
     @Override
     public PaginationData getPhoto(PatchesParam param, String dkbh) {
-        LotInfo lotInfo=getLotinfoToDb(dkbh);
-        int statue=lotInfo.getIsPush();
-        if (statue==0){
-        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));}
-        else {
-            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));}
+//        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 List<MediaFileEntity> listPohto(String dkbh) {
+        return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%")
+                .eq(MediaFileEntity::getExamine,1));
     }
     public LotInfo getLotinfo(String dkbh, String workspaceId) {
         return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)
                 .eq(LotInfo::getWorkspaceId, workspaceId));
+    }
+
+    public LotInfo getLotinfo(String dkbh) {
+        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh));
     }
     public void patchesPushed(String taskId, String dkbh, String workspaceId) {
         LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
@@ -130,12 +184,23 @@
                 .eq(LotInfo::getTaskId, taskId);
         mapper.update(null, updateWrapper);
     }
+    public void patchesPushed(String taskId, String dkbh) {
+        LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(LotInfo::getIsPush, 1)
+                .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> 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){
@@ -147,4 +212,8 @@
             mapper.insert(list.get(i));
         }
     }
+    public List<LotInfo> getLotInfosByIDs(String idsStr) {
+        List<String> idList = Arrays.asList(idsStr.split(","));
+        return mapper.selectBatchIds(idList);
+    }
 }

--
Gitblit v1.9.3