管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-10 f063bd6697c768a1214fecdf597fcbd1eff7f322
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
package com.lf.server.service.data;
 
import com.alibaba.druid.support.spring.stat.annotation.Stat;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.data.CoordEntity;
import com.lf.server.entity.data.DirEntity;
import com.lf.server.entity.data.FmeLogEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.mapper.data.UploadMapper;
import com.lf.server.service.all.BaseUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.io.File;
import java.util.ArrayList;
import java.util.List;
 
/**
 * 数据上传服务类
 * @author WWW
 */
@Service
public class UploadService extends BaseUploadService implements UploadMapper {
    @Autowired
    UploadMapper uploadMapper;
 
    @Override
    public List<CoordEntity> selectCoords(String zoning) {
        return uploadMapper.selectCoords(zoning);
    }
 
    @Override
    public Integer selectCount4Coord(String epsgCode) {
        return uploadMapper.selectCount4Coord(epsgCode);
    }
 
    @Override
    public List<DirEntity> selectProject() {
        return uploadMapper.selectProject();
    }
 
    @Override
    public List<FmeLogEntity> selectFmeLog(String parentid) {
        return uploadMapper.selectFmeLog(parentid);
    }
 
    /**
     * 插入文件
     */
    public void insertFiles(UserEntity ue, List<MetaFileEntity> list) {
        checkMetaFiles(ue, list);
 
    }
 
    /**
     * 检查元数据文件
     */
    private void checkMetaFiles(UserEntity ue, List<MetaFileEntity> list) {
        String tempPath = pathHelper.getConfig().getTempPath();
 
        int i = 0;
        while (i < list.size()) {
            MetaFileEntity mf = list.get(i);
            File f = new File(tempPath + File.separator + mf.getPath());
            if (!f.exists()) {
                list.remove(i);
                continue;
            }
 
            // mf.setCreateUser(ue.getId()); mf.setDepid(ue.getDepid())
            i++;
        }
    }
 
    /**
     * 获取Excel文件
     */
    private List<String> getExcelFiles(List<MetaFileEntity> list) {
        String tempPath = pathHelper.getConfig().getTempPath();
 
        List<String> xlsList = new ArrayList<>();
        for (MetaFileEntity mf : list) {
            if (StaticData.XLS.equals(mf.getExtName()) || StaticData.XLSX.equals(mf.getExtName())) {
                File f = new File(tempPath + File.separator + mf.getPath());
                if (f.exists() && !f.isDirectory()) {
                    xlsList.add(f.getPath());
                }
            }
        }
 
        return xlsList;
    }
}