| | |
| | | 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), |
| | |
| | | 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 '分辨率'; |
| | |
| | | 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.元数据文件表 |
| | |
| | | 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, |
| | |
| | | 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'; |
| | |
| | | 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, |
| | |
| | | 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'; |
| | |
| | | --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.版本表 |
| | |
| | | |
| | | private String type; |
| | | |
| | | private long sizes; |
| | | private double sizes; |
| | | |
| | | private String cs; |
| | | |
| | |
| | | this.type = type; |
| | | } |
| | | |
| | | public long getSizes() { |
| | | public double getSizes() { |
| | | return sizes; |
| | | } |
| | | |
| | | public void setSizes(long sizes) { |
| | | public void setSizes(double sizes) { |
| | | this.sizes = sizes; |
| | | } |
| | | |
| | |
| | | |
| | | private String path; |
| | | |
| | | private long sizes; |
| | | private double sizes; |
| | | |
| | | private int createUser; |
| | | |
| | |
| | | this.path = path; |
| | | } |
| | | |
| | | public long getSizes() { |
| | | public double getSizes() { |
| | | return sizes; |
| | | } |
| | | |
| | | public void setSizes(long sizes) { |
| | | public void setSizes(double sizes) { |
| | | this.sizes = sizes; |
| | | } |
| | | |
| | |
| | | |
| | | private String path; |
| | | |
| | | private long sizes; |
| | | private double sizes; |
| | | |
| | | private int createUser; |
| | | |
| | |
| | | this.path = path; |
| | | } |
| | | |
| | | public long getSizes() { |
| | | public double getSizes() { |
| | | return sizes; |
| | | } |
| | | |
| | | public void setSizes(long sizes) { |
| | | public void setSizes(double sizes) { |
| | | this.sizes = sizes; |
| | | } |
| | | |
| | |
| | | package com.lf.server.helper; |
| | | |
| | | import java.io.File; |
| | | import java.util.Date; |
| | | import java.text.DecimalFormat; |
| | | |
| | | /** |
| | | * 文件帮助类 |
| | |
| | | */ |
| | | public class FileHelper { |
| | | private final static String POINT = "."; |
| | | |
| | | public static final double D1024 = 1024.0; |
| | | |
| | | public static final double D1050 = 1050.0; |
| | | |
| | | /** |
| | | * 获取文件扩展名 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取临时路径 |
| | | * |
| | | * @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); |
| | | } |
| | | } |
| | |
| | | |
| | | 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); |
| | | |
| | |
| | | * 获取临时路径 |
| | | */ |
| | | public String getTempPath() { |
| | | String tempName = FileHelper.getTempPath(); |
| | | String tempName = StringHelper.getDateFormat4(); |
| | | String tempPath = config.getTempPath(); |
| | | String path = tempPath + File.separator + tempName; |
| | | |
| | |
| | | } |
| | | |
| | | double ran = Math.random() * 99; |
| | | if (ran > D92) { |
| | | if (ran > D90) { |
| | | deleteOldPath(tempPath); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static final SimpleDateFormat YMD_HM_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmm"); |
| | | |
| | | public static final double D1024 = 1024.0; |
| | | |
| | | /** |
| | | * 判断字符串,是否为数字 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 字节单位换算 |
| | | * 获取日期格式化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()); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | |
| | | // 剩余 |
| | | 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; |
| | |
| | | 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); |
| | |
| | | /** |
| | | * 获取附件实体类 |
| | | */ |
| | | 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); |
| | |
| | | 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())); |