diff --git a/src/main/java/com/bonus/imgTool/backstage/controller/DownloadController.java b/src/main/java/com/bonus/imgTool/backstage/controller/DownloadController.java index 155c834..b181660 100644 --- a/src/main/java/com/bonus/imgTool/backstage/controller/DownloadController.java +++ b/src/main/java/com/bonus/imgTool/backstage/controller/DownloadController.java @@ -23,7 +23,7 @@ import java.util.Map; * @author:cwchen * @date:2025-04-07-13:23 * @version:1.0 - * @description:文件下载 + * @description:原图/水印图片文件下载 */ @RestController @RequestMapping("/api/download") diff --git a/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java b/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java index c932bd6..285cb84 100644 --- a/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java +++ b/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java @@ -132,4 +132,22 @@ public interface SynthesisQueryDao { * @date 2025/4/8 9:37 */ void addTaskDownload(@Param("taskId") String taskId, @Param("nowTime") String nowTime,@Param("filePath") String filePath); + + /** + * 查询图片未生成水印照片的数据 + * @param proId + * @return List + * @author cwchen + * @date 2025/4/8 16:32 + */ + List generateWatermark(String proId); + + /** + * 批量更新水印照片地址 + * @param list + * @return void + * @author cwchen + * @date 2025/4/8 16:40 + */ + void updateBatchSyData(List list); } diff --git a/src/main/java/com/bonus/imgTool/backstage/service/DownloadService.java b/src/main/java/com/bonus/imgTool/backstage/service/DownloadService.java index decfb34..b059803 100644 --- a/src/main/java/com/bonus/imgTool/backstage/service/DownloadService.java +++ b/src/main/java/com/bonus/imgTool/backstage/service/DownloadService.java @@ -2,9 +2,11 @@ package com.bonus.imgTool.backstage.service; import com.bonus.imgTool.backstage.dao.SynthesisQueryDao; import com.bonus.imgTool.backstage.entity.Photo; -import com.bonus.imgTool.backstage.entity.ProClassifyStatisticDetailVo; +import com.bonus.imgTool.backstage.entity.SynthesisQueryVo; import com.bonus.imgTool.utils.DateTimeHelper; +import com.bonus.imgTool.utils.HighQualityWatermark; import com.bonus.imgTool.utils.SystemUtils; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +23,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -60,6 +63,10 @@ public class DownloadService { tempDirPath = Paths.get(tempDir, taskId); Files.createDirectories(tempDirPath); Path zipFilePath = tempDirPath.resolve(proName + ".zip"); + // 生成图片水印 + if(Objects.equals(type,"2")){ + generateWatermark(proId); + } // 获取照片列表 List photos = getPhotosForAlbum(proId,type); int total = photos.size(); @@ -143,6 +150,43 @@ public class DownloadService { return filePath != null ? new File(filePath) : null; } + private void generateWatermark(String proId) { + try { + // 查询图片未生成水印照片的数据 + List list = Optional.ofNullable(synthesisQueryDao.generateWatermark(proId)).orElseGet(ArrayList::new); + list.forEach(item->{ + String path = SystemUtils.getUploadPath() + item.getOriginalFilePath(); + if (new File(path).exists()) { + String syPath = generateWatermarkData(item); + item.setWatermarkFilePath(syPath); + } + }); + if(CollectionUtils.isNotEmpty(list)){ + synthesisQueryDao.updateBatchSyData(list); + } + } catch (Exception e) { + logger.error(e.toString(),e); + } + } + + public String generateWatermarkData(SynthesisQueryVo vo){ + // 准备多行水印文本 + List watermarkLines = new ArrayList<>(); + String uploadTime = new SimpleDateFormat("yyyy-MM-dd").format(vo.getUploadTime()); + watermarkLines.add(uploadTime); + watermarkLines.add(vo.getProName().replaceAll("(.{18})", "$1@@")); + watermarkLines.add(vo.getUploadTypeName()); + String sourceTypeName = null; + if (Objects.equals(vo.getSourceType(), "9")) { + sourceTypeName = vo.getTitle(); + } else { + sourceTypeName = vo.getSourceTypeName().split("-")[1]; + } + watermarkLines.add(sourceTypeName); + String localPath = SystemUtils.getUploadPath() +File.separator+ vo.getOriginalFilePath(); + return HighQualityWatermark.generateWatermark(watermarkLines,localPath); + } + private List getPhotosForAlbum(String proId,String type) { // 实现获取照片列表的逻辑 // 返回包含所有照片路径的列表 @@ -176,4 +220,5 @@ public class DownloadService { void onComplete(String taskId, String downloadUrl); void onError(String taskId, String message); } + } diff --git a/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml b/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml index 53b4b8c..2375fb7 100644 --- a/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml +++ b/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml @@ -418,7 +418,7 @@ AND tcq.is_active = '1' - ORDER BY tcq.update_time DESC + ORDER BY tcq.create_time DESC + + @@ -512,4 +536,12 @@ where id = #{id} + + + + UPDATE sys_file_resource + SET watermark_file_path = #{item.watermarkFilePath} + WHERE id = #{item.id} + + diff --git a/src/main/resources/static/img/synthesisQuery/refresh-icon.png b/src/main/resources/static/img/synthesisQuery/refresh-icon.png new file mode 100644 index 0000000..a2db93f Binary files /dev/null and b/src/main/resources/static/img/synthesisQuery/refresh-icon.png differ diff --git a/src/main/resources/static/js/synthesisQuery/synthesisQuery.js b/src/main/resources/static/js/synthesisQuery/synthesisQuery.js index 8c8b751..e9482a9 100644 --- a/src/main/resources/static/js/synthesisQuery/synthesisQuery.js +++ b/src/main/resources/static/js/synthesisQuery/synthesisQuery.js @@ -248,3 +248,20 @@ function resetData() { $(this).removeClass('type-num-check'); }) } + +/**刷新数据*/ +function refreshData(){ + layer.msg("数据刷新中,请稍候...", {icon: 16, scrollbar: false, time: 1000,}); + pageNum = 1; + $('#keyWord').val(''); + highSearchData = {}; + $('.type-num').each(function () { + $(this).removeClass('type-num-check'); + }) + initImgNum(); + dataFlow({ + pageNum: pageNum, + pageSize: pageSize, + queryType: queryType + }); +} \ No newline at end of file diff --git a/src/main/resources/static/pages/synthesisQuery/fileDownload.html b/src/main/resources/static/pages/synthesisQuery/fileDownload.html index 5f2d451..6b1cf64 100644 --- a/src/main/resources/static/pages/synthesisQuery/fileDownload.html +++ b/src/main/resources/static/pages/synthesisQuery/fileDownload.html @@ -66,8 +66,8 @@ } -

照片下载中心

-

点击下方按钮下载所有照片

+

+

点击下方按钮下载所有照片(请勿关闭浏览器和浏览器窗口)

diff --git a/src/main/resources/static/pages/synthesisQuery/synthesisQuery.html b/src/main/resources/static/pages/synthesisQuery/synthesisQuery.html index 6cb49a1..3623eb0 100644 --- a/src/main/resources/static/pages/synthesisQuery/synthesisQuery.html +++ b/src/main/resources/static/pages/synthesisQuery/synthesisQuery.html @@ -18,7 +18,7 @@