Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
084cc709
提交
084cc709
编写于
12月 28, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
job逻辑优化
上级
126889db
变更
1
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
77 行增加
和
62 行删除
+77
-62
PermissionSyncJob.java.ftl
...in/java/%SYS_PKGPATH%/util/job/PermissionSyncJob.java.ftl
+77
-62
未找到文件。
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/job/PermissionSyncJob.java.ftl
浏览文件 @
084cc709
...
...
@@ -43,6 +43,7 @@ import org.springframework.boot.ApplicationRunner;
import
org
.
springframework
.
boot
.
autoconfigure
.
condition
.
ConditionalOnProperty
;
import
org
.
springframework
.
context
.
annotation
.
Lazy
;
import
org
.
springframework
.
stereotype
.
Component
;
import
org
.
springframework
.
util
.
ObjectUtils
;
import
org
.
springframework
.
util
.
DigestUtils
;
import
java
.
io
.
InputStream
;
import
java
.
util
.*;
...
...
@@ -55,33 +56,33 @@ import java.util.*;
@
ConditionalOnProperty
(
name
=
"ibiz.enablePermissionValid"
,
havingValue
=
"true"
)
public
class
PermissionSyncJob
implements
ApplicationRunner
{
@
Autowired
@
Lazy
private
IBZUAAFeignClient
client
;
@
Value
(
"${r'$'}{ibiz.systemid:${sid}}"
)
private
String
systemId
;
@
Value
(
"${r'$'}{ibiz.systemname:${sname}}"
)
private
String
systemName
;
@
Autowired
@
Lazy
private
IBZUAAFeignClient
client
;
@
Autowired
@
Lazy
IBZLiteFeignClient
liteFeignClient
;
<#
if
hasWF
>
@
Autowired
@
Lazy
private
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZWFFeignClient
client2
;
</#
if
>
<#
if
hasMsgTemplate
>
@
Autowired
@
Lazy
private
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZNotifyFeignClient
notifyFeignClient
;
</#
if
>
@
Autowired
@
Lazy
IBZLiteFeignClient
liteFeignClient
;
<#
if
hasPredefinedCodeList
>
@
Autowired
@
Lazy
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZDictFeignClient
dictFeignClient
;
...
...
@@ -91,83 +92,97 @@ public class PermissionSyncJob implements ApplicationRunner {
public
void
run
(
ApplicationArguments
args
)
{
try
{
Thread
.
sleep
(
10000
);
InputStream
permission
=
this
.
getClass
().
getResourceAsStream
(
"/permission/systemResource.json"
);
//
获取当前系统所有实体资源能力
String
permissionResult
=
IOUtils
.
toString
(
permission
,
"UTF-8"
);
JSONObject
system
=
new
JSONObject
();
system
.
put
(
"pssystemid"
,
systemId
);
system
.
put
(
"pssystemname"
,
systemName
);
system
.
put
(
"sysstructure"
,
JSONObject
.
parseObject
(
permissionResult
));
system
.
put
(
"md5check"
,
DigestUtils
.
md5DigestAsHex
(
permissionResult
.
getBytes
()));
if
(
client
.
syncSysAuthority
(
system
))
{
log
.
info
(
"向[UAA]同步系统资源成功"
);
}
else
{
log
.
error
(
"向[UAA]同步系统资源失败"
);
}
}
catch
(
Exception
ex
)
{
log
.
error
(
String
.
format
(
"向[UAA]同步系统资源失败,请检查[UAA]服务是否正常! [%s]"
,
ex
));
InputStream
permission
=
this
.
getClass
().
getResourceAsStream
(
"/permission/systemResource.json"
);
//
权限资源
if
(
!ObjectUtils.isEmpty(permission)) {
String
strPermission
=
IOUtils
.
toString
(
permission
,
"UTF-8"
);
JSONObject
system
=
new
JSONObject
()
{{
put
(
"pssystemid"
,
systemId
);
put
(
"pssystemid"
,
systemName
);
put
(
"sysstructure"
,
JSONObject
.
parseObject
(
strPermission
));
put
(
"md5check"
,
DigestUtils
.
md5DigestAsHex
(
strPermission
.
getBytes
()));
}};
if
(
uaaClient
.
syncSysAuthority
(
system
))
{
log
.
info
(
"向[uaa]同步系统资源成功"
);
}
else
{
log
.
error
(
"向[uaa]同步系统资源失败"
);
}
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"向[uaa]同步系统资源失败,请检查[uaa]服务是否正常运行! {}"
,
ex
.
getMessage
());
}
try
{
InputStream
sysModel
=
this
.
getClass
().
getResourceAsStream
(
"/sysmodel/${sys.codeName}.json"
);
//
获取当前系统所有实体资源能力
String
strSysModel
=
IOUtils
.
toString
(
sysModel
,
"UTF-8"
);
if
(
liteFeignClient
.
syncSysModel
(
JSONObject
.
parseObject
(
strSysModel
)))
{
log
.
info
(
"向[lite]同步系统模型成功"
);
}
else
{
log
.
error
(
"向[lite]同步系统模型失败"
);
InputStream
model
=
this
.
getClass
().
getResourceAsStream
(
"/sysmodel/${sys.codeName}.json"
);
//
系统模型
if
(
!ObjectUtils.isEmpty(model)) {
String
strModel
=
IOUtils
.
toString
(
model
,
"UTF-8"
);
if
(
liteClient
.
syncSysModel
(
JSONObject
.
parseObject
(
strModel
)))
{
log
.
info
(
"向[lite]同步模型成功"
);
}
else
{
log
.
error
(
"向[lite]同步模型失败"
);
}
}
catch
(
Exception
ex
)
{
log
.
error
(
String
.
format
(
"向[lite]同步系统模型失败,请检查[lite]服务是否正常! [%s]"
,
ex
));
}
catch
(
Exception
ex
)
{
log
.
error
(
"向[lite]同步系统模型失败,请检查[lite]服务是否正常运行! {}"
,
ex
.
getMessage
(
));
}
<#
if
hasWF
>
try
{
List
<
Map
<
String
,
Object
>>
bpmnfiles
=
new
ArrayList
();
try
{
List
<
Map
<
String
,
Object
>>
workflows
=
new
ArrayList
();
//
工作流
<#
list
sys
.
getAllPSWorkflows
()
as
wf
>
<#
if
wf
.
getPSWFVersions
()??>
<#
list
wf
.
getPSWFVersions
()
as
wfvs
>
bpmnfiles
.
add
(
new
HashMap
<
String
,
Object
>(){{
put
(
"${wfvs.codeName}.bpmn"
,
IOUtils
.
toString
(
this
.
getClass
().
getResourceAsStream
(
"/workflow/${wfvs.codeName}.bpmn"
),
"UTF-8"
));}});
if
(
!ObjectUtils.isEmpty(this.getClass().getResourceAsStream("/workflow/${wfvs.codeName}.bpmn"))) {
workflows
.
add
(
new
HashMap
<
String
,
Object
>()
{{
put
(
"${wfvs.codeName}.bpmn"
,
IOUtils
.
toString
(
this
.
getClass
().
getResourceAsStream
(
"/workflow/${wfvs.codeName}.bpmn"
),
"UTF-8"
));
}});
}
</#
list
>
</#
if
>
</#
list
>
if
(
client2
.
deployBpmnFile
(
bpmnfiles
))
{
log
.
info
(
"部署流程成功"
);
}
else
{
log
.
error
(
"部署流程失败"
);
if
(
workflows
.
size
()
>
0
)
{
if
(
wfClient
.
deployBpmnFile
(
workflows
))
{
log
.
info
(
"向[wf]部署流程成功"
);
}
else
{
log
.
error
(
"向[wf]部署流程失败"
);
}
}
catch
(
Exception
ex
)
{
log
.
error
(
String
.
format
(
"部署流程失败,请检查[WF]服务是否正常! [%s]"
,
ex
));
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"向[wf]部署流程失败,请检查[wf]服务是否正常运行! {}"
,
ex
.
getMessage
());
}
</#
if
>
<#
if
hasMsgTemplate
>
try
{
InputStream
msgTemplate
=
this
.
getClass
().
getResourceAsStream
(
"/msgtempl/systemMsgTempl.json"
);
//
获取当前系统所有实体资源能力
String
strMsgTemplate
=
IOUtils
.
toString
(
msgTemplate
,
"UTF-8"
);
JSONObject
template
=
new
JSONObject
();
template
.
put
(
"template"
,
JSONArray
.
parseArray
(
strMsgTemplate
));
if
(
notifyFeignClient
.
createMsgTemplate
(
template
))
{
log
.
info
(
"推送消息模板成功"
);
}
else
{
log
.
error
(
"推送消息模板失败"
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"推送消息模板失败"
);
InputStream
template
=
this
.
getClass
().
getResourceAsStream
(
"/msgtempl/systemMsgTempl.json"
);
//
消息模板
if
(
!ObjectUtils.isEmpty(template)) {
String
strTemplate
=
IOUtils
.
toString
(
template
,
"UTF-8"
);
if
(
notifyClient
.
createMsgTemplate
(
new
JSONObject
()
{{
put
(
"template"
,
JSONArray
.
parseArray
(
strTemplate
));
}}))
{
log
.
info
(
"向[notify]同步消息模板成功"
);
}
else
{
log
.
error
(
"向[notify]同步消息模板失败"
);
}
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"向[notify]同步消息模板失败,请检查[notify]服务是否正常运行! {}"
,
ex
.
getMessage
());
}
</#
if
>
<#
if
hasPredefinedCodeList
>
try
{
InputStream
runtimeDict
=
this
.
getClass
().
getResourceAsStream
(
"/sysmodel/RuntimeDict.json"
);
//
获取当前系统所有实体资源能力
String
strRuntimeDict
=
IOUtils
.
toString
(
runtimeDict
,
"UTF-8"
);
if
(
dictFeignClient
.
syncRuntimeDict
(
JSONArray
.
parseArray
(
strRuntimeDict
)))
{
log
.
info
(
"推送系统预置代码表成功"
);
}
else
{
log
.
error
(
"推送系统预置代码表失败"
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"推送系统预置代码表失败"
);
InputStream
dict
=
this
.
getClass
().
getResourceAsStream
(
"/sysmodel/RuntimeDict.json"
);
//
代码表
if
(
!ObjectUtils.isEmpty(dict)) {
String
strDict
=
IOUtils
.
toString
(
dict
,
"UTF-8"
);
if
(
dictClient
.
syncRuntimeDict
(
JSONArray
.
parseArray
(
strDict
)))
{
log
.
info
(
"向[dict]同步代码表成功"
);
}
else
{
log
.
error
(
"向[dict]同步代码表失败"
);
}
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"向[dict]同步代码表失败,请检查[dict]服务是否正常运行! {}"
,
ex
.
getMessage
());
}
</#
if
>
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录