package com.fzzy.igds.file;
|
|
import com.fzzy.common.utils.Base64Util;
|
import com.fzzy.igds.dzhwk.data.DzhwkConfigData;
|
import com.ruoyi.common.config.FrameworkConfig;
|
import lombok.extern.slf4j.Slf4j;
|
import com.ruoyi.common.utils.StringUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.springframework.stereotype.Service;
|
import javax.annotation.Resource;
|
import java.io.File;
|
import java.util.Date;
|
|
/**
|
* @Description 仓房service层
|
* @Author CZT
|
* @Date 2024/11/20 19:03
|
*/
|
@Slf4j
|
@Service
|
public class FileService {
|
|
@Resource
|
private DzhwkConfigData configData;
|
|
/**
|
* 获取库区路径下文件
|
* @param companyId
|
* @return
|
*/
|
public String getDeptFilePath(String companyId) {
|
if (StringUtils.isEmpty(companyId)){
|
companyId = configData.getCompanyId();
|
}
|
|
String basePath = configData.getProfile() + "IMG/"+ companyId + "/SECURITY/";
|
|
File file = new File(basePath);
|
if (!file.exists()) {
|
file.mkdirs();
|
}
|
return basePath;
|
}
|
|
public String getInoutFilePath(Date date) {
|
if (null == date) date = new Date();
|
String basePath = configData.getProfile() + "INOUT/" + DateFormatUtils.format(date, "yyyyMM") + "/";
|
File file = new File(basePath);
|
if (!file.exists()) {
|
file.mkdirs();
|
}
|
return basePath;
|
}
|
|
|
public String getSnapFilePath(Date date) {
|
if (null == date) date = new Date();
|
String basePath = configData.getProfile() + "SNAP/" + DateFormatUtils.format(date, "yyyyMM") + "/";
|
File file = new File(basePath);
|
if (!file.exists()) {
|
file.mkdirs();
|
}
|
return basePath;
|
}
|
|
|
public String getSnapFilePath(String dateStr) {
|
if (null == dateStr) return null;
|
|
if (dateStr.length() > 6) dateStr = dateStr.substring(0, 6);
|
|
String basePath = configData.getProfile() + "SNAP/" + dateStr + "/";
|
File file = new File(basePath);
|
if (!file.exists()) {
|
file.mkdirs();
|
}
|
return basePath;
|
}
|
|
|
public String getCommonFilePath(Date date) {
|
if (null == date)
|
date = new Date();
|
|
String basePath = configData.getProfile() + "COMMON/" + DateFormatUtils.format(date, "yyyyMM") + "/";
|
|
File file = new File(basePath);
|
if (!file.exists()) {
|
file.mkdirs();
|
}
|
return basePath;
|
}
|
|
|
public String getSnapPlateFilePath(Date date) {
|
if (null == date)
|
date = new Date();
|
|
String basePath = configData.getProfile() + "TEMP/" + DateFormatUtils.format(date, "yyyyMM") + "/";
|
|
File file = new File(basePath);
|
if (!file.exists()) {
|
file.mkdirs();
|
}
|
return basePath;
|
}
|
|
|
public String getTempFilePath(String companyId) {
|
|
String basePath = configData.getProfile() + "TEMP/";
|
if (StringUtils.isNotEmpty(companyId)) {
|
basePath += companyId + "/";
|
}
|
File file = new File(basePath);
|
if (!file.exists()) {
|
file.mkdirs();
|
}
|
return basePath;
|
}
|
|
|
public String getConfPath() {
|
|
String basePath = configData.getProfile() + "CONF/";
|
File file = new File(basePath);
|
if (!file.exists()) {
|
file.mkdirs();
|
}
|
return basePath;
|
}
|
|
|
public void baseImg2Disk(String basePath, String fileName, String imgData) {
|
Base64Util.generateImage(imgData, basePath + fileName);
|
}
|
|
}
|