Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
6458ad97
提交
6458ad97
编写于
1月 05, 2021
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
差异文件
合并分支 'dev' 到 'master'
Dev 查看合并请求
!40
上级
56054369
f0358ffe
变更
16
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
708 行增加
和
267 行删除
+708
-267
CHANGELOG.md
CHANGELOG.md
+12
-0
%PUBPRJ%-app-%APP_PKGPATH%.yaml.ftl
...PATH%/src/main/docker/%PUBPRJ%-app-%APP_PKGPATH%.yaml.ftl
+4
-0
logback-spring.xml.ftl
SLN/%PUBPRJ%-boot/src/main/resources/logback-spring.xml.ftl
+5
-6
%DE%InheritMapping.java.ftl
...H%/core/%MOD_PKGPATH%/mapping/%DE%InheritMapping.java.ftl
+4
-4
I%DE%Service.java.ftl
...PKGPATH%/core/%MOD_PKGPATH%/service/I%DE%Service.java.ftl
+5
-0
%DE%ServiceImpl.java.ftl
.../core/%MOD_PKGPATH%/service/impl/%DE%ServiceImpl.java.ftl
+46
-25
RocketMQConfig.java.ftl
...va/%SYS_PKGPATH%/core/util/config/RocketMQConfig.java.ftl
+0
-118
RocketMQConsumer.java.ftl
.../%SYS_PKGPATH%/core/util/config/RocketMQConsumer.java.ftl
+125
-0
RocketMQListenerProcessor.java.ftl
...PATH%/core/util/config/RocketMQListenerProcessor.java.ftl
+110
-0
RocketMQProducer.java.ftl
.../%SYS_PKGPATH%/core/util/config/RocketMQProducer.java.ftl
+106
-0
pom.xml.ftl
SLN/%PUBPRJ%-dependencies/pom.xml.ftl
+18
-17
%PUBPRJ%-provider-%SYSAPI_PKGPATH%.yaml.ftl
...c/main/docker/%PUBPRJ%-provider-%SYSAPI_PKGPATH%.yaml.ftl
+4
-0
%ITEM%Resource.java.ftl
...YS_PKGPATH%/%SYSAPI_PKGPATH%/rest/%ITEM%Resource.java.ftl
+56
-8
RocketMQAspect.java.ftl
...in/java/%SYS_PKGPATH%/util/aspect/RocketMQAspect.java.ftl
+74
-24
PermissionSyncJob.java.ftl
...in/java/%SYS_PKGPATH%/util/job/PermissionSyncJob.java.ftl
+79
-65
application-sys.yml.ftl
SLN/%PUBPRJ%-util/src/main/resources/application-sys.yml.ftl
+60
-0
未找到文件。
CHANGELOG.md
浏览文件 @
6458ad97
# **iBiz4j Spring R7 Template ChangeLog**
## [v2021.01.05]
-
修复:mybatis游标异常
-
修复:liquibase内网环境启动错误
-
修复:save带id时保存时,无法填充createDate的问题
-
修复:service中ProxyService无法注入子服务对象
-
优化:实体数据同步(RocketMQ)消息发送与接收逻辑
-
优化:logback 日志文件到达上限后重新生成新日志文件
-
优化:补充 docker 故障重启次数
-
优化:资源同步服务(PermissionSyncJob)逻辑优化
-
优化:服务接口补充空的返回值类型
-
优化:服务接口补充实体行为批处理,用于界面行为多项数据
## [v2020.12.13]
-
支持工作流操作视图、操作表单配置
-
支持实体数据同步(RocketMQ)
...
...
SLN/%PUBPRJ%-app/%PUBPRJ%-app-%APP_PKGPATH%/src/main/docker/%PUBPRJ%-app-%APP_PKGPATH%.yaml.ftl
浏览文件 @
6458ad97
...
...
@@ -103,6 +103,10 @@ services:
memory: 256M
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
volumes:
- "nfs:/app/file"
...
...
SLN/%PUBPRJ%-boot/src/main/resources/logback-spring.xml.ftl
浏览文件 @
6458ad97
...
...
@@ -31,18 +31,17 @@ TARGET=PSSYSTEM
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${r'${LOG_PATH}'}/${sys.getCodeName()?lower_case}.%d{yyyy-MM-dd}.log</FileNamePattern>
<FileNamePattern>${r'${LOG_PATH}'}/${sys.getCodeName()?lower_case}.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件最大的大小-->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${r'${LOG_PATTERN}'}</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>100MB</MaxFileSize>
</triggeringPolicy>
</appender>
<!-- 日志输出级别 -->
<root level="INFO">
...
...
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/%MOD_PKGPATH%/mapping/%DE%InheritMapping.java.ftl
浏览文件 @
6458ad97
...
...
@@ -60,7 +60,7 @@ public interface ${de.codeName}InheritMapping {
</#
list
>
</#
if
>
})
${
majorIndexDECodeName
}
to
${
majorIndexDECodeNameCamel
}(${
MinorIndexDECodeName
}
${
MinorIndexDECodeName
?
lower_case
}
);
${
majorIndexDECodeName
}
to
${
majorIndexDECodeNameCamel
}(${
MinorIndexDECodeName
}
minorEntity
);
@
Mappings
({
@
Mapping
(
source
=
"${majorIndexDEKeyFieldCodeName}"
,
target
=
"${MinorIndexDEKeyFieldCodeName}"
),
...
...
@@ -81,11 +81,11 @@ public interface ${de.codeName}InheritMapping {
</#
list
>
</#
if
>
})
${
MinorIndexDECodeName
}
to
${
MinorIndexDECodeNameCamel
}(${
majorIndexDECodeName
}
${
majorIndexDECodeName
?
lower_case
}
);
${
MinorIndexDECodeName
}
to
${
MinorIndexDECodeNameCamel
}(${
majorIndexDECodeName
}
majorEntity
);
List
<${
majorIndexDECodeName
}>
to
${
majorIndexDECodeNameCamel
}(
List
<${
MinorIndexDECodeName
}>
${
MinorIndexDECodeName
?
lower_case
}
);
List
<${
majorIndexDECodeName
}>
to
${
majorIndexDECodeNameCamel
}(
List
<${
MinorIndexDECodeName
}>
minorEntities
);
List
<${
MinorIndexDECodeName
}>
to
${
MinorIndexDECodeNameCamel
}(
List
<${
majorIndexDECodeName
}>
${
majorIndexDECodeName
?
lower_case
}
);
List
<${
MinorIndexDECodeName
}>
to
${
MinorIndexDECodeNameCamel
}(
List
<${
majorIndexDECodeName
}>
majorEntities
);
}
</#
if
>
...
...
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/%MOD_PKGPATH%/service/I%DE%Service.java.ftl
浏览文件 @
6458ad97
...
...
@@ -44,6 +44,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
*
实体
[${
item
.
codeName
}]
服务对象接口
*/
<#
if
item
.
getDSLink
??
&&
item
.
getDSLink
()??>
<#
if
item
.
getDSLink
()
!='DEFAULT'>
@
com
.
baomidou
.
dynamic
.
datasource
.
annotation
.
DS
(
"${item.getDSLink()?lower_case}"
)
</#
if
>
</#
if
>
public
interface
I
${
item
.
codeName
}
Service
extends
IService
<${
item
.
codeName
}>
{
<@
addIDESerivceBody
/>
...
...
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/%MOD_PKGPATH%/service/impl/%DE%ServiceImpl.java.ftl
浏览文件 @
6458ad97
...
...
@@ -67,6 +67,9 @@ TARGET=PSDATAENTITY
</#
list
>
</#
if
>
<#
assign
isDupCheck
=
isDupCheckEntity
(
de
)>
<#
assign
keyfield
=
de
.
getKeyPSDEField
()>
<#
assign
keyfieldPrivateCodeName
=
srfcaseformat
(
keyfield
.
getCodeName
(),
'l_u2lC'
)
>
<#
assign
keyfieldPublicCodeName
=
keyfieldPrivateCodeName
?
cap_first
>
package
${
pub
.
getPKGCodeName
()}.
core
.${
item
.
getPSSystemModule
().
getCodeName
()?
lower_case
}.
service
.
impl
;
import
java
.
io
.
Serializable
;
...
...
@@ -122,10 +125,6 @@ import org.springframework.util.StringUtils;
@
Service
(
"${item.getCodeName()}ServiceImpl"
)
public
class
${
item
.
getCodeName
()}
ServiceImpl
extends
ServiceImpl
<${
de
.
getCodeName
()}
Mapper
,
${
de
.
getCodeName
()}>
implements
I
${
de
.
getCodeName
()}
Service
{
<#
assign
keyfield
=
de
.
getKeyPSDEField
()>
<#
assign
keyfieldPrivateCodeName
=
srfcaseformat
(
keyfield
.
getCodeName
(),
'l_u2lC'
)
>
<#
assign
keyfieldPublicCodeName
=
keyfieldPrivateCodeName
?
cap_first
>
<#
comment
>
引入关联依赖
-
从关系
</#
comment
>
<#
if
de
.
getMajorPSDERs
()??>
<#
list
de
.
getMajorPSDERs
()
as
der
>
...
...
@@ -451,7 +450,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
if
(
null
==
et
)
{
return
false
;
}
else
{
return
checkKey
(
et
)
?
this
.
update
(
et
)
:
this
.
create
(
et
);
return
checkKey
(
et
)
?
getProxyService
().
update
(
et
)
:
getProxyService
()
.
create
(
et
);
}
}
...
...
@@ -463,7 +462,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#
if
hasMinorPSDERs
gt
0
>
list
.
forEach
(
item
->
fillParentData
(
item
));
</#
if
>
saveOrUpdateBatch
(
list
,
batchSize
);
<@
saveBatch
/>
return
true
;
}
...
...
@@ -475,7 +474,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#
if
hasMinorPSDERs
gt
0
>
list
.
forEach
(
item
->
fillParentData
(
item
));
</#
if
>
saveOrUpdateBatch
(
list
,
batchSize
);
<@
saveBatch
/>
}
<#
elseif
deaction
.
getCodeName
()?
lower_case
==
"remove"
>
...
...
@@ -646,11 +645,11 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
_create
.
add
(
sub
);
}
if
(
_update
.
size
()>
0
)
proxyService
.
updateBatch
(
_update
);
getProxyService
()
.
updateBatch
(
_update
);
if
(
_create
.
size
()>
0
)
proxyService
.
createBatch
(
_create
);
getProxyService
()
.
createBatch
(
_create
);
if
(
delIds
.
size
()>
0
)
proxyService
.
removeBatch
(
delIds
);
getProxyService
()
.
removeBatch
(
delIds
);
}
</#
if
>
...
...
@@ -993,6 +992,9 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#
comment
>
重复值检查
-
searchContext
</#
comment
>
<@
outputSearchContext
/>
<#
comment
>
引入
proxyservice
</#
comment
>
<@
autowiredProxyService
/>
}
<#
comment
>
NOSQL
存储
</#
comment
>
...
...
@@ -1414,11 +1416,11 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
_create
.
add
(
sub
);
}
if
(
_update
.
size
()>
0
)
proxyService
.
updateBatch
(
_update
);
getProxyService
()
.
updateBatch
(
_update
);
if
(
_create
.
size
()>
0
)
proxyService
.
createBatch
(
_create
);
getProxyService
()
.
createBatch
(
_create
);
if
(
delIds
.
size
()>
0
)
proxyService
.
removeBatch
(
delIds
);
getProxyService
()
.
removeBatch
(
delIds
);
}
</#
if
>
...
...
@@ -1956,11 +1958,11 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
_create
.
add
(
sub
);
}
if
(
_update
.
size
()>
0
)
proxyService
.
updateBatch
(
_update
);
getProxyService
()
.
updateBatch
(
_update
);
if
(
_create
.
size
()>
0
)
proxyService
.
createBatch
(
_create
);
getProxyService
()
.
createBatch
(
_create
);
if
(
delIds
.
size
()>
0
)
proxyService
.
removeBatch
(
delIds
);
getProxyService
()
.
removeBatch
(
delIds
);
}
</#
if
>
...
...
@@ -2281,11 +2283,11 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
_create
.
add
(
sub
);
}
if
(
_update
.
size
()>
0
)
proxyService
.
updateBatch
(
_update
);
getProxyService
()
.
updateBatch
(
_update
);
if
(
_create
.
size
()>
0
)
proxyService
.
createBatch
(
_create
);
getProxyService
()
.
createBatch
(
_create
);
if
(
delIds
.
size
()>
0
)
proxyService
.
removeBatch
(
delIds
);
getProxyService
()
.
removeBatch
(
delIds
);
}
</#
if
>
...
...
@@ -2672,9 +2674,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#
comment
>
注入代理行为
</#
comment
>
<#
macro
autowiredProxyService
>
<#
if
!P.exists(de.codeName,'proxyService')>
@
Autowired
@
Lazy
I
${
de
.
codeName
}
Service
proxyService
;
public
I
${
de
.
getCodeName
()}
Service
getProxyService
()
{
return
${
pub
.
getPKGCodeName
()}.
util
.
security
.
SpringContextHolder
.
getBean
(
this
.
getClass
());
}
</#
if
>
</#
macro
>
...
...
@@ -2795,7 +2797,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
@
Transactional
public
JSONObject
importData
(
List
<${
de
.
codeName
}>
entities
,
int
batchSize
,
boolean
isIgnoreError
)
{
if
(
entities
.
size
()>
syncImportLimit
){
proxyService
.
asyncImportData
(
entities
,
batchSize
,
isIgnoreError
);
getProxyService
()
.
asyncImportData
(
entities
,
batchSize
,
isIgnoreError
);
JSONObject
rs
=
new
JSONObject
();
rs
.
put
(
"rst"
,
0
);
rs
.
put
(
"msg"
,
String
.
format
(
"当前导入数据已超过同步导入数量上限[%s],系统正在进行异步导入,请稍后!"
,
syncImportLimit
));
...
...
@@ -2871,10 +2873,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
}
}
if
(
_update
.
size
()>
0
)
{
proxyService
.
updateBatch
(
_update
);
getProxyService
()
.
updateBatch
(
_update
);
}
if
(
_create
.
size
()>
0
)
{
proxyService
.
createBatch
(
_create
);
getProxyService
()
.
createBatch
(
_create
);
}
}
</#
if
>
...
...
@@ -3070,4 +3072,23 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
}
</#
macro
>
<#
comment
>
批量保存
</#
comment
>
<#
macro
saveBatch
>
List
<${
item
.
getCodeName
()}>
create
=
new
ArrayList
<>();
List
<${
item
.
getCodeName
()}>
update
=
new
ArrayList
<>();
for
(${
item
.
getCodeName
()}
et
:
list
)
{
if
(
ObjectUtils
.
isEmpty
(
et
.
get
${
keyfieldPublicCodeName
}())
||
ObjectUtils
.
isEmpty
(
getById
(
et
.
get
${
keyfieldPublicCodeName
}())))
{
create
.
add
(
et
);
}
else
{
update
.
add
(
et
);
}
}
if
(
create
.
size
()
>
0
)
{
getProxyService
().
createBatch
(
create
);
}
if
(
update
.
size
()
>
0
)
{
getProxyService
().
updateBatch
(
update
);
}
</#
macro
>
</#
if
>
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/util/config/RocketMQConfig.java.ftl
已删除
100644 → 0
浏览文件 @
56054369
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
assign
hasMQEntity
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
if
dataEntity
.
getAllPSDEDataSyncs
??
&&
dataEntity
.
getAllPSDEDataSyncs
()??>
<#
list
dataEntity
.
getAllPSDEDataSyncs
()
as
dataSync
>
<#
assign
hasMQEntity
=
true
>
<#
break
>
</#
list
>
</#
if
>
</#
list
>
<#
if
hasMQEntity
>
<#
assign
nameAddress
=
"127.0.0.1:9876"
>
<#
assign
instanceName
=
"rmq-instance"
>
package
${
pub
.
getPKGCodeName
()}.
core
.
util
.
config
;
import
com
.
alibaba
.
fastjson
.
JSON
;
import
com
.
alibaba
.
rocketmq
.
client
.
consumer
.
DefaultMQPushConsumer
;
import
com
.
alibaba
.
rocketmq
.
client
.
consumer
.
listener
.
ConsumeConcurrentlyContext
;
import
com
.
alibaba
.
rocketmq
.
client
.
consumer
.
listener
.
ConsumeConcurrentlyStatus
;
import
com
.
alibaba
.
rocketmq
.
client
.
consumer
.
listener
.
MessageListenerConcurrently
;
import
com
.
alibaba
.
rocketmq
.
client
.
producer
.
DefaultMQProducer
;
import
com
.
alibaba
.
rocketmq
.
common
.
message
.
MessageExt
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
context
.
annotation
.
Bean
;
import
org
.
springframework
.
context
.
annotation
.
Configuration
;
import
org
.
springframework
.
context
.
annotation
.
Lazy
;
import
java
.
util
.
List
;
@
Slf4j
@
Configuration
public
class
RocketMQConfig
{
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
if
dataEntity
.
getAllPSDEDataSyncs
??
&&
dataEntity
.
getAllPSDEDataSyncs
()??>
<#
list
dataEntity
.
getAllPSDEDataSyncs
()
as
dataSync
>
<#
if
dataSync
.
getOutPSSysDataSyncAgent
??
&&
dataSync
.
getOutPSSysDataSyncAgent
()??>
<#
assign
syncAgent
=
dataSync
.
getOutPSSysDataSyncAgent
()>
<#
assign
producer
=
dataEntity
.
codeName
+
syncAgent
.
codeName
+
"producer"
>
<#
if
((
syncAgent
.
getAgentTag
())
!'')!=''>
<#
assign
nameAddress
=
syncAgent
.
getAgentTag
()>
</#
if
>
<#
if
((
syncAgent
.
getAgentTag2
())
!'')!=''>
<#
assign
instanceName
=
syncAgent
.
getAgentTag2
()>
</#
if
>
@
Bean
(
"${producer}"
)
public
DefaultMQProducer
${
srfmethodname
(
producer
)}(){
DefaultMQProducer
producer
=
null
;
try
{
producer
=
new
DefaultMQProducer
();
producer
.
setSendMsgTimeout
(
6000
);
producer
.
setNamesrvAddr
(
"${nameAddress}"
);
producer
.
setInstanceName
(
"${instanceName}"
);
}
catch
(
Exception
e
){
log
.
error
(
"初始化消息发送对象异常!"
);
}
return
producer
;
}
</#
if
>
</#
list
>
</#
if
>
</#
list
>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
if
dataEntity
.
getAllPSDEDataSyncs
??
&&
dataEntity
.
getAllPSDEDataSyncs
()??>
<#
list
dataEntity
.
getAllPSDEDataSyncs
()
as
dataSync
>
<#
if
dataSync
.
getInPSSysDataSyncAgent
??
&&
dataSync
.
getInPSSysDataSyncAgent
()??>
<#
assign
syncAgent
=
dataSync
.
getInPSSysDataSyncAgent
()>
<#
assign
consumer
=
dataEntity
.
codeName
+
syncAgent
.
codeName
+
"consumer"
>
<#
assign
entityName
=
dataEntity
.
getCodeName
()>
<#
if
((
syncAgent
.
getAgentTag
())
!'')!=''>
<#
assign
nameAddress
=
syncAgent
.
getAgentTag
()>
</#
if
>
<#
if
((
syncAgent
.
getAgentTag2
())
!'')!=''>
<#
assign
instanceName
=
syncAgent
.
getAgentTag2
()>
</#
if
>
@
Autowired
@
Lazy
${
pub
.
getPKGCodeName
()}.
core
.${
dataEntity
.
getPSSystemModule
().
getCodeName
()?
lower_case
}.
service
.
I
${
entityName
}
Service
${
entityName
}
Service
;
@
Bean
(
"${consumer}"
)
public
DefaultMQPushConsumer
${
srfmethodname
(
consumer
)}(){
DefaultMQPushConsumer
consumer
=
null
;
try
{
consumer
=
new
DefaultMQPushConsumer
();
consumer
.
setNamesrvAddr
(
"${nameAddress}"
);
consumer
.
setInstanceName
(
"${instanceName}"
);
consumer
.
subscribe
(
"${dataSync.codeName}"
,
"${dataSync.codeName}"
);
consumer
.
registerMessageListener
(
new
MessageListenerConcurrently
()
{
public
ConsumeConcurrentlyStatus
consumeMessage
(
List
<
MessageExt
>
msgs
,
ConsumeConcurrentlyContext
context
)
{
for
(
MessageExt
msg
:
msgs
)
{
<#
if
dataSync
.
getInTestPSDEAction
()??>
<#
assign
inputAction
=
srfmethodname
(
dataSync
.
getInTestPSDEAction
().
codeName
)>
${
pub
.
getPKGCodeName
()}.
core
.${
dataEntity
.
getPSSystemModule
().
getCodeName
()?
lower_case
}.
domain
.${
entityName
}
domain
=
JSON
.
parseObject
(
new
String
(
msg
.
getBody
()),${
pub
.
getPKGCodeName
()}.
core
.${
dataEntity
.
getPSSystemModule
().
getCodeName
()?
lower_case
}.
domain
.${
entityName
}.
class
);
${
entityName
}
Service
.${
inputAction
}(
domain
);
<#
else
>
log
.
info
(
"接收到[]消息,但未配置实体输入过滤行为,消息将被忽略。"
+
new
String
(
msg
.
getBody
()));
</#
if
>
}
return
ConsumeConcurrentlyStatus
.
CONSUME_SUCCESS
;
}
});
consumer
.
start
();
}
catch
(
Exception
e
){
log
.
error
(
"初始化消息接收对象异常!"
);
}
return
consumer
;
}
</#
if
>
</#
list
>
</#
if
>
</#
list
>
}
</#
if
>
\ No newline at end of file
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/util/config/RocketMQConsumer.java.ftl
0 → 100644
浏览文件 @
6458ad97
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
assign
hasMQConsumer
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
if
dataEntity
.
getAllPSDEDataSyncs
??
&&
dataEntity
.
getAllPSDEDataSyncs
()??>
<#
list
dataEntity
.
getAllPSDEDataSyncs
()
as
dataSync
>
<#
if
dataSync
.
getInPSSysDataSyncAgent
??
&&
dataSync
.
getInPSSysDataSyncAgent
()??>
<#
assign
hasMQConsumer
=
true
>
<#
break
>
</#
if
>
</#
list
>
</#
if
>
</#
list
>
<#
if
hasMQConsumer
>
<#
comment
>
服务接口微服务平台配置
</#
comment
>
<#
assign
mqServerAddress
=
""
>
<#
if
sys
.
getAllPSDevSlnMSDepAPIs
()??>
<#
list
sys
.
getAllPSDevSlnMSDepAPIs
()
as
depSysApi
>
<#
if
depSysApi
.
getPSDCMSPlatform
()??
>
<#
if
depSysApi
.
getUserParam
(
"rocketmq.consumer.namesrvAddr"
,
""
)??>
<#
assign
mqServerAddress
=
depSysApi
.
getUserParam
(
"rocketmq.consumer.namesrvAddr"
,
""
)>
</#
if
>
</#
if
>
</#
list
>
</#
if
>
<#
if
mqServerAddress
!=''>
<#
assign
mqServer
=
"on"
>
<#
else
>
<#
assign
mqServer
=
"off"
>
</#
if
>
package
${
pub
.
getPKGCodeName
()}.
core
.
util
.
config
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
import
org
.
apache
.
rocketmq
.
client
.
consumer
.
DefaultMQPushConsumer
;
import
org
.
apache
.
rocketmq
.
client
.
exception
.
MQClientException
;
import
org
.
apache
.
rocketmq
.
client
.
producer
.
DefaultMQProducer
;
import
org
.
apache
.
rocketmq
.
common
.
consumer
.
ConsumeFromWhere
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Value
;
import
org
.
springframework
.
context
.
annotation
.
Bean
;
import
org
.
springframework
.
context
.
annotation
.
Configuration
;
import
org
.
springframework
.
context
.
annotation
.
Lazy
;
import
org
.
springframework
.
boot
.
autoconfigure
.
condition
.
ConditionalOnExpression
;
@
Slf4j
@
Configuration
@
ConditionalOnExpression
(
"'${r'${rocketmq.consumer.isOnOff:'+mqServer+"
}
'.equals('
on
')"}")
public class RocketMQConsumer {
@Value("${r'
${
rocketmq
.
consumer
.
groupName
:
default
}
'}")
private String groupName;
@Value("${r'
${
rocketmq
.
consumer
.
topic
:
default
}
'}")
private String topic;
@Value("${r'
${
rocketmq
.
consumer
.
namesrvAddr
:
127.0.0.1
:
9876
}
'}")
private String namesrvAddr;
@Value("${r'
${
rocketmq
.
consumer
.
consumeThreadMin
:
1
}
'}")
private Integer consumeThreadMin;
@Value("${r'
${
rocketmq
.
consumer
.
consumeThreadMax
:
1
}
'}")
private Integer consumeThreadMax;
@Value("${r'
${
rocketmq
.
consumer
.
consumeMessageBatchMaxSize
:
1
}
'}")
private Integer consumeMessageBatchMaxSize;
@Autowired
@Lazy
private RocketMQListenerProcessor listenerProcessor;
/**
* mq 消费者配置
*
* @return
* @throws MQClientException
*/
@Bean
public DefaultMQPushConsumer defaultConsumer() {
log.info("defaultConsumer 正在创建---------------------------------------");
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(groupName);
consumer.setNamesrvAddr(namesrvAddr);
consumer.setConsumeThreadMin(consumeThreadMin);
consumer.setConsumeThreadMax(consumeThreadMax);
consumer.setConsumeMessageBatchMaxSize(consumeMessageBatchMaxSize);
// 设置监听
consumer.registerMessageListener(listenerProcessor);
/**
* 设置consumer第一次启动是从队列头部开始还是队列尾部开始
* 如果不是第一次启动,那么按照上次消费的位置继续消费
*/
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
/**
* 设置消费模型,集群还是广播,默认为集群
*/
// consumer.setMessageModel(MessageModel.CLUSTERING);
try {
consumer.subscribe(topic, "${getSubscribeTags()}");
consumer.start();
log.info("rocketmq consumer 创建成功 groupName={}, topics={}, namesrvAddr={}", groupName, topic, namesrvAddr);
} catch (MQClientException e) {
log.error("rocketmq consumer 创建失败!" + e);
}
return consumer;
}
}
</#if>
<#function getSubscribeTags>
<#assign result="">
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getInPSSysDataSyncAgent?? && dataSync.getInPSSysDataSyncAgent()??>
<#if result!="">
<#assign result=result+" || ">
</#if>
<#assign result=result+dataSync.codeName?lower_case>
</#if>
</#list>
</#if>
</#list>
<#return result>
</#function>
\ No newline at end of file
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/util/config/RocketMQListenerProcessor.java.ftl
0 → 100644
浏览文件 @
6458ad97
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
assign
hasMQConsumer
=
false
>
<#
comment
>
实体中配置输入数据同步
</#
comment
>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
if
dataEntity
.
getAllPSDEDataSyncs
??
&&
dataEntity
.
getAllPSDEDataSyncs
()??>
<#
list
dataEntity
.
getAllPSDEDataSyncs
()
as
dataSync
>
<#
if
dataSync
.
getInPSSysDataSyncAgent
??
&&
dataSync
.
getInPSSysDataSyncAgent
()??>
<#
assign
hasMQConsumer
=
true
>
<#
break
>
</#
if
>
</#
list
>
</#
if
>
</#
list
>
<#
if
hasMQConsumer
>
<#
comment
>
服务接口微服务平台配置
</#
comment
>
<#
assign
mqServerAddress
=
""
>
<#
if
sys
.
getAllPSDevSlnMSDepAPIs
()??>
<#
list
sys
.
getAllPSDevSlnMSDepAPIs
()
as
depSysApi
>
<#
if
depSysApi
.
getPSDCMSPlatform
()??
>
<#
if
depSysApi
.
getUserParam
(
"rocketmq.consumer.namesrvAddr"
,
""
)??>
<#
assign
mqServerAddress
=
depSysApi
.
getUserParam
(
"rocketmq.consumer.namesrvAddr"
,
""
)>
</#
if
>
</#
if
>
</#
list
>
</#
if
>
<#
if
mqServerAddress
!=''>
<#
assign
mqServer
=
"on"
>
<#
else
>
<#
assign
mqServer
=
"off"
>
</#
if
>
package
${
pub
.
getPKGCodeName
()}.
core
.
util
.
config
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
import
com
.
alibaba
.
fastjson
.
JSON
;
import
org
.
apache
.
rocketmq
.
client
.
consumer
.
listener
.
ConsumeOrderlyContext
;
import
org
.
apache
.
rocketmq
.
client
.
consumer
.
listener
.
ConsumeOrderlyStatus
;
import
org
.
apache
.
rocketmq
.
client
.
consumer
.
listener
.
MessageListenerOrderly
;
import
org
.
springframework
.
boot
.
autoconfigure
.
condition
.
ConditionalOnExpression
;
import
org
.
apache
.
rocketmq
.
common
.
message
.
MessageExt
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
context
.
annotation
.
Lazy
;
import
org
.
springframework
.
stereotype
.
Component
;
import
org
.
springframework
.
util
.
CollectionUtils
;
import
java
.
util
.
List
;
/**
*
MQ
订阅消息处理
*/
@
Slf4j
@
Component
@
ConditionalOnExpression
(
"'${r'${rocketmq.consumer.isOnOff:'+mqServer+"
}
'.equals('
on
')"}")
public class RocketMQListenerProcessor implements MessageListenerOrderly {
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getInPSSysDataSyncAgent?? && dataSync.getInPSSysDataSyncAgent()?? &&dataSync.getInTestPSDEAction?? && dataSync.getInTestPSDEAction()??>
<#assign entityName=dataEntity.getCodeName()>
<#if !P.exists(entityName,"service")>
@Autowired
@Lazy
${pub.getPKGCodeName()}.core.${dataEntity.getPSSystemModule().getCodeName()?lower_case}.service.I${entityName}Service ${entityName}Service;
</#if>
</#if>
</#list>
</#if>
</#list>
@Override
public ConsumeOrderlyStatus consumeMessage(List<MessageExt> list, ConsumeOrderlyContext consumeOrderlyContext) {
if (CollectionUtils.isEmpty(list)) {
log.info("MQ接收消息为空,直接返回成功");
return ConsumeOrderlyStatus.SUCCESS;
}
for (MessageExt messageExt : list) {
log.info("MQ接收到的消息为:" + messageExt.toString());
try {
String topic = messageExt.getTopic();
String tags = messageExt.getTags();
String body = new String(messageExt.getBody(), "utf-8");
log.info("MQ消息topic={}, tags={}, 消息内容={}", topic, tags, body);
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getInPSSysDataSyncAgent?? && dataSync.getInPSSysDataSyncAgent()??>
<#assign dataSyncCodeName=dataSync.codeName?lower_case>
<#if dataSync.getInTestPSDEAction?? && dataSync.getInTestPSDEAction()??>
<#assign inputAction=srfmethodname(dataSync.getInTestPSDEAction().codeName)>
if ("${dataSyncCodeName}".equalsIgnoreCase(tags)) {
${pub.getPKGCodeName()}.core.${dataEntity.getPSSystemModule().getCodeName()?lower_case}.domain.${entityName} domain = JSON.parseObject(new String(body),${pub.getPKGCodeName()}.core.${dataEntity.getPSSystemModule().getCodeName()?lower_case}.domain.${entityName}.class);
${entityName}Service.${inputAction}(domain);
}
<#else>
log.info("接收到[{}]消息,但未配置实体输入过滤行为,消息将被忽略。"+new String(msg.getBody()));
</#if>
</#if>
</#list>
</#if>
</#list>
} catch (Exception e) {
log.error("获取MQ消息内容异常{}", e);
}
}
return ConsumeOrderlyStatus.SUCCESS;
}
}
</#if>
\ No newline at end of file
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/util/config/RocketMQProducer.java.ftl
0 → 100644
浏览文件 @
6458ad97
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
assign
hasMQProducer
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
if
dataEntity
.
getAllPSDEDataSyncs
??
&&
dataEntity
.
getAllPSDEDataSyncs
()??>
<#
list
dataEntity
.
getAllPSDEDataSyncs
()
as
dataSync
>
<#
if
dataSync
.
getOutPSSysDataSyncAgent
??
&&
dataSync
.
getOutPSSysDataSyncAgent
()??>
<#
assign
hasMQProducer
=
true
>
<#
break
>
</#
if
>
</#
list
>
</#
if
>
</#
list
>
<#
if
hasMQProducer
>
<#
comment
>
服务接口微服务平台配置
</#
comment
>
<#
assign
mqServerAddress
=
""
>
<#
if
sys
.
getAllPSDevSlnMSDepAPIs
()??>
<#
list
sys
.
getAllPSDevSlnMSDepAPIs
()
as
depSysApi
>
<#
if
depSysApi
.
getPSDCMSPlatform
()??
>
<#
if
depSysApi
.
getUserParam
(
"rocketmq.producer.namesrvAddr"
,
""
)??>
<#
assign
mqServerAddress
=
depSysApi
.
getUserParam
(
"rocketmq.producer.namesrvAddr"
,
""
)>
</#
if
>
</#
if
>
</#
list
>
</#
if
>
<#
if
mqServerAddress
!=''>
<#
assign
mqServer
=
"on"
>
<#
else
>
<#
assign
mqServer
=
"off"
>
</#
if
>
package
${
pub
.
getPKGCodeName
()}.
core
.
util
.
config
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
import
org
.
apache
.
rocketmq
.
client
.
consumer
.
DefaultMQPushConsumer
;
import
org
.
apache
.
rocketmq
.
client
.
exception
.
MQClientException
;
import
org
.
apache
.
rocketmq
.
client
.
producer
.
DefaultMQProducer
;
import
org
.
apache
.
rocketmq
.
common
.
consumer
.
ConsumeFromWhere
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Value
;
import
org
.
springframework
.
context
.
annotation
.
Bean
;
import
org
.
springframework
.
context
.
annotation
.
Configuration
;
import
org
.
springframework
.
context
.
annotation
.
Lazy
;
import
org
.
springframework
.
boot
.
autoconfigure
.
condition
.
ConditionalOnExpression
;
@
Slf4j
@
Configuration
@
ConditionalOnExpression
(
"'${r'${rocketmq.producer.isOnOff:'+mqServer+"
}
'.equals('
on
')"}")
public class RocketMQProducer {
@Value("${r'
${
rocketmq
.
producer
.
groupName
:
default
}
'}")
private String groupName;
@Value("${r'
${
rocketmq
.
producer
.
namesrvAddr
:
127.0.0.1
:
9876
}
'}")
private String namesrvAddr;
// 消息最大值
@Value("${r'
${
rocketmq
.
producer
.
maxMessageSize
:
409600
}
'}")
private Integer maxMessageSize;
// 消息发送超时时间
@Value("${r'
${
rocketmq
.
producer
.
sendMsgTimeOut
:
3000
}
'}")
private Integer sendMsgTimeOut;
// 失败重试次数
@Value("${r'
${
rocketmq
.
producer
.
retryTimesWhenSendFailed
:
2
}
'}")
private Integer retryTimesWhenSendFailed;
/**
* mq 生成者配置
*
* @return
* @throws MQClientException
*/
@Bean
public DefaultMQProducer defaultProducer() throws MQClientException {
log.info("rocketmq defaultProducer 正在创建---------------------------------------");
DefaultMQProducer producer = new DefaultMQProducer(groupName);
producer.setNamesrvAddr(namesrvAddr);
producer.setVipChannelEnabled(false);
producer.setMaxMessageSize(maxMessageSize);
producer.setSendMsgTimeout(sendMsgTimeOut);
producer.setRetryTimesWhenSendAsyncFailed(retryTimesWhenSendFailed);
producer.start();
log.info("rocketmq producer server 开启成功----------------------------------");
return producer;
}
}
</#if>
<#function getSubscribeTags>
<#assign result="">
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getInPSSysDataSyncAgent?? && dataSync.getInPSSysDataSyncAgent()??>
<#if result!="">
<#assign result=result+" || ">
</#if>
<#assign result=result+dataSync.codeName?lower_case>
</#if>
</#list>
</#if>
</#list>
<#return result>
</#function>
\ No newline at end of file
SLN/%PUBPRJ%-dependencies/pom.xml.ftl
浏览文件 @
6458ad97
...
...
@@ -52,15 +52,12 @@ TARGET=PSSYSTEM
<spring-cloud-openfeign.version>2.2.1.RELEASE</spring-cloud-openfeign.version>
<!-- Alibaba Druid -->
<alibaba-druid.version>1.1.
16
</alibaba-druid.version>
<alibaba-druid.version>1.1.
21
</alibaba-druid.version>
<!-- Mybatis Plus -->
<mybatis-plus.version>3.3.1</mybatis-plus.version>
<mybatis-plus-dynamic-datasource.version>3.0.0</mybatis-plus-dynamic-datasource.version>
<!-- Liquibase -->
<liquibase.version>3.6.3</liquibase.version>
<!-- Swagger2 -->
<springfox-swagger.version>2.9.2</springfox-swagger.version>
...
...
@@ -87,7 +84,7 @@ TARGET=PSSYSTEM
<jsonwebtoken-jjwt.version>0.9.1</jsonwebtoken-jjwt.version>
<!--Liquibase数据库版本更新工具-->
<liquibase.version>3.
8.7
</liquibase.version>
<liquibase.version>3.
9.0
</liquibase.version>
<!--H2内存数据库-->
<h2.version>1.4.200</h2.version>
...
...
@@ -117,7 +114,7 @@ TARGET=PSSYSTEM
<#list sys.getAllPSSystemDBConfigs() as dbConfig>
<#if dbConfig.getDBType()=='MYSQL5'>
<#elseif dbConfig.getDBType()=='ORACLE'>
<oracle.version>1
1.2.0.3
</oracle.version>
<oracle.version>1
9.8.0.0
</oracle.version>
<#elseif dbConfig.getDBType()=='POSTGRESQL'>
<postgresql.version>42.2.6</postgresql.version>
</#if>
...
...
@@ -339,13 +336,7 @@ TARGET=PSSYSTEM
</exclusions>
</dependency>
</#if>
<#if hasMQEntity>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>${r'${rocketmq.version}'}</version>
</dependency>
</#if>
</dependencies>
</dependencyManagement>
...
...
@@ -418,8 +409,13 @@ TARGET=PSSYSTEM
<#elseif dbConfig.getDBType()=='ORACLE'>
<!-- Oracle驱动包 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${r'${oracle.version}'}</version>
</dependency>
<dependency>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
<version>${r'${oracle.version}'}</version>
</dependency>
<#elseif dbConfig.getDBType()=='POSTGRESQL'>
...
...
@@ -432,7 +428,6 @@ TARGET=PSSYSTEM
</#if>
</#list>
</#if>
<#if bDynamicDS>
<!-- mp动态数据源 -->
<dependency>
...
...
@@ -440,13 +435,19 @@ TARGET=PSSYSTEM
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
</#if>
<#if hasESEntity>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
</#if>
<#if hasMQEntity>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>${r'${rocketmq.version}'}</version>
</dependency>
</#if>
<#comment>引用组件包</#comment>
<#if pub.getPSSysSFPubPkgs?? && pub.getPSSysSFPubPkgs()??>
...
...
SLN/%PUBPRJ%-provider/%PUBPRJ%-provider-%SYSAPI_PKGPATH%/src/main/docker/%PUBPRJ%-provider-%SYSAPI_PKGPATH%.yaml.ftl
浏览文件 @
6458ad97
...
...
@@ -110,6 +110,10 @@ services:
memory: 400M
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
volumes:
- "nfs:/app/file"
...
...
SLN/%PUBPRJ%-provider/%PUBPRJ%-provider-%SYSAPI_PKGPATH%/src/main/java/%SYS_PKGPATH%/%SYSAPI_PKGPATH%/rest/%ITEM%Resource.java.ftl
浏览文件 @
6458ad97
...
...
@@ -145,6 +145,10 @@ public class ${itemCodeName}Resource {
<#
assign
deaction
=
apiMethod
.
getPSDEAction
()>
<#
assign
deactionName
=
deaction
.
getName
()>
<#
assign
deactionCodeName
=
deaction
.
getCodeName
()>
<#
assign
apiReturnValueType
=
itemCodeName
+
"DTO"
>
<#
if
apiMethod
.
getReturnValueType
()??
&&
apiMethod
.
getReturnValueType
()?
lower_case
==
'void'
>
<#
assign
apiReturnValueType
=
"Void"
>
</#
if
>
<#
comment
>
输出主接口测试行为
</#
comment
>
<@
outputTestActionDetail
deaction
/>
<#
if
deaction
.
codeName
?
lower_case
==
'create'
>
...
...
@@ -252,7 +256,7 @@ public class ${itemCodeName}Resource {
<@
SecurityAnnotation
deaction
/>
@
ApiOperation
(
value
=
"${deaction.getLogicName()}"
,
tags
=
{
"${deLogicName}"
},
notes
=
"${deaction.getLogicName()}"
)
@
RequestMapping
(
method
=
RequestMethod
.${
reqMtd
},
value
=
"${fullPath}<#if deaction.getRequestParamType() == 'NONE'><#else>/{${itemCodeNameLC + keyCNLC}}</#if>/${deactionCodeName?lower_case}"
)
public
ResponseEntity
<${
itemCodeName
}
DTO
>
${
deactionCodeName
?
uncap_first
}(<#
if
deaction
.
getRequestParamType
()
==
'NONE'
><#
else
>${
id_etParams
}</#
if
>)
{
public
ResponseEntity
<${
apiReturnValueType
}
>
${
deactionCodeName
?
uncap_first
}(<#
if
deaction
.
getRequestParamType
()
==
'NONE'
><#
else
>${
id_etParams
}</#
if
>)
{
<#
if
deaction
.
getRequestParamType
()
==
'NONE'
>
${
deCodeName
}
domain
=
new
${
deCodeName
}();
domain
=
${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}(
domain
);
...
...
@@ -263,7 +267,11 @@ public class ${itemCodeName}Resource {
domain
=
${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}(
domain
);
${
itemCodeNameLC
}
dto
=
${
itemCodeNameLC
}
Mapping
.
toDto
(
domain
);
</#
if
>
<#
if
apiReturnValueType
?
lower_case
==
'void'
>
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
build
();
<#
else
>
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(${
itemCodeNameLC
}
dto
);
</#
if
>
}
<#
comment
>
自定义行为批处理
</#
comment
>
<#
if
(
deaction
.
getActionType
()==
'USERCUSTOM'
)>
...
...
@@ -433,6 +441,10 @@ public class ${itemCodeName}Resource {
<#
assign
deaction
=
apiMethod
.
getPSDEAction
()>
<#
assign
deactionName
=
deaction
.
getName
()>
<#
assign
deactionCodeName
=
deaction
.
getCodeName
()>
<#
assign
apiReturnValueType
=
itemCodeName
+
"DTO"
>
<#
if
apiMethod
.
getReturnValueType
()??
&&
apiMethod
.
getReturnValueType
()?
lower_case
==
'void'
>
<#
assign
apiReturnValueType
=
"Void"
>
</#
if
>
<#
comment
>
输出从接口测试行为
</#
comment
>
<@
outputTestActionDetail2
deaction
/>
<#
if
deaction
.
codeName
?
lower_case
==
'create'
>
...
...
@@ -597,7 +609,7 @@ public class ${itemCodeName}Resource {
<@
SecurityAnnotation
deaction
/>
@
ApiOperation
(
value
=
"${byTagParams}${deLogicName}"
,
tags
=
{
"${deLogicName}"
},
notes
=
"${byTagParams}${deLogicName}"
)
@
RequestMapping
(
method
=
RequestMethod
.${
reqMtd
},
value
=
"${fullPath}<#if deaction.getRequestParamType() == 'NONE'><#else>/{${itemCodeNameLC + keyCNLC}}</#if>/${deactionCodeName?lower_case}"
)
public
ResponseEntity
<${
itemCodeName
}
DTO
>
${
deactionCodeName
?
uncap_first
}${
byParams
}(<#
if
deaction
.
getRequestParamType
()
==
'NONE'
><#
else
>${
id_etParams
}</#
if
>)
{
public
ResponseEntity
<${
apiReturnValueType
}
>
${
deactionCodeName
?
uncap_first
}${
byParams
}(<#
if
deaction
.
getRequestParamType
()
==
'NONE'
><#
else
>${
id_etParams
}</#
if
>)
{
<#
if
deaction
.
getRequestParamType
()
==
'NONE'
>
${
deCodeName
}
domain
=
new
${
deCodeName
}();
domain
=
${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}(
domain
)
;
...
...
@@ -608,7 +620,11 @@ public class ${itemCodeName}Resource {
domain
=
${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}(
domain
)
;
${
itemCodeNameLC
}
dto
=
${
itemCodeNameLC
}
Mapping
.
toDto
(
domain
);
</#
if
>
<#
if
apiReturnValueType
?
lower_case
==
'void'
>
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
build
();
<#
else
>
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(${
itemCodeNameLC
}
dto
);
</#
if
>
}
<#
comment
>
自定义行为批处理
</#
comment
>
<#
if
(
deaction
.
getActionType
()==
'USERCUSTOM'
)>
...
...
@@ -1002,24 +1018,56 @@ public class ${itemCodeName}Resource {
<#
comment
>
用户自定义行为批处理
-
主实体关系
</#
comment
>
<#
macro
customBatchAction
deaction
>
<#
assign
resultValueType
=
"Boolean"
>
<#
if
apiReturnValueType
??
&&
apiReturnValueType
?
lower_case
==
'void'
>
<#
assign
resultValueType
=
'Void'
>
</#
if
>
<@
SecurityAnnotation
deaction
/>
@
ApiOperation
(
value
=
"批量处理[${deaction.getLogicName()}]"
,
tags
=
{
"${deLogicName}"
},
notes
=
"批量处理[${deaction.getLogicName()}]"
)
@
RequestMapping
(
method
=
RequestMethod
.${
reqMtd
},
value
=
"${fullPath}<#if deaction.getRequestParamType() == 'NONE'><#else>/{${itemCodeNameLC + keyCNLC}}</#if>/${deactionCodeName?lower_case}batch"
)
public
ResponseEntity
<
Boolean
>
${
deactionCodeName
?
uncap_first
}
Batch
(${
etParamsList
})
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}
Batch
(${
itemCodeNameLC
}
Mapping
.
toDomain
(${
itemCodeNameLC
}
dtos
)));
@
RequestMapping
(
method
=
RequestMethod
.${
reqMtd
},
value
=
"${fullPath}/${deactionCodeName?lower_case}batch"
)
public
ResponseEntity
<${
resultValueType
}>
${
deactionCodeName
?
uncap_first
}
Batch
(<#
if
deaction
.
getRequestParamType
()
==
'NONE'
><#
else
>${
etParamsList
}</#
if
>)
{
<#
if
deaction
.
getRequestParamType
()
==
'NONE'
>
List
<${
deCodeName
}>
domains
=
new
ArrayList
<${
deCodeName
}>();
boolean
result
=
${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}
Batch
(
domains
);
<#
else
>
List
<${
deCodeName
}>
domains
=
${
itemCodeNameLC
}
Mapping
.
toDomain
(${
itemCodeNameLC
}
dtos
);
boolean
result
=
${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}
Batch
(
domains
);
</#
if
>
<#
if
resultValueType
?
lower_case
==
'void'
>
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
build
();
<#
else
>
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
result
);
</#
if
>
}
</#
macro
>
<#
comment
>
用户自定义行为批处理
-
从实体关系
</#
comment
>
<#
macro
customBatchActionRS
deaction
>
<#
assign
resultValueType
=
"Boolean"
>
<#
if
apiReturnValueType
??
&&
apiReturnValueType
?
lower_case
==
'void'
>
<#
assign
resultValueType
=
'Void'
>
</#
if
>
@
ApiOperation
(
value
=
"批量处理[${byTagParams}${deLogicName}]"
,
tags
=
{
"${deLogicName}"
},
notes
=
"批量处理[${byTagParams}${deLogicName}]"
)
@
RequestMapping
(
method
=
RequestMethod
.${
reqMtd
},
value
=
"${fullPath}<#if deaction.getRequestParamType() == 'NONE'><#else>/{${itemCodeNameLC + keyCNLC}}</#if>/${deactionCodeName?lower_case}batch"
)
public
ResponseEntity
<
Boolean
>
${
deactionCodeName
?
uncap_first
}${
byParams
}(${
etParamsList
})
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}
Batch
(${
itemCodeNameLC
}
Mapping
.
toDomain
(${
itemCodeNameLC
}
dtos
)));
@
RequestMapping
(
method
=
RequestMethod
.${
reqMtd
},
value
=
"${fullPath}/${deactionCodeName?lower_case}batch"
)
public
ResponseEntity
<${
resultValueType
}>
${
deactionCodeName
?
uncap_first
}${
byParams
}(<#
if
deaction
.
getRequestParamType
()
==
'NONE'
><#
else
>${
etParamsList
}</#
if
>)
{
<#
if
deaction
.
getRequestParamType
()
==
'NONE'
>
List
<${
deCodeName
}>
domains
=
new
ArrayList
<${
deCodeName
}>();
boolean
result
=
${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}
Batch
(
domains
);
<#
else
>
List
<${
deCodeName
}>
domains
=
${
itemCodeNameLC
}
Mapping
.
toDomain
(${
itemCodeNameLC
}
dtos
);
boolean
result
=
${
deCodeNameLC
}
Service
.${
srfmethodname
(
deactionCodeName
)}
Batch
(
domains
);
</#
if
>
<#
if
resultValueType
?
lower_case
==
'void'
>
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
build
();
<#
else
>
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
result
);
</#
if
>
}
</#
macro
>
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/aspect/RocketMQAspect.java.ftl
浏览文件 @
6458ad97
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
assign
hasMQ
Entity
=
false
>
<#
assign
hasMQ
Producer
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
if
dataEntity
.
getAllPSDEDataSyncs
??
&&
dataEntity
.
getAllPSDEDataSyncs
()??>
<#
list
dataEntity
.
getAllPSDEDataSyncs
()
as
dataSync
>
<#
if
dataSync
.
getOutPSSysDataSyncAgent
??
&&
dataSync
.
getOutPSSysDataSyncAgent
()??>
<#
assign
hasMQ
Entity
=
true
>
<#
assign
hasMQ
Producer
=
true
>
<#
break
>
</#
if
>
</#
list
>
</#
if
>
</#
list
>
<#
if
hasMQEntity
>
<#
if
hasMQProducer
>
<#
comment
>
服务接口微服务平台配置
</#
comment
>
<#
assign
mqServerAddress
=
""
>
<#
if
sys
.
getAllPSDevSlnMSDepAPIs
()??>
<#
list
sys
.
getAllPSDevSlnMSDepAPIs
()
as
depSysApi
>
<#
if
depSysApi
.
getPSDCMSPlatform
()??
>
<#
if
depSysApi
.
getUserParam
(
"rocketmq.producer.namesrvAddr"
,
""
)??>
<#
assign
mqServerAddress
=
depSysApi
.
getUserParam
(
"rocketmq.producer.namesrvAddr"
,
""
)>
</#
if
>
</#
if
>
</#
list
>
</#
if
>
<#
if
mqServerAddress
!=''>
<#
assign
mqServer
=
"on"
>
<#
else
>
<#
assign
mqServer
=
"off"
>
</#
if
>
package
${
pub
.
getPKGCodeName
()}.
util
.
aspect
;
import
com
.
alibaba
.
fastjson
.
JSON
;
import
com
.
alibaba
.
rocketmq
.
client
.
producer
.
DefaultMQProducer
;
import
com
.
alibaba
.
rocketmq
.
common
.
message
.
Message
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
import
${
pub
.
getPKGCodeName
()}.
util
.
domain
.
EntityBase
;
import
com
.
alibaba
.
fastjson
.
JSON
;
import
org
.
apache
.
rocketmq
.
client
.
producer
.
DefaultMQProducer
;
import
org
.
apache
.
rocketmq
.
client
.
producer
.
SendResult
;
import
org
.
apache
.
rocketmq
.
common
.
message
.
Message
;
import
org
.
aspectj
.
lang
.
JoinPoint
;
import
org
.
aspectj
.
lang
.
annotation
.
AfterReturning
;
import
org
.
aspectj
.
lang
.
annotation
.
Aspect
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Qualifier
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Value
;
import
org
.
springframework
.
context
.
annotation
.
Lazy
;
import
org
.
springframework
.
expression
.
EvaluationContext
;
import
org
.
springframework
.
expression
.
Expression
;
import
org
.
springframework
.
expression
.
ExpressionParser
;
import
org
.
springframework
.
expression
.
spel
.
standard
.
SpelExpressionParser
;
import
org
.
springframework
.
expression
.
spel
.
support
.
StandardEvaluationContext
;
import
org
.
springframework
.
boot
.
autoconfigure
.
condition
.
ConditionalOnExpression
;
import
org
.
springframework
.
scheduling
.
annotation
.
Async
;
import
org
.
springframework
.
stereotype
.
Component
;
import
org
.
springframework
.
util
.
ObjectUtils
;
...
...
@@ -40,31 +58,34 @@ import java.util.List;
/**
*
rocketMQ
消息切面
*/
@
Slf4j
@
Aspect
@
Component
@
Slf4j
@
ConditionalOnExpression
(
"'${r'${rocketmq.producer.isOnOff:'+mqServer+"
}
'.equals('
on
')"}")
public class RocketMQAspect
{
private final ExpressionParser parser = new SpelExpressionParser();
@Autowired
@Lazy
DefaultMQProducer defaultMQProducer;
@Value("${r'
${
rocketmq
.
producer
.
topic
:
default
}
'}")
private String topic;
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getOutPSSysDataSyncAgent?? && dataSync.getOutPSSysDataSyncAgent()??>
<#
assign
syncAgent
=
dataSync
.
getOutPSSysDataSyncAgent
()>
<#
assign
producer
=
dataEntity
.
codeName
+
syncAgent
.
codeName
+
"producer"
>
@
Autowired
@
Qualifier
(
"${producer}"
)
@
Lazy
DefaultMQProducer
${
producer
};
@
AfterReturning
(
value
=
"(execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.create*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.update*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.save*(..)) ||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.remove*(..))) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.save*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.remove*(..))"
)
<#assign producer=dataEntity.codeName+dataSync.codeName>
@AfterReturning(value = "${getPointCut(dataEntity,dataSync)}")
@Async
public void ${srfmethodname(producer)}(JoinPoint point) {
<#if dataSync.getOutTestPSDEAction?? && dataSync.getOutTestPSDEAction()??>
<#assign actionName=srfmethodname(dataSync.getOutTestPSDEAction().codeName)>
outputAction(point, "${actionName}");
</#if>
sendMsg
(
${
producer
},
"${dataSync.codeName}"
,
"${dataSync.codeNam
e}"
,
getEntity
(
point
));
sendMsg(
topic, "${dataSync.codeName?lower_cas
e}", getEntity(point));
}
</#if>
</#list>
...
...
@@ -113,24 +134,53 @@ public class RocketMQAspect
/**
* 发送消息
*
@
param
producer
* @param topic
* @param tag
* @param body
*/
private
void
sendMsg
(
DefaultMQProducer
producer
,
String
topic
,
String
tag
,
Object
body
)
{
private void sendMsg(String topic, String tag, Object body) {
if(ObjectUtils.isEmpty(body)) {
log
.
error
(
"
发送消息失败,无法获取到要发送的消息内容!"
);
log.error("
消息内容为空,[{}]消息将被忽略!",tag
);
return;
}
try {
producer
.
start
();
Message message = new Message(topic, tag, JSON.toJSONString(body).getBytes());
p
roducer
.
send
(
message
);
producer
.
shutdown
(
);
SendResult sendResult = defaultMQP
roducer.send(message);
log.info("消息发送响应:" + sendResult.toString()
);
} catch (Exception e) {
log.error("消息发送异常,"+e);
}
}
}
</#
if
>
\ No newline at end of file
</#if>
<#comment>输出切点</#comment>
<#function getPointCut dataEntity dataSync>
<#comment>数值代码表 1=新建; 2=编辑; 4=删除</#comment>
<#assign createArray = [1,3,5,7]>
<#assign updateArray = [2,3,6,7]>
<#assign deleteArray=[4,5,6,7]>
<#assign result="">
<#if dataSync.getEventType?? && dataSync.getEventType()??>
<#assign type=dataSync.getEventType()>
<#assign isCreate=createArray?seq_contains(type)>
<#assign isUpdate=updateArray?seq_contains(type)>
<#assign isDelete=deleteArray?seq_contains(type)>
<#if isCreate>
<#assign result="execution(* "+pub.getPKGCodeName()+".core.*.service.*"+dataEntity.codeName+"*.create*(..))">
</#if>
<#if isUpdate>
<#if result!="">
<#assign result=result+"||">
</#if>
<#assign result=result+"execution(* "+pub.getPKGCodeName()+".core.*.service.*"+dataEntity.codeName+"*.update*(..))">
</#if>
<#if isDelete>
<#if result!="">
<#assign result=result+"||">
</#if>
<#assign result=result+"execution(* "+pub.getPKGCodeName()+".core.*.service.*"+dataEntity.codeName+"*.remove*(..))">
</#if>
</#if>
<#return "("+result+")">
</#function>
\ No newline at end of file
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/job/PermissionSyncJob.java.ftl
浏览文件 @
6458ad97
...
...
@@ -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,119 +56,132 @@ 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
;
<#
if
hasWF
>
@
Autowired
@
Lazy
private
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZWFFeignClient
client2
;
</#
if
>
private
IBZUAAFeignClient
uaaClient
;
<#
if
hasMsgTemplate
>
@
Autowired
@
Lazy
private
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZNotifyFeignClient
notifyFeign
Client
;
<
/#
if
>
IBZLiteFeignClient
lite
Client
;
<
#
if
hasWF
>
@
Autowired
@
Lazy
IBZLiteFeignClient
liteFeignClient
;
private
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZWFFeignClient
wfClient
;
</#
if
>
<#
if
hasMsgTemplate
>
@
Autowired
@
Lazy
private
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZNotifyFeignClient
notifyClient
;
</#
if
>
<#
if
hasPredefinedCodeList
>
@
Autowired
@
Lazy
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZDictFeignClient
dict
Feign
Client
;
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZDictFeignClient
dictClient
;
</#
if
>
@
Override
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]同步系统资源失败"
);
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
(
"pssystemname"
,
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
(
String
.
format
(
"向[UAA]同步系统资源失败,请检查[UAA]服务是否正常! [%s]"
,
ex
));
}
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
(
"向[lite]同步系统模型失败,请检查[lite]服务是否正常运行! {}"
,
ex
.
getMessage
());
}
catch
(
Exception
ex
)
{
log
.
error
(
String
.
format
(
"向[lite]同步系统模型失败,请检查[lite]服务是否正常! [%s]"
,
ex
));
}
<#
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
(
"推送消息模板失败"
);
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
e
)
{
log
.
error
(
"
推送消息模板失败"
);
}
catch
(
Exception
e
x
)
{
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
(
"推送系统预置代码表失败"
);
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
e
)
{
log
.
error
(
"
推送系统预置代码表失败"
);
}
catch
(
Exception
e
x
)
{
log
.
error
(
"
向[dict]同步代码表失败,请检查[dict]服务是否正常运行! {}"
,
ex
.
getMessage
()
);
}
</#
if
>
}
...
...
SLN/%PUBPRJ%-util/src/main/resources/application-sys.yml.ftl
浏览文件 @
6458ad97
...
...
@@ -12,6 +12,8 @@ TARGET=PSSYSTEM
<#assign bDynamicDS=false>
<#assign bmogo=false>
<#assign mongodbUri="mongodb://"+sys.name+":"+sys.name+"@127.0.0.1:27017/"+sys.name>
<#assign hasMQProducer=false>
<#assign hasMQConsumer=false>
<#if sys.getAllPSDataEntities()??>
<#list sys.getAllPSDataEntities() as de>
<#if de.getStorageMode()?? && de.getStorageMode()==2>
...
...
@@ -323,6 +325,64 @@ seata:
password: "${nacosPassWord}" #密码
</#if>
<#assign producerMQServer="127.0.0.1:9876">
<#assign consumerMQServer="127.0.0.1:9876">
<#assign producerisOnOff="off">
<#assign consumerisOnOff="off">
<#assign producerGroupName="default">
<#assign consumerGroupName="default">
<#assign producerTopic="default">
<#assign consumerTopic="default">
<#if sys.getAllPSDevSlnMSDepAPIs()??>
<#list sys.getAllPSDevSlnMSDepAPIs() as depSysApi>
<#if depSysApi.getPSDCMSPlatform()?? >
<#if depSysApi.getUserParam("rocketmq.producer.namesrvAddr","")?? && depSysApi.getUserParam("rocketmq.producer.namesrvAddr","")!=''>
<#assign hasMQProducer=true>
<#assign producerMQServer=depSysApi.getUserParam("rocketmq.producer.namesrvAddr","")>
<#if depSysApi.getUserParam("rocketmq.producer.isOnOff","")?? && depSysApi.getUserParam("rocketmq.producer.isOnOff","")!=''>
<#assign producerMQServer=depSysApi.getUserParam("rocketmq.producer.isOnOff","")>
</#if>
<#if depSysApi.getUserParam("rocketmq.producer.groupName","")?? && depSysApi.getUserParam("rocketmq.producer.groupName","")!=''>
<#assign producerGroupName=depSysApi.getUserParam("rocketmq.producer.groupName","")>
</#if>
<#if depSysApi.getUserParam("rocketmq.producer.topic","")?? && depSysApi.getUserParam("rocketmq.producer.topic","")!=''>
<#assign producerTopic=depSysApi.getUserParam("rocketmq.producer.topic","")>
</#if>
</#if>
<#if depSysApi.getUserParam("rocketmq.consumer.namesrvAddr","")?? && depSysApi.getUserParam("rocketmq.consumer.namesrvAddr","")!=''>
<#assign hasMQConsumer=true>
<#assign consumerMQServer=depSysApi.getUserParam("rocketmq.consumer.namesrvAddr","")>
<#if depSysApi.getUserParam("rocketmq.consumer.isOnOff","")?? && depSysApi.getUserParam("rocketmq.consumer.isOnOff","")!=''>
<#assign consumerisOnOff=depSysApi.getUserParam("rocketmq.consumer.isOnOff","")>
</#if>
<#if depSysApi.getUserParam("rocketmq.consumer.groupName","")?? && depSysApi.getUserParam("rocketmq.consumer.groupName","")!=''>
<#assign consumerGroupName=depSysApi.getUserParam("rocketmq.consumer.groupName","")>
</#if>
<#if depSysApi.getUserParam("rocketmq.consumer.topic","")?? && depSysApi.getUserParam("rocketmq.consumer.topic","")!=''>
<#assign consumerTopic=depSysApi.getUserParam("rocketmq.consumer.topic","")>
</#if>
</#if>
</#if>
</#list>
</#if>
<#if hasMQProducer ||hasMQConsumer>
rocketmq:
<#if hasMQProducer>
producer:
namesrvAddr: ${producerMQServer}
isOnOff: '${producerisOnOff}'
groupName: ${producerGroupName}
topic: ${producerTopic}
</#if>
<#if hasMQConsumer>
consumer:
namesrvAddr: ${consumerMQServer}
isOnOff: '${consumerisOnOff}'
groupName: ${consumerGroupName}
topic: ${consumerTopic}
</#if>
</#if>
<#macro singleDatasourceConfig>
datasource:
username: ${dbUserName}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录