From 10e4a29fad93759f69c03b94eec8603070ff765a Mon Sep 17 00:00:00 2001
From: shicf <shi_chongfu@163.com>
Date: 星期四, 28 十一月 2024 11:20:34 +0800
Subject: [PATCH] 移动端文件预览
---
src/main/java/com/product/file/service/FileManagerService.java | 67 ++++++++++++++++++++++++++++++++-
1 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/product/file/service/FileManagerService.java b/src/main/java/com/product/file/service/FileManagerService.java
index e01e65a..cd6e528 100644
--- a/src/main/java/com/product/file/service/FileManagerService.java
+++ b/src/main/java/com/product/file/service/FileManagerService.java
@@ -20,6 +20,8 @@
import com.product.file.util.FileUtil;
import com.product.file.util.FileUtils;
import com.product.module.sys.entity.SystemUser;
+import com.product.util.BaseUtil;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
@@ -232,6 +234,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();
+ }
+ }
/**
* 涓婁紶鏂囦欢鍒版湰鍦版湇鍔″櫒
@@ -286,7 +321,7 @@
String uuids = "";
for (Map.Entry<Object, Object> entry : map.entrySet()) {
fieldFse = fieldMetaEntity.getFieldMeta(fieldName);
- if (fieldFse == null || !CmnConst.ATTACHMENT_TYPE.equals(fieldFse.getString(CmnConst.FIELD_TYPE))) {
+ if (fieldFse == null || (!CmnConst.ATTACHMENT_TYPE.equals(fieldFse.getString(CmnConst.FIELD_TYPE)) && !"file-image".equals(fieldFse.getString(CmnConst.FIELD_TYPE)))) {
fse.setValue(entry.getKey().toString(), null);
continue;
}
@@ -383,6 +418,34 @@
fse.setValue(fieldName, uuids);
}
return fse;
+ }
+
+ /**
+ * 鏍规嵁闄勪欢琛ㄦ暟鎹敓鎴愭枃妗g储寮�
+ */
+ public void readAttachmentCreateIndex() {
+ // 閬嶅巻闄勪欢琛�
+ DataTableEntity dtAttachment = baseDao.listTable(CmnConst.PRODUCT_SYS_ATTACHMENTS);
+ if (BaseUtil.dataTableIsEmpty(dtAttachment)) {
+ return;
+ }
+ for (int i = 0; i < dtAttachment.getRows(); i++) {
+ // 鑾峰彇闄勪欢淇℃伅锛屽苟鍒ゆ柇鏄惁鏈夎〃鍜屽瓧娈�
+ FieldSetEntity fseAttachment = dtAttachment.getFieldSetEntity(i);
+ if (BaseUtil.strIsNull(fseAttachment.getString("attachment_data_field")) || BaseUtil.strIsNull(fseAttachment.getString("attachment_data_field"))) {
+ continue;
+ }
+ // 鏌ヨ鍘熸暟鎹紝鏈夊師鏁版嵁鍐嶇敓鎴愭枃妗f绱�
+ FieldSetEntity fseRecord = baseDao.getFieldSetEntityByFilter(fseAttachment.getString("attachment_data_table"), fseAttachment.getString("attachment_data_field") + " LIKE ?", new Object[]{"%" + fseAttachment.getUUID() + "%"}, false);
+ if (fseRecord != null) {
+ // 鐢熸垚鏂囨。妫�绱俊鎭�
+ FieldSetEntity fseIndex = new FieldSetEntity();
+ fseIndex.setTableName("fseIndex");
+ fseIndex.setValue("function_uuid", fseAttachment.getString("function_uuid"));
+ fseIndex.setValue("attachment_uuid", fseAttachment.getUUID());
+ CreateDocumentIndexThread.getInstance().appendAttaInfo(fseIndex);
+ }
+ }
}
/**
@@ -504,7 +567,7 @@
}
os.flush();
}
-
+ is.close();
}
logger.info("鏂囦欢娴佽幏鍙栨垚鍔�");
}
--
Gitblit v1.9.2