Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
5874e615
提交
5874e615
编写于
10月 25, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
规避一级缓存反序列化瓶颈
上级
fad6a070
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
253 行增加
和
10 行删除
+253
-10
AnalyseEntityServiceImpl.java
...lab/core/extensions/service/AnalyseEntityServiceImpl.java
+17
-5
AnalyseSqlServiceImpl.java
...bizlab/core/extensions/service/AnalyseSqlServiceImpl.java
+21
-5
BaseEntityServiceImpl.java
...bizlab/core/extensions/service/BaseEntityServiceImpl.java
+26
-0
ExpiryMap.java
.../main/java/cn/ibizlab/core/extensions/util/ExpiryMap.java
+189
-0
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/AnalyseEntityServiceImpl.java
浏览文件 @
5874e615
...
...
@@ -6,6 +6,7 @@ import cn.ibizlab.core.extensions.cql.ExecResult;
import
cn.ibizlab.core.extensions.domain.BaseRequest
;
import
cn.ibizlab.core.extensions.domain.ResultsMQMsg
;
import
cn.ibizlab.core.extensions.util.DefaultMQProducerService
;
import
cn.ibizlab.core.extensions.util.ExpiryMap
;
import
cn.ibizlab.core.extensions.util.MsgProducerService
;
import
cn.ibizlab.core.lite.extensions.domain.FieldObj
;
import
cn.ibizlab.core.lite.extensions.domain.ModelObj
;
...
...
@@ -40,9 +41,6 @@ public class AnalyseEntityServiceImpl extends BaseEntityServiceImpl {
@Lazy
private
DABuildExService
daBuildExService
;
@Autowired
@Lazy
private
DictDstService
dictDstService
;
@Override
public
void
saveResult
(
ModelObj
param
,
String
RULEID
,
String
RULECODE
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
FieldObj
BUSINESSCAT
,
...
...
@@ -109,7 +107,7 @@ public class AnalyseEntityServiceImpl extends BaseEntityServiceImpl {
if
((!
StringUtils
.
isEmpty
(
result
.
getRuleid
()))&&(!
StringUtils
.
isEmpty
(
result
.
getDomainsfield
()))&&(!
StringUtils
.
isEmpty
(
result
.
getKeyvaluefield
()))&&(!
ObjectUtils
.
isEmpty
(
result
.
getTimefield
())))
{
result
.
setUpdatedate
(
ExecResult
.
nowLocalDate
());
List
<
DADimension
>
dims
=
daBuildExService
.
getDims
(
result
.
getBusinesscat
());
List
<
DADimension
>
dims
=
getDims
(
result
.
getBusinesscat
());
if
(
dims
!=
null
)
{
ArrayList
<
ExecResult
>
results
=
new
ArrayList
<>();
for
(
DADimension
dim
:
dims
)
{
...
...
@@ -121,7 +119,7 @@ public class AnalyseEntityServiceImpl extends BaseEntityServiceImpl {
if
(!
StringUtils
.
isEmpty
(
dictname
))
{
CodeList
codeList
=
dictDstService
.
getCodeListCatalog
(
dictname
);
CodeList
codeList
=
this
.
getCodeListCatalog
(
dictname
);
//维度指定代码表时,向上同时为每一个父节点添加一条数据
while
(
true
)
{
...
...
@@ -296,4 +294,18 @@ public class AnalyseEntityServiceImpl extends BaseEntityServiceImpl {
this
.
ruExecLogService
.
update
(
execlog
);
return
execlog
;
}
private
ExpiryMap
<
String
,
List
<
DADimension
>>
dimlistMap
=
new
ExpiryMap
<>();
public
List
<
DADimension
>
getDims
(
String
id
)
{
List
<
DADimension
>
dims
=
dimlistMap
.
get
(
"dims"
+
id
);
if
(
dims
==
null
)
{
dims
=
daBuildExService
.
get
(
id
).
getDadimension
();
if
(
dims
!=
null
)
dimlistMap
.
put
(
"dims"
+
id
,
dims
);
}
return
dims
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/AnalyseSqlServiceImpl.java
浏览文件 @
5874e615
...
...
@@ -2,6 +2,7 @@ package cn.ibizlab.core.extensions.service;
import
cn.ibizlab.core.analysis.domain.DADimension
;
import
cn.ibizlab.core.dict.extensions.service.DictDstService
;
import
cn.ibizlab.core.extensions.util.ExpiryMap
;
import
cn.ibizlab.core.rule.domain.ExecResult
;
import
cn.ibizlab.core.extensions.domain.BaseRequest
;
import
cn.ibizlab.core.lite.extensions.domain.FieldObj
;
...
...
@@ -32,13 +33,13 @@ import java.util.List;
public
class
AnalyseSqlServiceImpl
extends
BaseEntityServiceImpl
{
@Autowired
@Lazy
private
DABuildExService
daBuildExService
;
@Autowired
@Lazy
private
DictDstService
dictDstService
;
@Autowired
...
...
@@ -111,7 +112,7 @@ public class AnalyseSqlServiceImpl extends BaseEntityServiceImpl {
if
((!
StringUtils
.
isEmpty
(
result
.
getRuleId
()))&&(!
StringUtils
.
isEmpty
(
result
.
getKeyValueField
())))
{
List
<
DADimension
>
dims
=
daBuildExService
.
getDims
(
result
.
getBusinessCat
());
List
<
DADimension
>
dims
=
getDims
(
result
.
getBusinessCat
());
if
(
dims
!=
null
)
{
for
(
DADimension
dim
:
dims
)
{
...
...
@@ -123,7 +124,7 @@ public class AnalyseSqlServiceImpl extends BaseEntityServiceImpl {
if
(!
StringUtils
.
isEmpty
(
dictname
))
{
CodeList
codeList
=
dictDstService
.
getCodeListCatalog
(
dictname
);
CodeList
codeList
=
this
.
getCodeListCatalog
(
dictname
);
//维度指定代码表时,向上同时为每一个父节点添加一条数据
while
(
true
)
{
...
...
@@ -299,4 +300,19 @@ public class AnalyseSqlServiceImpl extends BaseEntityServiceImpl {
this
.
ruExecLogService
.
update
(
execlog
);
return
execlog
;
}
private
ExpiryMap
<
String
,
List
<
DADimension
>>
dimlistMap
=
new
ExpiryMap
<>();
public
List
<
DADimension
>
getDims
(
String
id
)
{
List
<
DADimension
>
dims
=
dimlistMap
.
get
(
"dims"
+
id
);
if
(
dims
==
null
)
{
dims
=
daBuildExService
.
get
(
id
).
getDadimension
();
if
(
dims
!=
null
)
dimlistMap
.
put
(
"dims"
+
id
,
dims
);
}
return
dims
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BaseEntityServiceImpl.java
浏览文件 @
5874e615
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.analysis.domain.DADimension
;
import
cn.ibizlab.core.dict.extensions.service.DictDstService
;
import
cn.ibizlab.core.extensions.domain.BaseRequest
;
import
cn.ibizlab.core.extensions.util.ExpiryMap
;
import
cn.ibizlab.core.lite.extensions.domain.FieldObj
;
import
cn.ibizlab.core.lite.extensions.domain.ModelObj
;
import
cn.ibizlab.core.rule.domain.ExecLog
;
import
cn.ibizlab.core.rule.domain.ExecResult
;
import
cn.ibizlab.core.rule.service.IExecLogService
;
import
cn.ibizlab.core.rule.service.IExecResultService
;
import
cn.ibizlab.util.dict.CodeList
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.helper.RuleUtils
;
...
...
@@ -26,6 +30,7 @@ import org.kie.api.runtime.KieSession;
import
org.kie.api.runtime.rule.FactHandle
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
...
...
@@ -570,4 +575,25 @@ public class BaseEntityServiceImpl implements BaseEntityService
this
.
ruExecLogService
.
update
(
execlog
);
return
execlog
;
}
@Autowired
@Lazy
private
DictDstService
dictDstService
;
private
ExpiryMap
<
String
,
CodeList
>
codelistMap
=
new
ExpiryMap
<>();
public
CodeList
getCodeListCatalog
(
String
dictname
)
{
CodeList
codeList
=
codelistMap
.
get
(
dictname
);
if
(
codeList
==
null
)
{
codeList
=
dictDstService
.
getCodeListCatalog
(
dictname
);
if
(
codeList
!=
null
)
codelistMap
.
put
(
dictname
,
codeList
);
}
return
codeList
;
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/util/ExpiryMap.java
0 → 100644
浏览文件 @
5874e615
package
cn
.
ibizlab
.
core
.
extensions
.
util
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
/**
* <p>
* Title: ExpireMap
* </p>
*
* <p>
* Description: 设置map过期时间
* </p>
*
* <p>
* Company:
* </p>
*
* @author
*
* @since:2020-7-28 下午05:23:25
*
*/
public
class
ExpiryMap
<
K
,
V
>
extends
HashMap
<
K
,
V
>
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 过期时间设置为3分钟,可以修改
*/
private
long
EXPIRY
=
1000
*
60
*
10
;
private
HashMap
<
K
,
Long
>
expiryMap
=
new
HashMap
();
public
ExpiryMap
()
{
super
();
}
public
ExpiryMap
(
long
defaultExpiryTime
)
{
this
(
1
<<
4
,
defaultExpiryTime
);
}
public
ExpiryMap
(
int
initialCapacity
,
long
defaultExpiryTime
)
{
super
(
initialCapacity
);
this
.
EXPIRY
=
defaultExpiryTime
;
}
public
V
put
(
K
key
,
V
value
)
{
expiryMap
.
put
(
key
,
System
.
currentTimeMillis
()
+
EXPIRY
);
return
super
.
put
(
key
,
value
);
}
public
boolean
containsKey
(
Object
key
)
{
return
!
checkExpiry
(
key
,
true
)
&&
super
.
containsKey
(
key
);
}
/**
* @param key
* @param value
* @param expiryTime
* 键值对有效期 毫秒
* @return
*/
public
V
put
(
K
key
,
V
value
,
long
expiryTime
)
{
expiryMap
.
put
(
key
,
System
.
currentTimeMillis
()
+
expiryTime
);
return
super
.
put
(
key
,
value
);
}
public
int
size
()
{
return
entrySet
().
size
();
}
public
boolean
isEmpty
()
{
return
entrySet
().
size
()
==
0
;
}
public
boolean
containsValue
(
Object
value
)
{
if
(
value
==
null
)
return
Boolean
.
FALSE
;
Set
<
java
.
util
.
Map
.
Entry
<
K
,
V
>>
set
=
super
.
entrySet
();
Iterator
<
java
.
util
.
Map
.
Entry
<
K
,
V
>>
iterator
=
set
.
iterator
();
while
(
iterator
.
hasNext
())
{
java
.
util
.
Map
.
Entry
<
K
,
V
>
entry
=
iterator
.
next
();
if
(
value
.
equals
(
entry
.
getValue
()))
{
if
(
checkExpiry
(
entry
.
getKey
(),
false
))
{
iterator
.
remove
();
return
Boolean
.
FALSE
;
}
else
return
Boolean
.
TRUE
;
}
}
return
Boolean
.
FALSE
;
}
public
Collection
<
V
>
values
()
{
Collection
<
V
>
values
=
super
.
values
();
if
(
values
==
null
||
values
.
size
()
<
1
)
return
values
;
Iterator
<
V
>
iterator
=
values
.
iterator
();
while
(
iterator
.
hasNext
())
{
V
next
=
iterator
.
next
();
if
(!
containsValue
(
next
))
iterator
.
remove
();
}
return
values
;
}
public
V
get
(
Object
key
)
{
if
(
key
==
null
)
return
null
;
if
(
checkExpiry
(
key
,
true
))
return
null
;
return
super
.
get
(
key
);
}
/**
*
* @Description: 是否过期
* @param key
* @return null:不存在或key为null -1:过期 存在且没过期返回value 因为过期的不是实时删除,所以稍微有点作用
*/
public
Object
isInvalid
(
Object
key
)
{
if
(
key
==
null
)
return
null
;
if
(!
expiryMap
.
containsKey
(
key
))
{
return
null
;
}
long
expiryTime
=
expiryMap
.
get
(
key
);
boolean
flag
=
System
.
currentTimeMillis
()
>
expiryTime
;
if
(
flag
)
{
super
.
remove
(
key
);
expiryMap
.
remove
(
key
);
return
-
1
;
}
return
super
.
get
(
key
);
}
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
m
)
{
for
(
Map
.
Entry
<?
extends
K
,
?
extends
V
>
e
:
m
.
entrySet
())
expiryMap
.
put
(
e
.
getKey
(),
System
.
currentTimeMillis
()
+
EXPIRY
);
super
.
putAll
(
m
);
}
public
Set
<
Map
.
Entry
<
K
,
V
>>
entrySet
()
{
Set
<
java
.
util
.
Map
.
Entry
<
K
,
V
>>
set
=
super
.
entrySet
();
Iterator
<
java
.
util
.
Map
.
Entry
<
K
,
V
>>
iterator
=
set
.
iterator
();
while
(
iterator
.
hasNext
())
{
java
.
util
.
Map
.
Entry
<
K
,
V
>
entry
=
iterator
.
next
();
if
(
checkExpiry
(
entry
.
getKey
(),
false
))
iterator
.
remove
();
}
return
set
;
}
/**
*
* @Description: 是否过期
* @param
*
* @param isRemoveSuper
* true super删除
* @return
*/
private
boolean
checkExpiry
(
Object
key
,
boolean
isRemoveSuper
)
{
if
(!
expiryMap
.
containsKey
(
key
))
{
return
Boolean
.
FALSE
;
}
long
expiryTime
=
expiryMap
.
get
(
key
);
boolean
flag
=
System
.
currentTimeMillis
()
>
expiryTime
;
if
(
flag
)
{
if
(
isRemoveSuper
)
super
.
remove
(
key
);
expiryMap
.
remove
(
key
);
}
return
flag
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录