2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
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
package com.landtool.lanbase.test;
 
import org.apache.commons.lang.StringUtils;
 
import java.io.File;
 
public class NcService {
    private static final String BASE_DIR = "/iserverData/NC/";
 
    /**
     *
     * @param ncpath nc数据相对路径
     * @param type 类型
     * @param depth 深度
     * @return
     */
    public static String isNcDataFileExist(String ncpath, String type, String depth){
        //
        String message = "";
        //
        String cacheRelativePath = ncpath.substring(0,ncpath.indexOf("."));
        // 文件路径
        String filePath = BASE_DIR + "data/" + ncpath;
        // 缓存文件名称
        String cacheName = cacheRelativePath + "_" + type + "_" + depth + ".dat" ;
        // 缓存文件相对路径
        String relativePath = "cache/" + cacheName;
        // 缓存文件路径
        String cachePath = BASE_DIR + "cache/" + cacheName;
        // 判断文件是否存在
        File file = new File(cachePath);
        if (!file.exists()){
            message = "{\"path\":\"error\"}";
        }else{
            message = "{\"path\":\"" + relativePath + "\"}";
        }
        return message;
    }
 
    public static void main(String[] args) {
        try {
            String ncpath = "chinasea_201901_salt_1.dat";
            String type = "type1";
            String depth = "deep1";
            String resultMessage = isNcDataFileExist(ncpath,type,depth);
            if (StringUtils.isNotEmpty(resultMessage)){
                System.out.println(resultMessage);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}