From 17d7043f10d55429db919238fe639bff1b51ec0e Mon Sep 17 00:00:00 2001 From: liukangdong <898885815@qq.com> Date: 星期五, 07 二月 2025 15:59:37 +0800 Subject: [PATCH] Merge branch '2.0.1' of http://139.186.142.91:10010/r/productDev/funingyunwei into 2.0.1 --- server/system_service/src/main/java/com/doumee/core/utils/Constants.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) diff --git a/server/system_service/src/main/java/com/doumee/core/utils/Constants.java b/server/system_service/src/main/java/com/doumee/core/utils/Constants.java index e6d936f..29ead0a 100644 --- a/server/system_service/src/main/java/com/doumee/core/utils/Constants.java +++ b/server/system_service/src/main/java/com/doumee/core/utils/Constants.java @@ -1,7 +1,10 @@ package com.doumee.core.utils; +import cn.hutool.core.io.IoUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.doumee.core.constants.ResponseStatus; +import com.doumee.core.exception.BusinessException; import com.doumee.core.model.LoginUserInfo; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; @@ -9,10 +12,16 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategy; import io.swagger.models.auth.In; import org.apache.batik.util.Platform; +import org.apache.commons.compress.archivers.zip.Zip64Mode; +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.apache.commons.lang3.StringUtils; import org.springframework.util.CollectionUtils; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.OutputStream; import java.math.BigDecimal; import java.net.URLDecoder; import java.text.SimpleDateFormat; @@ -52,6 +61,9 @@ public static final String YW_DEVICE ="YW_DEVICE" ; public static final String YW_PATROL ="YW_PATROL" ; public static final String YW_CONTRACT_BILL ="YW_CONTRACT_BILL" ; + public static final String YW_MATERIAL ="YW_MATERIAL" ; + public static final String YW_PROBLEM ="YW_PROBLEM" ; + public static final String YW_QUICK_MODEL ="YW_QUICK_MODEL" ; public static final String RESERVATION_TOTAL_NUM ="RESERVATION_TOTAL_NUM" ; public static final String SIGN_IN_PLACE_LAT ="SIGN_IN_PLACE_LAT" ; @@ -1385,6 +1397,9 @@ YW_CONTRACT_FILE(9, "鍚堝悓闄勪欢 ", "鍚堝悓闄勪欢 "), FN_CONTRACT_REVENUE_FILE(10, "鏀舵敮娴佹按闄勪欢 ", "鍚堝悓璐﹀崟闄勪欢 "), FN_PATROL_TASK_RECORD_FILE(11, "宸℃浠诲姟鐐瑰鐞嗛檮浠� ", "宸℃浠诲姟鐐瑰鐞嗛檮浠� "), + MATERIAL_FILE(12, "璧勪骇闄勪欢 ", "璧勪骇闄勪欢 "), + PROBLEM_FILE(13, "闂闄勪欢 ", "闂闄勪欢 "), + FN_DEVICE_MAINTENANCE_FILE(14, "闃滃畞鏈嶅姟骞冲彴璁惧鏂囦欢 ", "闃滃畞鏈嶅姟骞冲彴璁惧鏂囦欢 "), ; // 鎴愬憳鍙橀噺 @@ -1523,4 +1538,41 @@ } } + public static void packFilesToZip(List<File> files, OutputStream os) throws IOException { + try { + ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(os); + zipOutputStream.setUseZip64(Zip64Mode.AsNeeded); + for (File file : files) { + if(!file.exists()){ + System.out.println("===鏂囦欢涓嶅瓨鍦�======="+file.getPath()); + continue; + }else{ + System.out.println("===鏂囦欢瀛樺湪======="+file.getPath()); + } + ZipArchiveEntry entry = new ZipArchiveEntry(file.getName()); + zipOutputStream.putArchiveEntry(entry); + 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(); + zipOutputStream.flush(); + IoUtil.close(fileInputStream); + file.delete(); + } + }catch (Exception e){ + throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR.getCode(),"瀵逛笉璧凤紝涓嬭浇鍘嬬缉鏂囦欢澶辫触"); + }finally { + if (os != null) { + try { + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } -- Gitblit v1.9.3