From ae9dd63087211599a77aec737861fb07ee0460ed Mon Sep 17 00:00:00 2001
From: 许鹏程 <1821349743@qq.com>
Date: 星期四, 30 五月 2024 18:03:07 +0800
Subject: [PATCH] 设备管理提交

---
 src/main/java/com/product/file/service/FileManagerService.java |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 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..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();
+		}
+	}
 
 	/**
 	 * 涓婁紶鏂囦欢鍒版湰鍦版湇鍔″櫒
@@ -504,7 +537,7 @@
 				}
 				os.flush();
 			}
-
+			is.close();
 		}
 		logger.info("鏂囦欢娴佽幏鍙栨垚鍔�");
 	}

--
Gitblit v1.9.2