路径修改

This commit is contained in:
haozq 2025-05-07 10:58:52 +08:00
parent e59a45b48b
commit 9689c1b3a7
7 changed files with 24 additions and 17 deletions

View File

@ -153,7 +153,7 @@ public class FileUploadUtils
{ {
int dirLastIndex = RuoYiConfig.getProfile().length() + 1; int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
String currentDir = StringUtils.substring(uploadDir, dirLastIndex); String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; return "/" + fileName;
} }
/** /**

View File

@ -3,6 +3,7 @@ package com.bonus.framework.config;
import java.io.File; import java.io.File;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
@ -27,6 +28,12 @@ public class ResourcesConfig implements WebMvcConfigurer
@Autowired @Autowired
private RepeatSubmitInterceptor repeatSubmitInterceptor; private RepeatSubmitInterceptor repeatSubmitInterceptor;
/**
* 上传文件存储在本地的根路径
*/
@Value("${file.path}")
private String localFilePath;
// @Override // @Override
// public void addResourceHandlers(ResourceHandlerRegistry registry) // public void addResourceHandlers(ResourceHandlerRegistry registry)
// { // {
@ -42,11 +49,8 @@ public class ResourcesConfig implements WebMvcConfigurer
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/files/**").addResourceLocations("file:/usr/local/bonus/uploadPath"+ File.separator); registry.addResourceHandler("/files/**").addResourceLocations("file:"+localFilePath+ File.separator);
//super.addResourceHandlers(registry);
// registry.addResourceHandler("/files/**").addResourceLocations("file:E:\\file\\");
// super.addResourceHandlers(registry);
} }
/** /**

View File

@ -60,7 +60,6 @@ public class LocalSysFileServiceImpl implements ISysFileService
public TbFileSourceVo uploadFile(MultipartFile file) throws Exception public TbFileSourceVo uploadFile(MultipartFile file) throws Exception
{ {
String url = FileUploadUtils.upload(localFilePath, file); String url = FileUploadUtils.upload(localFilePath, file);
// String url = domain + localFilePrefix + name;
String name = FileUtils.getName(url); String name = FileUtils.getName(url);
String fileSuffix = FileUploadUtils.getExtension(file); String fileSuffix = FileUploadUtils.getExtension(file);
return TbFileSourceVo.builder().filePath(url).fileName(name).fileSuffix(fileSuffix).build(); return TbFileSourceVo.builder().filePath(url).fileName(name).fileSuffix(fileSuffix).build();
@ -97,12 +96,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
@Override @Override
public void deleteFile(String urlStr) throws Exception public void deleteFile(String urlStr) throws Exception
{ {
// String regex = String.format("^(.*?%s)", localFilePrefix); Path path = Paths.get(localFilePath+urlStr);
// String updatePath = urlStr.replaceFirst(regex, localFilePath);
// Path path = Paths.get(updatePath);
String oldPart = "/profile/oadPath";
String updatePath = urlStr.replace(oldPart, localFilePath);
Path path = Paths.get(updatePath);
if (Files.exists(path)){ if (Files.exists(path)){
try { try {
Files.deleteIfExists(path); Files.deleteIfExists(path);

View File

@ -8,7 +8,7 @@
<artifactId>search_tool_service</artifactId> <artifactId>search_tool_service</artifactId>
<version>3.8.9</version> <version>3.8.9</version>
<name>ruoyi</name> <name>bonus</name>
<url>http://www.ruoyi.vip</url> <url>http://www.ruoyi.vip</url>
<description>若依管理系统</description> <description>若依管理系统</description>

View File

@ -201,7 +201,8 @@ public class EpcServiceImpl implements EpcService {
} }
} }
@Value("file.path")
@Value("${file.path}")
private String filePath; private String filePath;

View File

@ -11,6 +11,7 @@ import com.bonus.tool.service.StateGridService;
import com.bonus.tool.template.util.FreeMarkerUtil; import com.bonus.tool.template.util.FreeMarkerUtil;
import com.bonus.tool.template.util.WordUtils; import com.bonus.tool.template.util.WordUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -264,9 +265,14 @@ public class StateGridServiceImpl implements StateGridService {
return AjaxResult.success(); return AjaxResult.success();
} }
@Value("file.path")
@Value("${file.path}")
private String filePath; private String filePath;
public static void main(String[] args) throws Exception {
String bast64= FreeMarkerUtil.getImageBase("F:\\File\\tool\\2025\\05\\07\\3_20250507104937A005.png");
System.err.println(bast64);
}
/** /**
* 将数据转换为模版数据 * 将数据转换为模版数据
@ -312,7 +318,8 @@ public class StateGridServiceImpl implements StateGridService {
imgMap.put("index", 100 * index + imgIndex++); imgMap.put("index", 100 * index + imgIndex++);
imgMap.put("width", "5325745"); imgMap.put("width", "5325745");
imgMap.put("height", "7534910"); imgMap.put("height", "7534910");
imgMap.put("base64Url", file.getFilePath() != null ? FreeMarkerUtil.getImageBase(filePath+file.getFilePath()) : ""); String bast64=FreeMarkerUtil.getImageBase(filePath+file.getFilePath());
imgMap.put("base64Url", file.getFilePath() != null ? bast64: "");
imgList.add(imgMap); imgList.add(imgMap);
} }
perfImgMap.put("imgList", imgList); perfImgMap.put("imgList", imgList);
@ -321,6 +328,7 @@ public class StateGridServiceImpl implements StateGridService {
} }
} }
// 处理分包商数据(核心分包商业绩证明) // 处理分包商数据(核心分包商业绩证明)
if (tbData.getSubList() != null && !tbData.getSubList().isEmpty()) { if (tbData.getSubList() != null && !tbData.getSubList().isEmpty()) {
int subIndex = 1; int subIndex = 1;

View File

@ -133,5 +133,5 @@ xss:
file: file:
domain: http://192.168.0.14:58089 domain: http://192.168.0.14:58089
path: /usr/local/bonus/uploadPath path: F:\File\tool
prefix: /statics prefix: /statics