From 2d93efd310612e24b99c8a487102638cfa3fbadf Mon Sep 17 00:00:00 2001
From: 18756 <1875631620@qq.com>
Date: 星期五, 23 八月 2024 16:29:24 +0800
Subject: [PATCH] 文档借阅功能8.23
---
src/main/java/com/product/file/service/FileManagerService.java | 50 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/product/file/service/FileManagerService.java b/src/main/java/com/product/file/service/FileManagerService.java
index 02613ba..9b9502f 100644
--- a/src/main/java/com/product/file/service/FileManagerService.java
+++ b/src/main/java/com/product/file/service/FileManagerService.java
@@ -232,6 +232,39 @@
return baseDao.executeUpdate(sql.toString());
}
+ /**
+ * 鏍规嵁闄勪欢uuid鍒ゆ柇鏂囦欢鏄惁瀛樺湪
+ *
+ * @param uuid
+ * @return
+ */
+ public boolean fileExist(String uuid) {
+ if (StringUtils.isEmpty(uuid)) {
+ return false;
+ }
+ FieldSetEntity attachmentFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ATTACHMENTS, uuid, false);
+ if (attachmentFse == null) {
+ return false;
+ }
+
+ //鍒ゆ柇鏂囦欢瀛樻斁鍦ㄦ湇鍔″櫒杩樻槸鏈湴
+ boolean needDownloadFromServerFlag = "1".equals(attachmentFse.getString(CmnConst.UPLOAD_SIGN));
+ String dir = attachmentFse.getString(CmnConst.ATTACHMENT_URL);
+ String fileName = attachmentFse.getString(CmnConst.ATTACHMENT_TITLE);
+ boolean encrptSignFlag = "1".equals(attachmentFse.getString(CmnConst.ENCRPT_SIGN));
+
+ if (needDownloadFromServerFlag) {
+ // 闇�瑕佷粠闄勪欢鏈嶅姟鍣ㄤ笂鍙栨枃浠�
+ FTPService ftpService = new FTPService();
+ return ftpService.fileIsExist(dir, fileName);
+ } else {
+ // 鐩存帴鍦ㄦ湰鍦扮殑鐩綍涓壘鏂囦欢
+ String localBasePath = Global.getSystemConfig("local.dir", "");
+ String path = localBasePath + File.separator + dir + File.separator + fileName;
+ File file = new File(path);
+ return file.isFile();
+ }
+ }
/**
* 涓婁紶鏂囦欢鍒版湰鍦版湇鍔″櫒
@@ -348,7 +381,7 @@
attachmentFse.setValue(CmnConst.ENCRPT_SIGN, Global.getPropertyToBoolean("file.encrypt", "true") ? 1 : 0);
attachmentFse.setValue(CmnConst.ATTACHMENT_SIZE, fileLength);
attachmentFse.setValue(CmnConst.UPLOAD_SIGN, needUpload2FileServerFlag ? 1 : 0);
-
+ attachmentFse.setValue(CmnConst.FUNCTION_UUID, fse.getString(CmnConst.FUNCTION_UUID));
attachmentFse.setValue(CmnConst.ATTACHMENT_CONTAINER, fse.getString(CmnConst.ATTACHMENT_CONTAINER));
attachmentFse.setValue(CmnConst.ATTACHMENT_DOMAIN, fse.getString(CmnConst.ATTACHMENT_DOMAIN));
attachmentFse.setValue(CmnConst.MODULE_UUID, fse.getString(CmnConst.MODULE_UUID));
@@ -406,8 +439,8 @@
String viewOnlineSign = attachmentFse.getString(CmnConst.VIEW_ONLINE_SIGN);
boolean encrptSignFlag = "1".equals(attachmentFse.getString(CmnConst.ENCRPT_SIGN));
boolean needOnlineViewFlag = "1".equals(fse.getString(CmnConst.NEED_ONLINE_VIEW)) && "1".equals(viewOnlineSign);
- if (needOnlineViewFlag) {
- // 闇�瑕佸湪绾块瑙堜笖杞崲涔嬪悗鎵嶈兘鍦ㄧ嚎棰勮
+ if (needOnlineViewFlag && !realFileName.endsWith(".xlsx") && !realFileName.endsWith(".xls")) {
+ // 闇�瑕佸湪绾块瑙堜笖杞崲涔嬪悗鎵嶈兘鍦ㄧ嚎棰勮 excel 鏂囦欢涓嶉渶瑕佽浆鎹㈢洿鎺ヨ緭鍑洪瑙�
dir += File.separator + CmnConst.TRANSFER_DIR_NAME;
}
@@ -504,7 +537,7 @@
}
os.flush();
}
-
+ is.close();
}
logger.info("鏂囦欢娴佽幏鍙栨垚鍔�");
}
@@ -541,7 +574,7 @@
try {
temp.createNewFile();
} catch (IOException e) {
- throw new BaseException(FileCode.GET_FILE_FAIL.getValue(), FileCode.GET_FILE_FAIL.getText() + (e.getMessage() != null ? e.getMessage() : ""));
+ throw new BaseException(FileCode.GET_FILE_FAIL.getValue(), FileCode.GET_FILE_FAIL.getText() + (e.getMessage() != null ? e.getMessage() + ",uuid:" + attachmentFse.getUUID() : ""));
}
try (FileOutputStream fos = new FileOutputStream(temp); BufferedOutputStream out = new BufferedOutputStream(fos)) {
@@ -549,10 +582,10 @@
return temp;
} catch (Exception e) {
e.printStackTrace();
- throw new BaseException(FileCode.GET_FILE_FAIL.getValue(), FileCode.GET_FILE_FAIL.getText() + (e.getMessage() != null ? e.getMessage() : ""));
+ throw new BaseException(FileCode.GET_FILE_FAIL.getValue(), FileCode.GET_FILE_FAIL.getText() + (e.getMessage() != null ? e.getMessage() + ",uuid:" + attachmentFse.getUUID() : ""));
}
}
- throw new BaseException(FileCode.GET_FILE_FAIL.getValue(), FileCode.GET_FILE_FAIL.getText());
+ throw new BaseException(FileCode.GET_FILE_FAIL.getValue(), FileCode.GET_FILE_FAIL.getText() + ",uuid:" + attachmentFse.getUUID());
}
/**
@@ -560,7 +593,8 @@
*/
public byte[] getFileContent(FieldSetEntity attachmentFse) throws BaseException {
if (attachmentFse == null || !CmnConst.PRODUCT_SYS_ATTACHMENTS.equals(attachmentFse.getTableName())) {
- return new byte[16];
+ //杩斿洖涓�涓┖鐨勫瓧鑺傛暟缁�
+ return new byte[0];
}
try (ByteArrayOutputStream os = new ByteArrayOutputStream();) {
FTPService ftpService = new FTPService();
--
Gitblit v1.9.2