管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-19 0506486bb7cda87354ffb9496803e5361582c3c7
1
已修改9个文件
117 ■■■■■ 文件已修改
data/db_tab.sql 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/data/MetaEntity.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/data/MetaFileEntity.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/sys/AttachEntity.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/FileHelper.java 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/PathHelper.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/StringHelper.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/all/ScheduleService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/UploaderService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_tab.sql
@@ -538,7 +538,7 @@
  depid integer default 0,
  verid integer default 0,
  type varchar(100),
  sizes bigint default 0,
  sizes float8 default 0,
  cs varchar(50),
  scale varchar(50),
  resolution varchar(50),
@@ -562,7 +562,7 @@
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 '格式';
comment on column lf.sys_meta.sizes is '大小:单位为B';
comment on column lf.sys_meta.sizes is '大小:单位MB';
comment on column lf.sys_meta.cs is '坐标系';
comment on column lf.sys_meta.scale is '比例尺';
comment on column lf.sys_meta.resolution is '分辨率';
@@ -573,7 +573,7 @@
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.geo is '空间位置';
-- insert into lf.sys_meta(dirid,depid,name,geo) values (1,1,'Test',ST_PolygonFromText('POLYGON ((100 0,120 0,120 20,100 20,100 0))',4490));
-- insert into lf.sys_meta(dirid,depid,name,geo,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(geo) from lf.sys_meta;
----------------------------------------------------------------------------------------------------- 17.元数据文件表
@@ -585,7 +585,7 @@
  fileid integer default 0,
  guid varchar(40) default new_guid(),
  path varchar(512),
  sizes bigint default 0,
  sizes float default 0,
  create_user integer default 1,
  create_time timestamp(6) without time zone default now(),
  update_user integer,
@@ -598,7 +598,7 @@
comment on column lf.sys_meta_file.fileid is '父文件ID:0-没有';
comment on column lf.sys_meta_file.guid is '文件ID';
comment on column lf.sys_meta_file.path is '存储路径';
comment on column lf.sys_meta_file.sizes is '文件大小';
comment on column lf.sys_meta_file.sizes is '文件大小:单位MB';
comment on column lf.sys_meta_file.create_user is '创建人ID';
comment on column lf.sys_meta_file.create_time is '创建时间';
comment on column lf.sys_meta_file.update_user is '更新人ID';
@@ -615,7 +615,7 @@
  tab_guid varchar(40),
  guid varchar(40) default new_guid(),
  path varchar(512),
  sizes bigint default 0;
  sizes float8 default 0;
  create_user integer default 1,
  create_time timestamp(6) without time zone default now(),
  update_user integer,
@@ -628,7 +628,7 @@
comment on column lf.sys_attach.tab_guid is '表ID';
comment on column lf.sys_attach.guid is '文件ID';
comment on column lf.sys_attach.path is '存储路径';
comment on column lf.sys_attach.sizes is '文件大小';
comment on column lf.sys_attach.sizes is '文件大小:单位MB';
comment on column lf.sys_attach.create_user is '创建人ID';
comment on column lf.sys_attach.create_time is '创建时间';
comment on column lf.sys_attach.update_user is '更新人ID';
@@ -636,6 +636,7 @@
--insert into lf.sys_attach (name,tab,path) values ('a.jpg','public.data_dir','c:\a.jpg');
--alter table lf.sys_attach add tab_guid varchar(40);
--alter table lf.sys_attach add sizes bigint default 0;
--alter table lf.sys_attach alter column sizes type float8;
select * from lf.sys_attach; select length(guid) from lf.sys_attach limit 1; select * from lf.sys_attach;
----------------------------------------------------------------------------------------------------- 19.版本表
src/main/java/com/lf/server/entity/data/MetaEntity.java
@@ -22,7 +22,7 @@
    private String type;
    private long sizes;
    private double sizes;
    private String cs;
@@ -95,11 +95,11 @@
        this.type = type;
    }
    public long getSizes() {
    public double getSizes() {
        return sizes;
    }
    public void setSizes(long sizes) {
    public void setSizes(double sizes) {
        this.sizes = sizes;
    }
src/main/java/com/lf/server/entity/data/MetaFileEntity.java
@@ -22,7 +22,7 @@
    private String path;
    private long sizes;
    private double sizes;
    private int createUser;
@@ -83,11 +83,11 @@
        this.path = path;
    }
    public long getSizes() {
    public double getSizes() {
        return sizes;
    }
    public void setSizes(long sizes) {
    public void setSizes(double sizes) {
        this.sizes = sizes;
    }
src/main/java/com/lf/server/entity/sys/AttachEntity.java
@@ -22,7 +22,7 @@
    private String path;
    private long sizes;
    private double sizes;
    private int createUser;
@@ -83,11 +83,11 @@
        this.path = path;
    }
    public long getSizes() {
    public double getSizes() {
        return sizes;
    }
    public void setSizes(long sizes) {
    public void setSizes(double sizes) {
        this.sizes = sizes;
    }
src/main/java/com/lf/server/helper/FileHelper.java
@@ -1,7 +1,7 @@
package com.lf.server.helper;
import java.io.File;
import java.util.Date;
import java.text.DecimalFormat;
/**
 * 文件帮助类
@@ -9,6 +9,10 @@
 */
public class FileHelper {
    private final static String POINT = ".";
    public static final double D1024 = 1024.0;
    public static final double D1050 = 1050.0;
    /**
     * 获取文件扩展名
@@ -135,11 +139,36 @@
    }
    /**
     * 获取临时路径
     *
     * @return
     * 字节单位换算
     */
    public static String getTempPath() {
        return StringHelper.YMD_HM_FORMAT.format(new Date());
    public static String formatByte(long byteNumber) {
        double kbNumber = byteNumber / D1024;
        if (kbNumber < D1024) {
            return new DecimalFormat("#.##KB").format(kbNumber);
        }
        double mbNumber = kbNumber / D1024;
        if (mbNumber < D1024) {
            return new DecimalFormat("#.##MB").format(mbNumber);
        }
        double gbNumber = mbNumber / D1024;
        if (gbNumber < D1024) {
            return new DecimalFormat("#.##GB").format(gbNumber);
        }
        double tbNumber = gbNumber / D1024;
        return new DecimalFormat("#.##TB").format(tbNumber);
    }
    /**
     * byte转MB
     */
    public static double sizeToMb(long size) {
        if (size < D1050) {
            return 0.001;
        }
        String str = String.format("%.3f", size / D1024 / D1024);
        return Double.parseDouble(str);
    }
}
src/main/java/com/lf/server/helper/PathHelper.java
@@ -27,7 +27,7 @@
    private static int sharePath = 1;
    private final static double D92 = 92;
    private final static double D90 = 90;
    private final static Log log = LogFactory.getLog(PathHelper.class);
@@ -120,7 +120,7 @@
     * 获取临时路径
     */
    public String getTempPath() {
        String tempName = FileHelper.getTempPath();
        String tempName = StringHelper.getDateFormat4();
        String tempPath = config.getTempPath();
        String path = tempPath + File.separator + tempName;
@@ -130,7 +130,7 @@
        }
        double ran = Math.random() * 99;
        if (ran > D92) {
        if (ran > D90) {
            deleteOldPath(tempPath);
        }
src/main/java/com/lf/server/helper/StringHelper.java
@@ -38,8 +38,6 @@
     */
    public static final SimpleDateFormat YMD_HM_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmm");
    public static final double D1024 = 1024.0;
    /**
     * 判断字符串,是否为数字
     */
@@ -122,23 +120,9 @@
    }
    /**
     * 字节单位换算
     * 获取日期格式化4:yyyyMMdd_HHmm
     */
    public static String formatByte(long byteNumber) {
        double kbNumber = byteNumber / D1024;
        if (kbNumber < D1024) {
            return new DecimalFormat("#.##KB").format(kbNumber);
        }
        double mbNumber = kbNumber / D1024;
        if (mbNumber < D1024) {
            return new DecimalFormat("#.##MB").format(mbNumber);
        }
        double gbNumber = mbNumber / D1024;
        if (gbNumber < D1024) {
            return new DecimalFormat("#.##GB").format(gbNumber);
        }
        double tbNumber = gbNumber / D1024;
        return new DecimalFormat("#.##TB").format(tbNumber);
    public static String getDateFormat4() {
        return YMD_HM_FORMAT.format(new Date());
    }
}
src/main/java/com/lf/server/service/all/ScheduleService.java
@@ -3,7 +3,7 @@
import com.lf.server.entity.all.RedisCacheKey;
import com.lf.server.entity.sys.ResEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.StringHelper;
import com.lf.server.helper.FileHelper;
import com.lf.server.service.sys.ResService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -103,9 +103,9 @@
        // 剩余
        long surplusByte = memory.getAvailable();
        map.put("totalMem", StringHelper.formatByte(totalByte));
        map.put("use", StringHelper.formatByte(totalByte - surplusByte));
        map.put("remainMem", StringHelper.formatByte(surplusByte));
        map.put("totalMem", FileHelper.formatByte(totalByte));
        map.put("use", FileHelper.formatByte(totalByte - surplusByte));
        map.put("remainMem", FileHelper.formatByte(surplusByte));
        map.put("usage", new DecimalFormat("#.##%").format((totalByte - surplusByte) * 1.0 / totalByte));
        return map;
src/main/java/com/lf/server/service/data/UploaderService.java
@@ -71,7 +71,7 @@
            String filePath = pathHelper.getTempPath() + File.separator + oldName;
            File newFile = new File(filePath);
            file.transferTo(newFile);
            long sizes = file.getSize();
            double sizes = FileHelper.sizeToMb(file.getSize());
            // 获取MD5
            String md5 = getFileMd5(filePath);
@@ -107,7 +107,7 @@
    /**
     * 获取附件实体类
     */
    protected AttachEntity getAttachEntity(UserEntity ue, String tab, String oldName, String md5, long sizes) {
    protected AttachEntity getAttachEntity(UserEntity ue, String tab, String oldName, String md5, double sizes) {
        AttachEntity entity = new AttachEntity();
        entity.setName(oldName);
        entity.setTab(tab);
@@ -270,9 +270,10 @@
                continue;
            }
            double sizes = FileHelper.sizeToMb(file.getSize());
            MetaFileEntity mf = new MetaFileEntity();
            mf.setName(file.getOriginalFilename());
            mf.setSizes(file.getSize());
            mf.setSizes(sizes);
            mf.setPath(path + File.separator + mf.getName());
            file.transferTo(new File(mf.getPath()));