管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-19 c9183fa5835268bfc15557b4bd0e0b6b333c79de
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
package com.lf.server.service.data;
 
import com.lf.server.entity.data.MetaEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.sys.MenuEntity;
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.sql.Timestamp;
import java.util.List;
 
/**
 * 数据上传
 * @author WWW
 */
@Service
public class DataUploadService extends BaseUploadService {
    @Autowired
    MetaService metaService;
 
    @Autowired
    MetaFileService metaFileService;
 
    /**
     * 插入文件
     */
    public int insertFiles(MetaEntity entity, List<MetaFileEntity> list) {
        int count = 0;
        try {
            String temp = pathHelper.getConfig().getTempPath();
            String root = pathHelper.getUploadFullPath();
 
            for (MetaFileEntity mf : list) {
                // 移动文件
                File file = new File(temp + File.separator + mf.getPath());
                File newFile = new File(root + File.separator + mf.getName());
                file.renameTo(newFile);
 
                // 元数据
                MetaEntity me=createMetaEntity(entity);
                me.setName(mf.getName());
                me.setSizes(mf.getSizes());
 
                // 元数据文件
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
 
        return count;
    }
 
    /**
     * 创建元数据实体
     */
    private MetaEntity createMetaEntity(MetaEntity entity) {
        MetaEntity me = new MetaEntity();
        me.setDepid(entity.getDepid());
        me.setDirid(entity.getDirid());
        me.setVerid(entity.getVerid());
        me.setType("file");
        me.setGather(entity.getGather());
        me.setBatch(entity.getBatch());
        me.setDescr(entity.getDescr());
        me.setCreateTime(entity.getCreateTime());
        me.setCreateUser(entity.getCreateUser());
 
        return me;
    }
}