From 8ac3affc79126b0b8ec6f4f7e80b73a6b4a4634b Mon Sep 17 00:00:00 2001
From: YYC <1833023622@qq.com>
Date: 星期四, 12 二月 2026 09:21:16 +0800
Subject: [PATCH] APP
---
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 152 insertions(+), 22 deletions(-)
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java
index c6c9507..8702908 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/FileService.java
@@ -2,7 +2,9 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzzy.igds.domain.FileInfo;
+import com.fzzy.igds.domain.Quantity;
import com.fzzy.igds.mapper.FileMapper;
+import com.fzzy.igds.utils.Base64Util;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.config.FrameworkConfig;
import org.apache.commons.lang3.time.DateFormatUtils;
@@ -30,6 +32,29 @@
private FileMapper fileMapper;
/**
+ * 鏍规嵁鏉′欢鑾峰彇闄勪欢淇℃伅
+ * @param companyId
+ * @param bizId
+ * @return
+ */
+ public List<FileInfo> listFile(String companyId, String bizId) {
+ if (StringUtils.isEmpty(companyId)) {
+ companyId = ContextUtil.getCompanyId();
+ }
+
+ if (StringUtils.isEmpty(bizId)){
+ return null;
+ }
+
+ QueryWrapper<FileInfo> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("company_id", companyId);
+ queryWrapper.eq("biz_id", bizId);
+ queryWrapper.orderByAsc("create_time");
+
+ return fileMapper.selectList(queryWrapper);
+ }
+
+ /**
* 寮傛鎵ц闄勪欢淇濆瓨
* @param files 闄勪欢淇℃伅
* @param bizId 涓氬姟id
@@ -50,10 +75,13 @@
}
data.setId(ContextUtil.generateId());
+ data.setCreateTime(new Date());
+ data.setCreateBy(ContextUtil.getLoginUserName());
data.setCompanyId(ContextUtil.getCompanyId());
//鏂囦欢鍏ㄨ矾寰�
String filePath = getFileSavePath(pathTag) + data.getFileName();
+
filePath = filePath.replace(FrameworkConfig.getProfile(), "/profile/");
data.setFilePath(filePath);
@@ -64,14 +92,28 @@
data.setBizTag(bizTag);
}
- data.setCreateTime(new Date());
- data.setCreateBy(ContextUtil.getLoginUserName());
-
- data.setUpdateTime(new Date());
- data.setUpdateBy(ContextUtil.getLoginUserName());
- fileMapper.insert(data);
+ saveFile(data);
}
}
+
+ /**
+ *
+ * @param data
+ */
+ public void saveFile(FileInfo data) {
+
+ data.setUpdateTime(new Date());
+ data.setUpdateBy(ContextUtil.getLoginUserName());
+
+ if(StringUtils.isBlank(data.getId())){
+ data.setId(ContextUtil.UUID());
+ data.setCreateTime(new Date());
+ data.setCreateBy(ContextUtil.getLoginUserName());
+ }
+
+ fileMapper.insert(data);
+ }
+
/**
* 鏍规嵁鏉′欢鏌ヨ鏁版嵁
@@ -98,15 +140,7 @@
}
/**
- *
- * @param id
- */
- public void delFile(String id) {
- fileMapper.deleteById(id);
- }
-
- /**
- * 鑾峰彇鍑哄叆搴撴枃浠惰矾寰�
+ * 鏍规嵁绫诲瀷鑾峰彇鏂囦欢璺緞
* @param pathTag
* @return
*/
@@ -114,19 +148,65 @@
if(StringUtils.isBlank(pathTag)){
pathTag = "COMMON";
}
+ if("EVENT".equals(pathTag)) return getEventFilePath();
+ if("SNAP".equals(pathTag)) return getSnapFilePath();
if("INOUT".equals(pathTag)) return getInoutFilePath();
if("PATROL".equals(pathTag)) return getPatrolFilePath();
if("DEPT".equals(pathTag)) return getDeptFilePath();
+ if("TEMP".equals(pathTag)) return getTempFilePath();
+ if("CONF".equals(pathTag)) return getConfPath();
+ if("TEMPLATE".equals(pathTag)) return getTemplateFilePath();
+ if("QUANTITY".equals(pathTag)) return getQuantityPath();
+ if("WORD".equals(pathTag)) return getWordPath();
return getCommonFilePath();
}
/**
- * 鑾峰彇鍑哄叆搴撴枃浠惰矾寰�
+ * 鑾峰彇浜嬩欢鏂囦欢璺緞
+ * @return
+ */
+ public String getQuantityPath() {
+ String basePath = FrameworkConfig.getProfile() + "QUANTITY/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+ File file = new File(basePath);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ return basePath;
+ }
+
+ /**
+ * 鑾峰彇浜嬩欢鏂囦欢璺緞
+ * @return
+ */
+ public String getEventFilePath() {
+ String basePath = FrameworkConfig.getProfile() + "EVENT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+ File file = new File(basePath);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ return basePath;
+ }
+
+ /**
+ * 鑾峰彇鎶撴媿鏂囦欢璺緞
+ * @return
+ */
+ public String getSnapFilePath() {
+ String basePath = FrameworkConfig.getProfile() + "SNAP/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+ File file = new File(basePath);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ return basePath;
+ }
+
+ /**
+ * 鑾峰彇宸℃鏂囦欢璺緞
* @return
*/
public String getPatrolFilePath() {
- String basePath = FrameworkConfig.getProfile() + "INOUT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+ String basePath = FrameworkConfig.getProfile() + "PATROL/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
File file = new File(basePath);
if (!file.exists()) {
file.mkdirs();
@@ -179,15 +259,11 @@
/**
* 鑾峰彇涓存椂璺緞
- * @param companyId
* @return
*/
- public String getTempFilePath(String companyId) {
+ public String getTempFilePath() {
String basePath = FrameworkConfig.getProfile() + "TEMP/";
- if (org.apache.commons.lang3.StringUtils.isNotEmpty(companyId)) {
- basePath += companyId + "/";
- }
File file = new File(basePath);
if (!file.exists()) {
file.mkdirs();
@@ -207,6 +283,42 @@
file.mkdirs();
}
return basePath;
+ }
+
+ /**
+ * 鑾峰彇妯℃澘璺緞锛氭墍鏈夋ā鏉跨粺涓�鏀惧湪TEMPLATE/鐩綍涓�
+ * @return
+ */
+ public String getTemplateFilePath() {
+ String basePath = FrameworkConfig.getProfile() + "TEMPLATE/";
+ File file = new File(basePath);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ return basePath;
+ }
+
+ /**
+ * 鑾峰彇word璺緞
+ * @return
+ */
+ public String getWordPath() {
+
+ String basePath = FrameworkConfig.getProfile() + "WORD/";
+ File file = new File(basePath);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ return basePath;
+ }
+
+ /**
+ * base64杞浘鐗囦繚瀛�
+ * @param filePath
+ * @param imgData
+ */
+ public void baseImg2Disk(String filePath, String imgData) {
+ Base64Util.generateImage(imgData, filePath);
}
/**
@@ -233,6 +345,24 @@
ImageIO.write(compressedImage, "jpg", new File(outputPath));
}
+ /**
+ * 鍒ゆ柇璺緞涓嬫枃浠舵槸鍚﹀瓨鍦紝涓嶅瓨鍦ㄥ垯缁欓粯璁�
+ * @param imgPath
+ * @return
+ */
+ public String isImgExit(String imgPath, String tag) {
+ String path = "/img/img-fail.jpg";
+ if(StringUtils.isNotBlank(tag) && "dept".equals(tag)){
+ path = "/img/deptImg.jpg";
+ }
+ if(StringUtils.isNotBlank(imgPath)){
+ File file = new File(imgPath.replace("/profile", FrameworkConfig.getProfile()));
+ if(file.exists()){
+ path = imgPath;
+ }
+ }
+ return path;
+ }
}
--
Gitblit v1.9.3