管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-11 1ef1e36cda961e1c348b22049932b05cd21d397e
1
已修改4个文件
190 ■■■■■ 文件已修改
data/db_tab.sql 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/all/SettingData.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/FileHelper.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/UploadService.java 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_tab.sql
@@ -542,60 +542,6 @@
select * from lf.sys_role_menu_auth;
----------------------------------------------------------------------------------------------------- 16.元数据表
-- DROP TABLE IF EXISTS lf.sys_meta;
create table lf.sys_meta(
  id serial primary key,
  name varchar(256),
  dirid integer default 0,
  depid integer default 0,
  verid integer default 0,
  type varchar(100),
  sizes float8 default 0,
  tab varchar(50),
  rows integer default 0,
  cs varchar(50),
  scale varchar(50),
  resolution varchar(50),
  gather timestamp(6) without time zone,
  batch varchar(50),
  descr varchar(256),
  create_user integer default 1,
  create_time timestamp(6) without time zone default now(),
  update_user integer,
  update_time timestamp(6) without time zone,
  geom geometry default null,
  CONSTRAINT enforce_dims_geom CHECK (st_ndims(geom) = 2),
  CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) = 'POLYGON'::text OR geom IS NULL),
  CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 4490)
);
-- drop index index_sys_meta_geom;
create index index_sys_meta_geom on lf.sys_meta using GIST (geom);
comment on table lf.sys_meta is '元数据表';
comment on column lf.sys_meta.id is '主键ID';
comment on column lf.sys_meta.name is '名称';
comment on column lf.sys_meta.dirid is '目录ID';
comment on column lf.sys_meta.depid is '单位ID';
comment on column lf.sys_meta.verid is '版本ID';
comment on column lf.sys_meta.type is '类型:file-文件,shp-ShapeFile,gdb-GDB,zip-压缩包';
comment on column lf.sys_meta.sizes is '大小:单位MB';
comment on column lf.sys_meta.tab is '表名';
comment on column lf.sys_meta.rows is '行数';
comment on column lf.sys_meta.cs is '坐标系';
comment on column lf.sys_meta.scale is '比例尺';
comment on column lf.sys_meta.resolution is '分辨率';
comment on column lf.sys_meta.gather is '采集日期';
comment on column lf.sys_meta.batch is '批次';
comment on column lf.sys_meta.descr is '描述';
comment on column lf.sys_meta.create_user is '创建人ID';
comment on column lf.sys_meta.create_time is '创建时间';
comment on column lf.sys_meta.update_user is '更新人ID';
comment on column lf.sys_meta.update_time is '更新时间';
comment on column lf.sys_meta.geom is '空间位置';
-- insert into lf.sys_meta(dirid,depid,name,geom,sizes) values (1,1,'Test',ST_PolygonFromText('POLYGON ((100 0,120 0,120 20,100 20,100 0))',4490),0.001);
select * from lf.sys_meta; select id,name,dirid,depid,verid,type,sizes,descr,create_user,create_time,update_user,update_time,st_astext(geom) from lf.sys_meta;
----------------------------------------------------------------------------------------------------- 16.元数据表-New
-- DROP TABLE IF EXISTS lf.sys_meta; DROP TABLE IF EXISTS lf.sys_meta_file;
create table lf.sys_meta_new (
  id serial primary key,
  eventid varchar(38) default new_guid(),
@@ -618,7 +564,7 @@
  geom geometry(MultiPolygon, 4490)
);
-- drop index index_sys_meta_geom;
create index index_sys_meta_geom on lf.sys_meta_new using GIST (geom);
create index index_sys_meta_geom on lf.sys_meta using GIST (geom);
comment on table lf.sys_meta is '元数据表';
comment on column lf.sys_meta.id is '主键ID';
comment on column lf.sys_meta.eventid is 'GUID';
@@ -642,7 +588,7 @@
-- insert into lf.sys_meta(dirid,depid,geom,sizes,name,path) values (1,1,ST_PolygonFromText('MultiPolygon (((100 0,120 0,120 20,100 20,100 0)))', 4490),0.001,'a.jpg','c:\a.jpg');
-- alter table lf.sys_meta rename column bstab to tab; alter table lf.sys_meta drop column mdtab;
select * from lf.sys_meta; select a.*,st_astext(geom) from lf.sys_meta a;
select a.*,st_astext(geom) from lf.sys_meta a; select id,name,dirid,depid,verid,type,sizes,create_user,create_time,update_user,update_time,st_astext(geom) from lf.sys_meta;
----------------------------------------------------------------------------------------------------- 18.附件表
-- DROP TABLE IF EXISTS lf.sys_attach;
create table lf.sys_attach(
src/main/java/com/lf/server/entity/all/SettingData.java
@@ -31,9 +31,9 @@
    public static int CACHE_EXPIRE = 240;
    /**
     * 最大文件数
     * 最大文件数:2000
     */
    public static int MAX_FILES = 2000;
    public static int MAX_FILES = 2001;
    /**
     * Cookie有效期:s
src/main/java/com/lf/server/helper/FileHelper.java
@@ -254,17 +254,19 @@
     * @param file 文件
     */
    public static void deleteFiles(File file) {
        if (file == null || !file.exists()) {
        if (null == file || !file.exists()) {
            return;
        }
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File f : files) {
                if (f.isDirectory()) {
                    deleteFiles(f);
                } else {
                    f.delete();
            if (null != files && files.length > 0) {
                for (File f : files) {
                    if (f.isDirectory()) {
                        deleteFiles(f);
                    } else {
                        f.delete();
                    }
                }
            }
        }
src/main/java/com/lf/server/service/data/UploadService.java
@@ -2,10 +2,7 @@
import com.lf.server.entity.all.BaseEntity;
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.data.*;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.*;
import com.lf.server.mapper.all.BasicMapper;
@@ -32,6 +29,9 @@
    @Autowired
    FmeService fmeService;
    @Autowired
    MetaService metaService;
    @Override
    public List<CoordEntity> selectCoords(String zoning) {
@@ -77,8 +77,8 @@
            File f = new File(mf.getPath());
            if (!f.exists()) {
                mf.setMsg("文件丢失");
                mf.setRows(-1);
                mf.setMsg("文件不存在");
            }
        }
    }
@@ -165,6 +165,7 @@
     * 复制文件
     */
    private void copyFiles(List<MetaFileEntity> list) {
        List<String> gdbList = new ArrayList<>();
        for (MetaFileEntity mf : list) {
            switch (mf.getExtName()) {
                case StaticData.MPT:
@@ -183,6 +184,15 @@
                    copyMultiFile(mf, StaticData.SHP_EXT);
                    break;
                case StaticData.GDB:
                    if (gdbList.contains(mf.getPath())) {
                        MetaEntity meta = metaService.selectByGuid(mf.getGuid());
                        if (null != meta) {
                            mf.setPath(meta.getPath());
                        }
                        continue;
                    }
                    gdbList.add(mf.getPath());
                    copyFolderFile(mf);
                    break;
                default:
@@ -195,28 +205,116 @@
    /**
     * 复制单个文件
     */
    private void copySingleFile(MetaFileEntity mf) {
    private int copySingleFile(MetaFileEntity mf) {
        File file = new File(mf.getPath());
        if (!file.exists()) {
            mf.setMsg("文件丢失");
            return -1;
        }
        MetaEntity old = metaService.selectByGuid(mf.getGuid());
        if (null != old) {
            mf.setMsg("文件已存在");
            file.delete();
            return 0;
        }
        String uploadPath = pathHelper.getUploadFullPath();
        String targetPath = uploadPath + File.separator + mf.getGuid() + mf.getExtName();
        File newFile = new File(targetPath);
        if (newFile.exists()) {
            file.delete();
            return 0;
        }
        file.renameTo(newFile);
        String subPath = FileHelper.getRelativePath(targetPath);
        mf.setPath(subPath);
        return 1;
    }
    /**
     * 复制多个文件
     */
    private void copyMultiFile(MetaFileEntity mf, List<String> extList) {
        String path = mf.getPath();
        int status = copySingleFile(mf);
        if (status < 1) {
            for (int i = 0, c = extList.size(); i < c; i++) {
                String subPath = path.replace(mf.getExtName(), extList.get(i));
                File file = new File(subPath);
                if (file.exists()) {
                    file.delete();
                }
            }
            return;
        }
        String uploadPath = pathHelper.getConfig().getUploadPath();
        for (int i = 0, c = extList.size(); i < c; i++) {
            String sourcePath = path.replace(mf.getExtName(), extList.get(i));
            File file = new File(sourcePath);
            if (!file.exists()) {
                continue;
            }
            String targetPath = uploadPath + File.separator + mf.getPath().replace(mf.getExtName(), extList.get(i));
            File newFile = new File(targetPath);
            if (newFile.exists()) {
                continue;
            }
            file.renameTo(newFile);
        }
    }
    /**
     * 复制文件夹文件
     */
    private void copyFolderFile(MetaFileEntity mf) {
        File file = new File(mf.getPath());
        if (!file.exists()) {
            mf.setMsg("文件丢失");
            return;
        }
        MetaEntity old = metaService.selectByGuid(mf.getGuid());
        if (null != old) {
            mf.setMsg("文件已存在");
            FileHelper.deleteFiles(file);
            return;
        }
        String uploadPath = pathHelper.getUploadFullPath();
        String targetPath = uploadPath + File.separator + mf.getGuid() + mf.getExtName();
        File newFile = new File(targetPath);
        if (newFile.exists() && newFile.isDirectory()) {
            FileHelper.deleteFiles(file);
            return;
        }
        newFile.mkdirs();
        File[] files = file.listFiles();
        if (null == files || files.length == 0) {
            return;
        }
        for (File f : files) {
            String subPath = targetPath + File.separator + FileHelper.getFileName(f.getPath());
            f.renameTo(new File(subPath));
        }
        String subPath = FileHelper.getRelativePath(targetPath);
        mf.setPath(subPath);
    }
    /**
     * 插入元数据
     *
     * @param list
     */
    private void insertMetas(List<MetaFileEntity> list) {
        for (MetaFileEntity mf : list) {