Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdisk
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdisk
提交
40c4871c
提交
40c4871c
编写于
3月 18, 2021
作者:
tangyaolong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lite代码兼容disk,删除无引用代码
上级
74aac998
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
110 行删除
+14
-110
MetaDynamicModelExService.java
...ab/core/extensions/service/MetaDynamicModelExService.java
+14
-72
FileHelper.java
...util/src/main/java/cn/ibizlab/util/helper/FileHelper.java
+0
-38
未找到文件。
ibzdisk-core/src/main/java/cn/ibizlab/core/extensions/service/MetaDynamicModelExService.java
浏览文件 @
40c4871c
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.disk.domain.MetaDynamicModel
;
import
cn.ibizlab.core.disk.extensions.service.DiskCoreService
;
import
cn.ibizlab.core.disk.service.IMetaDynamicModelService
;
import
cn.ibizlab.core.disk.service.impl.MetaDynamicModelServiceImpl
;
import
cn.ibizlab.util.cache.listener.RedisPublisher
;
...
...
@@ -49,11 +50,8 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
return
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
ReflectionKit
.
getSuperClassGenericType
(
this
.
getClass
().
getSuperclass
(),
1
);
}
@Value
(
"${ibiz.filePath:/app/file/}"
)
private
String
fileRoot
;
@Autowired
private
FileService
fil
eService
;
DiskCoreService
diskCor
eService
;
@Autowired
private
IMetaDynamicModelService
dynamicModelService
;
...
...
@@ -62,7 +60,7 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
@Lazy
private
IBZWFFeignClient
wfClient
;
@Value
(
"${ibiz.dynamic.publishpath:
/app/file/dynamicModel/publicpath
}"
)
@Value
(
"${ibiz.dynamic.publishpath:
d:/app/file/dynamicModel/publicpath/net-disk
}"
)
private
String
publishPath
;
@Autowired
...
...
@@ -103,10 +101,9 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
if
(!
ObjectUtils
.
isEmpty
(
items
)
&&
items
.
size
()
>
1
)
{
throw
new
BadRequestAlertException
(
"单次只允许上传一个模型文件"
,
"MetaDynamicModel"
,
"unzip"
);
}
String
dirPath
=
this
.
fileRoot
+
"ibizutil"
+
File
.
separator
+
items
.
get
(
0
).
getId
();
File
parent
=
new
File
(
dirPath
);
if
(
parent
.
exists
()
&&
parent
.
isDirectory
()
&&
parent
.
listFiles
().
length
>
0
)
{
modelFile
=
new
File
(
FileHelper
.
getLatestFilePath
(
parent
.
listFiles
()));
File
parent
=
diskCoreService
.
getFile
(
items
.
get
(
0
).
getId
());
if
(
parent
.
exists
())
{
modelFile
=
parent
;
}
else
{
throw
new
InternalServerErrorException
(
"文件未找到"
);
}
...
...
@@ -171,18 +168,22 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
public
MetaDynamicModel
publish
(
MetaDynamicModel
et
)
{
et
=
get
(
et
.
getConfigid
());
String
systemId
=
et
.
getSystemId
();
String
dynamicId
=
et
.
getDynainstid
();
String
strModelFile
=
et
.
getModelfile
();
if
(
StringUtils
.
isEmpty
(
strModelFile
)
&&
StringUtils
.
isEmpty
(
et
.
getSystemId
()))
throw
new
BadRequestAlertException
(
String
.
format
(
"信息不足,请检查[%s]模型数据是否存在系统标识及模型文件"
,
et
.
getConfigid
()),
"MetaDynamicModel"
,
"
unzip
"
);
throw
new
BadRequestAlertException
(
String
.
format
(
"信息不足,请检查[%s]模型数据是否存在系统标识及模型文件"
,
et
.
getConfigid
()),
"MetaDynamicModel"
,
"
publish
"
);
List
<
FileItem
>
items
=
JSONArray
.
parseArray
(
strModelFile
,
FileItem
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
items
)
&&
items
.
size
()
>
1
)
throw
new
BadRequestAlertException
(
String
.
format
(
"模型解析失败,[%s]模型文件过多"
,
et
.
getConfigid
()),
"MetaDynamicModel"
,
"
unzip
"
);
throw
new
BadRequestAlertException
(
String
.
format
(
"模型解析失败,[%s]模型文件过多"
,
et
.
getConfigid
()),
"MetaDynamicModel"
,
"
publish
"
);
File
publishFile
=
new
File
(
getPublishPath
()
+
systemId
+
File
.
separator
+
et
.
getDynainstid
());
//删除发布目录中的历史文件
if
(
publishFile
.
exists
())
{
FileHelper
.
deleteDir
(
publishFile
.
getPath
());
}
File
modelFile
=
fileService
.
getFile
(
items
.
get
(
0
).
getId
());
if
(
ObjectUtils
.
isEmpty
(
items
)){
throw
new
BadRequestAlertException
(
String
.
format
(
"文件不存在,请在发布前确认文件是否已经上传!"
,
et
.
getConfigid
()),
"MetaDynamicModel"
,
"publish"
);
}
File
modelFile
=
diskCoreService
.
getFile
(
items
.
get
(
0
).
getId
());
String
unzipPath
=
modelFile
.
getParent
().
replace
(
"ibizutil"
,
"dynamicmodel"
);
File
unzipFile
=
new
File
(
unzipPath
);
//拷贝文件到发布目录
...
...
@@ -204,70 +205,11 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
redisPublisher
.
publisher
(
message
);
//激活当前et.
et
.
setStatus
(
StaticDict
.
DynamicModelStatus
.
ITEM_1
.
getValue
());
update
(
Wrappers
.<
MetaDynamicModel
>
lambdaUpdate
().
set
(
MetaDynamicModel:
:
getStatus
,
StaticDict
.
DynamicModelStatus
.
ITEM_0
.
getValue
()).
eq
(
MetaDynamicModel:
:
getSystemId
,
systemId
));
update
(
Wrappers
.<
MetaDynamicModel
>
lambdaUpdate
().
set
(
MetaDynamicModel:
:
getStatus
,
StaticDict
.
DynamicModelStatus
.
ITEM_0
.
getValue
()).
eq
(
MetaDynamicModel:
:
getSystemId
,
systemId
)
.
eq
(
MetaDynamicModel:
:
getDynainstid
,
dynamicId
)
);
update
(
et
);
return
et
;
}
/**
* 获取处理逻辑
*
* @param systemId
* @return
*/
@SneakyThrows
public
List
<
Map
<
String
,
Object
>>
getDynamicModel
(
String
systemId
)
{
String
pubPath
=
getPublishPath
()
+
systemId
;
List
<
Map
<
String
,
Object
>>
delogics
=
searchLogic
(
pubPath
);
if
(
ObjectUtils
.
isEmpty
(
delogics
))
{
throw
new
BadRequestAlertException
(
String
.
format
(
"在发布目录[%s]中没有找到系统[%s]动态模型文件"
,
pubPath
,
systemId
),
"MetaDynamicModel"
,
"getDynamicModel"
);
}
return
delogics
;
}
/**
* 从发布目录中查询 bpmn及drl
*
* @param path
* @return
*/
public
List
<
Map
<
String
,
Object
>>
searchLogic
(
String
path
)
{
List
<
Map
<
String
,
Object
>>
models
=
new
ArrayList
<>();
File
publish
=
new
File
(
path
);
if
(!
publish
.
exists
())
{
throw
new
BadRequestAlertException
(
String
.
format
(
"发布目录[%s]不存在"
,
publish
.
getPath
()),
"MetaDynamicModel"
,
"searchLogic"
);
}
File
[]
subFiles
=
publish
.
listFiles
();
if
(
null
!=
subFiles
)
{
for
(
File
subFile
:
subFiles
)
{
if
(
subFile
.
isDirectory
())
{
List
<
Map
<
String
,
Object
>>
subModels
=
searchLogic
(
subFile
.
getAbsolutePath
());
if
(!
ObjectUtils
.
isEmpty
(
subModels
))
{
models
.
addAll
(
subModels
);
}
}
else
if
(
subFile
.
isFile
()
&&
(!
subFile
.
getName
().
matches
(
wf_regex
))
&&
(
subFile
.
getName
().
endsWith
(
".bpmn"
)
||
subFile
.
getName
().
endsWith
(
".drl"
)))
{
InputStream
file
=
null
;
try
{
file
=
new
FileInputStream
(
subFile
);
Map
fileMap
=
new
HashMap
();
fileMap
.
put
(
"filename"
,
subFile
.
getName
().
toLowerCase
());
fileMap
.
put
(
"filepath"
,
subFile
.
getPath
().
replace
(
getPublishPath
(),
""
).
toLowerCase
());
fileMap
.
put
(
"filecontent"
,
IOUtils
.
toString
(
file
,
"UTF-8"
));
models
.
add
(
fileMap
);
}
catch
(
IOException
e
)
{
}
finally
{
try
{
if
(
file
!=
null
)
{
file
.
close
();
}
}
catch
(
IOException
e
)
{
}
}
}
}
}
return
models
;
}
/**
* 从查询工作流 bpmn
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/helper/FileHelper.java
浏览文件 @
40c4871c
...
...
@@ -7,15 +7,7 @@ import org.springframework.util.StringUtils;
import
java.io.*
;
import
java.nio.charset.Charset
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.time.Instant
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.zip.GZIPInputStream
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
...
...
@@ -139,36 +131,6 @@ public class FileHelper {
}
}
/**
* 获取相同路径下最新的文件
* @param files 传入文件组
* @return
*/
public
static
String
getLatestFilePath
(
File
[]
files
)
{
if
(
files
==
null
)
{
return
null
;
}
BasicFileAttributes
attr
=
null
;
Map
<
Long
,
String
>
compareMap
=
new
HashMap
();
Long
format
=
0L
;
try
{
for
(
File
file
:
files
)
{
Path
path
=
file
.
toPath
();
attr
=
Files
.
readAttributes
(
path
,
BasicFileAttributes
.
class
);
Instant
instant
=
attr
.
creationTime
().
toInstant
();
Long
compareDate
=
Long
.
parseLong
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
).
withZone
(
ZoneId
.
systemDefault
()).
format
(
instant
));
format
=
compareDate
>
format
?
compareDate
:
format
;
compareMap
.
put
(
format
,
path
.
toString
());
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
compareMap
.
get
(
format
);
}
/**
* 构建目录
* @param outputDir
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录