From 61fe976781b4394d5360f9707ec26296746101d2 Mon Sep 17 00:00:00 2001 From: zhangyx <1254353766@qq.com> Date: Fri, 26 Mar 2021 09:11:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f2b90d5..027b4e3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: uat \ No newline at end of file + active: test \ No newline at end of file From d3a7638c2d2ffb644aa805d99dc28d282e34c1bf Mon Sep 17 00:00:00 2001 From: zhangyx <1254353766@qq.com> Date: Fri, 26 Mar 2021 09:58:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../export/enums/ExportExceptionEnum.java | 2 ++ .../impl/BizBidClientVersionServiceImpl.java | 29 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/export/enums/ExportExceptionEnum.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/export/enums/ExportExceptionEnum.java index e08bd87..99cba84 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/export/enums/ExportExceptionEnum.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/export/enums/ExportExceptionEnum.java @@ -21,6 +21,8 @@ public enum ExportExceptionEnum implements BusinessExceptionAssert { FRAME_EXCEPTION_GET_PROJECT_INFO(2200001, "获取项目信息失败"), + FRAME_EXCEPTION_GET_DOCUMENT_CENTER(2200009, "!"), + ; /** diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/impl/BizBidClientVersionServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/impl/BizBidClientVersionServiceImpl.java index 8d6377f..f7b6e38 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/impl/BizBidClientVersionServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/templatewarehouse/sevice/impl/BizBidClientVersionServiceImpl.java @@ -1,9 +1,12 @@ package com.chinaunicom.mall.ebtp.extend.templatewarehouse.sevice.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor; import com.chinaunicom.mall.ebtp.common.util.JsonUtils; +import com.chinaunicom.mall.ebtp.extend.export.enums.ExportExceptionEnum; import com.chinaunicom.mall.ebtp.extend.feign.client.DocumentCenterService; import com.chinaunicom.mall.ebtp.extend.templatewarehouse.entity.BizBidClientVersion; import lombok.RequiredArgsConstructor; @@ -21,6 +24,9 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; +import java.text.DateFormat; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -55,29 +61,38 @@ public class BizBidClientVersionServiceImpl extends BaseServiceImpl optionalBytes = modelConvertor.toByteArray(objectInfo); - log.info("文档中心文件下载返回数据转为byte[]数据:"+ optionalBytes.get()); +// log.info("文档中心文件下载返回数据转为byte[]数据:"+ new String(optionalBytes.get())); ServletOutputStream outputStream = response.getOutputStream(); - response.setContentType("application/octet-stream;charset=utf-8"); - response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("客户端配置文件", "utf-8")); +// response.setContentType("application/octet-stream;charset=utf-8"); + response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("AutoUpdater.xml", "utf-8")); if(optionalBytes.isPresent()){ outputStream.write(optionalBytes.get()); } + outputStream.flush(); + outputStream.close(); } public void downloadClientByOId(String objectId) throws IOException { log.info("文档中心s文件下载传入数据:"+ JsonUtils.objectToJson(objectId)); String objectInfo = documentCenterService.getObjectDetail(objectId); log.info("文档中心s文件下载返回数据:"+ JsonUtils.objectToJson(objectInfo)); + Map map = (Map) JSON.parse(objectInfo); + ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName("文档获取失败",!(map.containsKey("message") && map.containsKey("success"))); + ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName(map.get("message").toString(),!(boolean) map.get("success")); Optional optionalBytes = modelConvertor.toByteArray(objectInfo); - log.info("文档中心s文件下载返回数据转为byte[]数据:"+ optionalBytes.get()); - ByteArrayOutputStream fileStream = new ByteArrayOutputStream(); +// log.info("文档中心s文件下载返回数据转为byte[]数据:"+ optionalBytes.get()); ServletOutputStream outputStream = response.getOutputStream(); - response.setContentType("application/octet-stream;charset=utf-8"); - response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("客户端安装包", "utf-8")); +// response.setContentType("application/octet-stream;charset=utf-8"); + response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("ebtp-ca.zip", "utf-8")); if(optionalBytes.isPresent()){ outputStream.write(optionalBytes.get()); } + outputStream.flush(); + outputStream.close(); } }