czt
2025-06-11 283da741b2429cf5a53786e5ee1b5528b757fdf6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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);
    }
 
}