From 07ca844b3441a2774a1ca02a952e27e3fe986819 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 19 二月 2025 17:50:44 +0800
Subject: [PATCH] jtt808初始化

---
 server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java |   66 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 1 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java
index b4b873a..63c8345 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java
@@ -1,5 +1,8 @@
 package com.doumee.service.business.impl;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
 import com.doumee.core.model.LoginUserInfo;
+import com.doumee.core.wx.WxMiniConfig;
 import com.google.common.collect.Lists;
 
 import com.doumee.biz.system.SystemDictDataBiz;
@@ -22,12 +25,22 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.doumee.service.business.SitesService;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -128,7 +141,10 @@
             // 妫�鏌ユ槸鍚︽湁鍥剧墖淇℃伅娌℃湁鏇存柊淇濆瓨鍥剧墖
             locksList.forEach(s-> {
                 if (StringUtils.isBlank(s.getInfo())){
-                    wxMiniUtilService.generateWXMiniCode(s,systemDictData,prePath,code);
+                    try {
+                        wxMiniUtilService.generateWXMiniCode(s, WxMiniConfig.wxMaService.getAccessToken(),prePath,code);
+                    }catch (Exception e){
+                    }
                     s.setEditor(loginUserInfo.getId());
                     s.setEditDate(new Date());
                     updateById(s);
@@ -139,6 +155,7 @@
         }
         return new ArrayList<>();
     }
+
 
     @Override
     public PageData<Locks> findPage(PageWrap<Locks> pageWrap) {
@@ -170,6 +187,53 @@
         QueryWrapper<Locks> wrapper = new QueryWrapper<>(locks);
         return locksMapper.selectCount(wrapper);
     }
+    public static void packFilesToZip(List<File> files,    ServletOutputStream os) throws IOException {
+        try (ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(os)) {
+            for (File file : files) {
+                ZipArchiveEntry entry = new ZipArchiveEntry(file.getName());
+                zipOutputStream.putArchiveEntry(entry);
+                try (FileInputStream fileInputStream = new FileInputStream(file)) {
+                    byte[] buffer = new byte[1024];
+                    int length;
+                    while ((length = fileInputStream.read(buffer)) > 0) {
+                        zipOutputStream.write(buffer, 0, length);
+                    }
+                }
+                zipOutputStream.closeArchiveEntry();
+            }
+        }
+    }
+    @Override
+    public void  exportImages(String siteId, HttpServletResponse response) {
+        try {
+            List<File> fileList = new ArrayList<>();
+            List<Locks> locks = locksJoinMapper.selectList(new QueryWrapper<Locks>().lambda().eq(Locks::getSiteId,siteId).isNotNull(Locks::getInfo));
+            if(locks== null || locks.size() == 0){
+                throw  new BusinessException(ResponseStatus.DATA_EMPTY);
+            }
+            String path = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.IMG_DIR).getCode()+systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode();
+            for(Locks l : locks){
+                if(StringUtils.isNotBlank(l.getInfo())){
+                    File file = new File(path + l.getInfo());
+                    if(file!=null && file.isFile()){
+                        fileList.add(file);
+                    }
+                }
+            }
+            if(fileList == null || fileList.size() == 0){
+                throw  new BusinessException(ResponseStatus.DATA_EMPTY);
+            }
+            String fileName =  "绔欑偣銆�"+siteId+"銆戝皬绋嬪簭鐮佹壒閲忓鍑篲"+System.currentTimeMillis()+".zip" ;
+            String encodeFileName = URLEncoder.encode(fileName);
+            response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName);
+            response.setContentType("application/octet-stream");
+            response.setHeader("eva-opera-type", "download");
+            response.setHeader("eva-download-filename", encodeFileName);
+            packFilesToZip(fileList,response.getOutputStream());
+        } catch (IOException e) {
+            throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+        }
+    }
 
 
 }

--
Gitblit v1.9.3