From 00d1b6c654639b53d47af1c456037ea6e84099b4 Mon Sep 17 00:00:00 2001 From: zhangqinbin <181961702@qq.com> Date: Thu, 21 Dec 2023 16:57:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=91=8A=E7=BB=93=E6=9E=84=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ebtp/extend/wps/controller/WpsController.java | 6 +++++- .../extend/wps/service/impl/WpsServiceImpl.java | 13 ++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java index 6d7d087..9a02d4c 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java @@ -11,6 +11,7 @@ import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum; import com.chinaunicom.mall.ebtp.common.log.OperationLogDetail; import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogBusinessModule; import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogType; +import com.chinaunicom.mall.ebtp.extend.crypconfigure.crypto.tenderfee.test; import com.chinaunicom.mall.ebtp.extend.feign.client.UnicomOAuthClient; import com.chinaunicom.mall.ebtp.extend.shortmessage.utils.RSA; import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftFileSaveVo; @@ -273,9 +274,12 @@ public class WpsController { String text = " "; byte buf[] = text.getBytes(); try { - BufferedInputStream bis = new BufferedInputStream(new FileInputStream("text.doc")); + URL crt = test.class.getClassLoader().getResource("text.doc"); + File file = new File(crt.getPath()); + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); buf = IOUtils.toByteArray(bis); }catch (Exception e){ + log.error("读取异常",e); CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("模板文件读取异常",true); } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java index 078d1fa..8b9c76a 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java @@ -19,6 +19,7 @@ import com.chinaunicom.mall.ebtp.common.log.service.OperationLogService; import com.chinaunicom.mall.ebtp.common.uniBss.constant.UniBssConstant; import com.chinaunicom.mall.ebtp.common.uniBss.entity.UniBssAttached; import com.chinaunicom.mall.ebtp.common.util.HttpContextUtils; +import com.chinaunicom.mall.ebtp.extend.crypconfigure.crypto.tenderfee.test; import com.chinaunicom.mall.ebtp.extend.crypconfigure.util.SslUtil; import com.chinaunicom.mall.ebtp.extend.feign.client.UnicomOAuthClient; import com.chinaunicom.mall.ebtp.extend.shortmessage.utils.RSA; @@ -800,12 +801,10 @@ public class WpsServiceImpl implements WpsService { //System.out.println(URLEncoder.encode("hVLFkQhQkXI8w4RFE25zvCP9TKRZwT8Dqhxmi/PgDalGayE5SIjtyFBRpu6wuEqr7HvAIHm2Kc8+ahIUF7l8sc1PHYeCuEmgYEwzeosl1pT1yDyQ+KV6Q8REiufarAbZ1W9LEx70SBrtTXPKnEPi82njSv+CVrYqZCf6XZ/BINU=","utf-8")); - - String file = "17377117066807000001.doc"; - System.out.println("file"+file.split("\\.")[0]); - -// BufferedInputStream bis = new BufferedInputStream(new FileInputStream("E:\\工作\\联通\\文档\\3.0\\公告结构化\\文字文稿1.docx")); -// byte[] result = IOUtils.toByteArray(bis); -// System.out.println(result.length); + URL crt = test.class.getClassLoader().getResource("text.doc"); + File file = new File(crt.getPath()); + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); + byte[] result = IOUtils.toByteArray(bis); + System.out.println(result.length); } }