Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
0c061a3e
提交
0c061a3e
编写于
9月 14, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dict调整
上级
4c37e1aa
变更
6
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
561 行增加
和
161 行删除
+561
-161
DictDstService.java
.../ibizlab/core/dict/extensions/service/DictDstService.java
+152
-155
DAChartExService.java
.../cn/ibizlab/core/extensions/service/DAChartExService.java
+34
-0
DAReportExService.java
...cn/ibizlab/core/extensions/service/DAReportExService.java
+34
-0
Catalog.java
ibzdst-util/src/main/java/cn/ibizlab/util/dict/Catalog.java
+170
-3
CodeList.java
ibzdst-util/src/main/java/cn/ibizlab/util/dict/CodeList.java
+170
-2
DataObject.java
...util/src/main/java/cn/ibizlab/util/helper/DataObject.java
+1
-1
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/dict/extensions/service/DictDstService.java
浏览文件 @
0c061a3e
...
...
@@ -9,18 +9,45 @@ import cn.ibizlab.util.dict.Catalog;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.dict.CodeList
;
import
cn.ibizlab.util.dict.Option
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.cloud.client.loadbalancer.LoadBalanced
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.client.DefaultResponseErrorHandler
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
java.nio.charset.StandardCharsets
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@Slf4j
@Service
...
...
@@ -29,117 +56,40 @@ public class DictDstService
@Autowired
private
IDictCatalogService
dictCatalogService
;
@Autowired
@Lazy
private
DictDstService
proxy
;
@Autowired
private
IDictOptionService
optionService
;
@Cacheable
(
value
=
"dictcatalog"
,
key
=
"'dict:'+#p0"
)
public
Catalog
getDictCatalog
(
String
code
){
return
getDictCatalog
(
code
,
new
DictOptionSearchContext
());
Catalog
catalog
=
new
Catalog
();
CodeList
rootCatalog
=
proxy
.
getCodeListCatalog
(
code
);
catalog
.
setCode
(
code
).
setName
(
rootCatalog
.
getName
()).
setAdvancedSettings
(
rootCatalog
.
getAdvancedSettings
()).
setNodes
((
List
)
JSON
.
toJSON
(
rootCatalog
.
getOptions
()));
return
catalog
;
}
public
Catalog
getDictCatalog
(
String
code
,
DictOptionSearchContext
context
)
{
Catalog
catalog
=
new
Catalog
();
if
(
code
.
equalsIgnoreCase
(
"dictcatalog"
))
{
catalog
.
setCode
(
"DictCatalog"
);
catalog
.
setName
(
"字典目录"
);
List
<
Option
>
list
=
new
ArrayList
<>();
LambdaQueryWrapper
<
DictCatalog
>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(!
StringUtils
.
isEmpty
(
context
.
getN_val_like
()))
wrapper
.
like
(
DictCatalog:
:
getCode
,
context
.
getN_val_like
());
if
(!
StringUtils
.
isEmpty
(
context
.
getN_val_in
()))
wrapper
.
in
(
DictCatalog:
:
getCode
,
context
.
getN_val_in
());
if
(!
StringUtils
.
isEmpty
(
context
.
getN_val_leftlike
()))
wrapper
.
likeRight
(
DictCatalog:
:
getCode
,
context
.
getN_val_leftlike
());
if
(!
StringUtils
.
isEmpty
(
context
.
getN_val_notin
()))
wrapper
.
notIn
(
DictCatalog:
:
getCode
,
context
.
getN_val_notin
());
if
(!
StringUtils
.
isEmpty
(
context
.
getN_label_like
()))
wrapper
.
notIn
(
DictCatalog:
:
getName
,
context
.
getN_label_like
());
if
(!
StringUtils
.
isEmpty
(
context
.
getN_vfilter_like
()))
wrapper
.
like
(
DictCatalog:
:
getGroup
,
context
.
getN_vfilter_like
());
if
(!
StringUtils
.
isEmpty
(
context
.
getN_vfilter_in
()))
wrapper
.
in
(
DictCatalog:
:
getGroup
,
context
.
getN_vfilter_in
());
if
(!
StringUtils
.
isEmpty
(
context
.
getN_vfilter_leftlike
()))
wrapper
.
likeRight
(
DictCatalog:
:
getGroup
,
context
.
getN_vfilter_leftlike
());
if
(!
StringUtils
.
isEmpty
(
context
.
getN_vfilter_eq
()))
wrapper
.
eq
(
DictCatalog:
:
getGroup
,
context
.
getN_vfilter_eq
());
wrapper
.
orderByAsc
(
DictCatalog:
:
getGroup
,
DictCatalog:
:
getCode
);
dictCatalogService
.
list
(
wrapper
).
forEach
(
item
->{
list
.
add
(
new
Option
().
setValue
(
item
.
getCode
()).
setId
(
item
.
getCode
())
.
setDisabled
(
false
)
.
setFilter
(
item
.
getGroup
()).
setLabel
(
item
.
getName
())
);
});
catalog
.
setOptions
(
list
);
}
else
{
String
codeName
=
code
;
String
filter
=
""
;
String
subCode
=
""
;
if
(
codeName
.
indexOf
(
"."
)>
0
)
{
String
[]
arg
=
codeName
.
split
(
"[.]"
);
codeName
=
arg
[
0
];
subCode
=
arg
[
1
];
}
if
(
codeName
.
indexOf
(
"-"
)>
0
)
{
String
[]
arg
=
codeName
.
split
(
"-"
);
codeName
=
arg
[
0
];
filter
=
arg
[
1
];
}
DictCatalog
dictCatalog
=
dictCatalogService
.
getOne
(
Wrappers
.<
DictCatalog
>
query
().
eq
(
"ccode"
,
codeName
));
catalog
.
setCode
(
code
).
setName
(
dictCatalog
.
getName
());
Map
<
String
,
List
<
Option
>>
map
=
new
LinkedHashMap
<>();
Option
subOption
=
null
;
for
(
DictOption
item:
optionService
.
list
(
context
.
getSelectCond
().
eq
(
"cid"
,
dictCatalog
.
getId
()).
orderByAsc
(
"showorder"
)))
{
Map
<
String
,
Object
>
extension
=
new
HashMap
<>();
if
(!
StringUtils
.
isEmpty
(
item
.
getExtension
()))
extension
=
JSONObject
.
parseObject
(
item
.
getExtension
(),
Map
.
class
);
String
pid
=
StringUtils
.
isEmpty
(
item
.
getParent
())?
"_root"
:
item
.
getParent
();
List
<
Option
>
list
=
null
;
if
(!
map
.
containsKey
(
pid
))
{
list
=
new
ArrayList
<>();
map
.
put
(
pid
,
list
);
}
else
list
=
map
.
get
(
pid
);
Option
option
=
new
Option
().
setValue
(
item
.
getValue
()).
setId
(
item
.
getValue
())
.
setDisabled
(((
item
.
getDisabled
()!=
null
&&
item
.
getDisabled
()==
1
)||(
item
.
getExpired
()!=
null
&&
item
.
getExpired
()==
1
))?
true
:
false
)
.
setFilter
(
item
.
getFilter
()).
setIconClass
(
item
.
getIconClass
()).
setLabel
(
item
.
getLabel
()).
setParent
(
item
.
getParent
()).
setExtension
(
extension
);
if
(
option
.
getValue
().
equals
(
subCode
))
subOption
=
option
;
if
(
StringUtils
.
isEmpty
(
filter
)||
option
.
getFilterSet
().
contains
(
filter
))
list
.
add
(
option
);
}
List
<
Option
>
codeItemTreeList
=
loop
(
map
,
(
StringUtils
.
isEmpty
(
subCode
))?
"_root"
:
subCode
);
if
(
subOption
!=
null
)
{
subOption
.
setChildren
(
codeItemTreeList
).
setParent
(
""
);
catalog
.
getOptions
().
add
(
subOption
);
}
else
catalog
.
setOptions
(
codeItemTreeList
);
}
CodeList
rootCatalog
=
proxy
.
getCodeListCatalog
(
code
,
context
);
catalog
.
setCode
(
code
).
setName
(
rootCatalog
.
getName
()).
setAdvancedSettings
(
rootCatalog
.
getAdvancedSettings
()).
setNodes
((
List
)
JSON
.
toJSON
(
rootCatalog
.
getOptions
()));
return
catalog
;
}
@CacheEvict
(
value
=
"dictcatalog"
,
key
=
"'dict:'+#p0"
)
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dictcatalog"
,
key
=
"'dict:'+#p0"
),
@CacheEvict
(
value
=
"dictcatalog"
,
key
=
"'glob:dict:'+#p0+'*'"
)
})
public
void
resetDictCatalog
(
String
code
)
{
}
@Cacheable
(
value
=
"dictcatalog"
,
key
=
"'codelist:'+#p0"
)
public
CodeList
getCodeListCatalog
(
String
code
){
return
getCodeListCatalog
(
code
,
new
DictOptionSearchContext
());
...
...
@@ -147,7 +97,6 @@ public class DictDstService
public
CodeList
getCodeListCatalog
(
String
code
,
DictOptionSearchContext
context
)
{
CodeList
catalog
=
new
CodeList
();
if
(
code
.
equalsIgnoreCase
(
"dictcatalog"
))
{
catalog
.
setCode
(
"DictCatalog"
);
...
...
@@ -199,89 +148,137 @@ public class DictDstService
codeName
=
arg
[
0
];
filter
=
arg
[
1
];
}
QueryWrapper
<
DictOption
>
qw
=
context
.
getSelectCond
();
DictCatalog
dictCatalog
=
dictCatalogService
.
getOne
(
Wrappers
.<
DictCatalog
>
query
().
eq
(
"ccode"
,
codeName
));
catalog
.
setCode
(
code
).
setName
(
dictCatalog
.
getName
());
Map
<
String
,
List
<
CodeItem
>>
map
=
new
LinkedHashMap
<>();
List
<
CodeItem
>
alllist
=
new
ArrayList
<>();
CodeItem
subOption
=
null
;
for
(
DictOption
item:
optionService
.
list
(
context
.
getSelectCond
().
eq
(
"cid"
,
dictCatalog
.
getId
()).
orderByAsc
(
"showorder"
))){
Map
<
String
,
Object
>
extension
=
new
HashMap
<>();
if
(!
StringUtils
.
isEmpty
(
item
.
getExtension
()))
extension
=
JSONObject
.
parseObject
(
item
.
getExtension
(),
Map
.
class
);
String
pid
=
StringUtils
.
isEmpty
(
item
.
getParent
())?
"_root"
:
item
.
getParent
();
List
<
CodeItem
>
list
=
null
;
if
(!
map
.
containsKey
(
pid
))
catalog
.
setCode
(
code
).
setName
(
dictCatalog
.
getName
()).
putAdvancedSettings
(
dictCatalog
.
getExtParams
());
if
(!
StringUtils
.
isEmpty
(
catalog
.
getUrl
()))
{
list
=
new
ArrayList
<>();
map
.
put
(
pid
,
list
);
Map
<
String
,
Object
>
urlParams
=
new
HashMap
<>();
urlParams
.
putAll
(
context
.
getSessioncontext
());
urlParams
.
putAll
(
context
.
getDatacontext
());
urlParams
.
put
(
"filter"
,
filter
);
urlParams
.
put
(
"subCode"
,
subCode
);
urlParams
.
put
(
"code"
,
code
);
urlParams
.
put
(
"codeName"
,
codeName
);
catalog
.
setNodes
((
List
)
getRemoteDict
(
catalog
,
urlParams
),
filter
,
subCode
);
}
else
list
=
map
.
get
(
pid
);
CodeItem
option
=
new
CodeItem
().
setValue
(
item
.
getValue
()).
setId
(
item
.
getValue
())
.
setDisabled
(((
item
.
getDisabled
()!=
null
&&
item
.
getDisabled
()==
1
)||(
item
.
getExpired
()!=
null
&&
item
.
getExpired
()==
1
))?
true
:
false
)
.
setFilter
(
item
.
getFilter
()).
setIconClass
(
item
.
getIconClass
()).
setLabel
(
item
.
getLabel
()).
setParent
(
item
.
getParent
()).
setExtension
(
extension
);
if
(
option
.
getValue
().
equals
(
subCode
))
subOption
=
option
;
if
(
StringUtils
.
isEmpty
(
filter
)||
option
.
getFilterSet
().
contains
(
filter
))
else
if
(
((!
StringUtils
.
isEmpty
(
filter
))||(!
StringUtils
.
isEmpty
(
subCode
)))
&&
qw
.
isEmptyOfWhere
()
)
{
alllist
.
add
(
option
);
list
.
add
(
option
);
}
CodeList
rootCatalog
=
proxy
.
getCodeListCatalog
(
codeName
);
catalog
.
setCode
(
code
).
setName
(
rootCatalog
.
getName
()).
setAdvancedSettings
(
rootCatalog
.
getAdvancedSettings
());
catalog
.
setNodes
((
List
)
JSON
.
toJSON
(
rootCatalog
.
getOptions
()),
filter
,
subCode
);
}
if
(
subOption
!=
null
)
else
{
List
<
CodeItem
>
codeItemTreeList
=
loopItem
(
map
,
subCode
);
codeItemTreeList
.
add
(
0
,
subOption
);
catalog
.
setOptions
(
codeItemTreeList
);
catalog
.
setNodes
((
List
)
JSON
.
toJSON
(
optionService
.
list
(
qw
.
eq
(
"cid"
,
dictCatalog
.
getId
()).
orderByAsc
(
"showorder"
))),
filter
,
subCode
);
}
else
catalog
.
setOptions
(
alllist
);
}
return
catalog
;
}
@CacheEvict
(
value
=
"dictcatalog"
,
key
=
"'codelist:'+#p0"
)
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dictcatalog"
,
key
=
"'codelist:'+#p0"
),
@CacheEvict
(
value
=
"dictcatalog"
,
key
=
"'glob:codelist:'+#p0+'*'"
)
})
public
void
resetCodeListCatalog
(
String
code
)
{
}
public
List
<
Option
>
loop
(
Map
<
String
,
List
<
Option
>>
listCodeItem
,
Object
parentValue
)
{
List
<
Option
>
trees
=
new
ArrayList
<
Option
>();
if
(
listCodeItem
.
containsKey
(
parentValue
))
{
for
(
Option
codeItem
:
listCodeItem
.
get
(
parentValue
))
{
List
<
Option
>
childCodeItem
=
loop
(
listCodeItem
,
codeItem
.
getValue
());
if
(
childCodeItem
.
size
()
>
0
)
{
codeItem
.
setChildren
(
childCodeItem
);
}
trees
.
add
(
codeItem
);
@Autowired
private
RestTemplate
remoteDictClient
;
public
JSONArray
getRemoteDict
(
CodeList
catalog
,
Map
<
String
,
Object
>
urlParams
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
if
(
requestAttributes
!=
null
)
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
requestAttributes
).
getRequest
();
String
auth
=
request
.
getHeader
(
"Authorization"
);
if
(!
StringUtils
.
isEmpty
(
auth
))
headers
.
add
(
"Authorization"
,
auth
);
}
String
response
=
null
;
response
=
remoteDictClient
.
exchange
(
catalog
.
getUrl
(),
HttpMethod
.
valueOf
(
catalog
.
getRequestMethod
().
toUpperCase
()),
new
HttpEntity
(
JSON
.
parse
(
catalog
.
getRequestBody
()),
headers
),
String
.
class
,
urlParams
).
getBody
();
Assert
.
notNull
(
response
,
"获取远程字典失败"
);
JSONArray
items
=
null
;
if
((!
StringUtils
.
isEmpty
(
catalog
.
getNodeProp
()))||
response
.
startsWith
(
"{"
))
{
String
nodeProp
=
StringUtils
.
isEmpty
(
catalog
.
getNodeProp
())?
"items"
:
catalog
.
getNodeProp
();
JSONObject
res
=
JSON
.
parseObject
(
response
);
String
pairs
[]
=
nodeProp
.
split
(
"[.]"
);
for
(
int
i
=
0
;
i
<
pairs
.
length
;
i
++)
{
String
pair
=
pairs
[
i
].
trim
();
if
(
StringUtils
.
isEmpty
(
pair
))
{
if
(
i
<
pairs
.
length
-
1
)
{
res
=
res
.
getJSONObject
(
pair
);
Assert
.
notNull
(
res
,
"获取远程字典失败:"
+
pair
+
"未找到"
);
}
return
trees
;
else
items
=
res
.
getJSONArray
(
pair
);
}
public
List
<
CodeItem
>
loopItem
(
Map
<
String
,
List
<
CodeItem
>>
listCodeItem
,
Object
parentValue
)
{
List
<
CodeItem
>
trees
=
new
ArrayList
<
CodeItem
>();
if
(
listCodeItem
.
containsKey
(
parentValue
))
{
for
(
CodeItem
codeItem
:
listCodeItem
.
get
(
parentValue
))
{
trees
.
add
(
codeItem
);
List
<
CodeItem
>
childCodeItem
=
loopItem
(
listCodeItem
,
codeItem
.
getValue
());
if
(
childCodeItem
.
size
()
>
0
)
{
trees
.
addAll
(
childCodeItem
);
}
}
else
{
items
=
JSON
.
parseArray
(
response
);
}
return
trees
;
Assert
.
notNull
(
items
,
"获取远程字典失败:数据项未找到"
);
return
items
;
}
@Bean
@LoadBalanced
public
RestTemplate
remoteDictClient
()
{
// 长连接
PoolingHttpClientConnectionManager
pollingConnectionManager
=
new
PoolingHttpClientConnectionManager
();
// 总连接数
pollingConnectionManager
.
setMaxTotal
(
1000
);
// 同路由的并发数
pollingConnectionManager
.
setDefaultMaxPerRoute
(
1000
);
HttpClientBuilder
httpClientBuilder
=
HttpClients
.
custom
();
httpClientBuilder
.
setConnectionManager
(
pollingConnectionManager
);
// 重试次数,默认是3次,没有开启
// httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(3,
// true));
HttpClient
httpClient
=
httpClientBuilder
.
build
();
HttpComponentsClientHttpRequestFactory
clientHttpRequestFactory
=
new
HttpComponentsClientHttpRequestFactory
(
httpClient
);
// 连接超时
clientHttpRequestFactory
.
setConnectTimeout
(
60000
);
// 数据读取超时时间,即SocketTimeout
clientHttpRequestFactory
.
setReadTimeout
(
60000
);
// 连接不够用的等待时间,不宜过长,必须设置,比如连接不够用时,时间过长将是灾难性的
clientHttpRequestFactory
.
setConnectionRequestTimeout
(
200
);
// 缓冲请求数据,默认值是true。通过POST或者PUT大量发送数据时,建议将此属性更改为false,以免耗尽内存。
RestTemplate
restTemplate
=
new
RestTemplate
();
restTemplate
.
getMessageConverters
().
set
(
1
,
new
StringHttpMessageConverter
(
StandardCharsets
.
UTF_8
));
restTemplate
.
setRequestFactory
(
clientHttpRequestFactory
);
restTemplate
.
setErrorHandler
(
new
DefaultResponseErrorHandler
());
return
restTemplate
;
}
public
String
formatURI
(
String
uri
,
Map
<
String
,
Object
>
map
)
{
boolean
ext
=
uri
.
indexOf
(
"$"
)>
0
;
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
map
.
entrySet
())
{
String
regex
=
ext
?
"\\$"
:
""
+
"\\{"
+
entry
.
getKey
()
+
"\\}"
;
Pattern
pattern
=
Pattern
.
compile
(
regex
);
Matcher
matcher
=
pattern
.
matcher
(
uri
);
uri
=
matcher
.
replaceAll
(
DataObject
.
getStringValue
(
entry
.
getValue
(),
"null"
));
}
return
uri
;
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/DAChartExService.java
浏览文件 @
0c061a3e
...
...
@@ -3,6 +3,8 @@ package cn.ibizlab.core.extensions.service;
import
cn.ibizlab.core.analysis.service.impl.DAChartServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.ibizlab.core.analysis.domain.DAChart
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Primary
;
...
...
@@ -31,5 +33,37 @@ public class DAChartExService extends DAChartServiceImpl {
public
DAChart
build
(
DAChart
et
)
{
return
super
.
build
(
et
);
}
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dataAnalyse"
,
allEntries
=
true
)
})
@Override
public
boolean
update
(
DAChart
et
)
{
return
super
.
update
(
et
);
}
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dataAnalyse"
,
allEntries
=
true
)
})
@Override
public
void
updateBatch
(
List
<
DAChart
>
list
)
{
super
.
updateBatch
(
list
);
}
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dataAnalyse"
,
allEntries
=
true
)
})
@Override
public
boolean
save
(
DAChart
et
)
{
return
super
.
save
(
et
);
}
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dataAnalyse"
,
allEntries
=
true
)
})
@Override
public
void
saveBatch
(
List
<
DAChart
>
list
)
{
super
.
saveBatch
(
list
);
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/DAReportExService.java
浏览文件 @
0c061a3e
...
...
@@ -3,6 +3,8 @@ package cn.ibizlab.core.extensions.service;
import
cn.ibizlab.core.analysis.service.impl.DAReportServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.ibizlab.core.analysis.domain.DAReport
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Primary
;
...
...
@@ -31,5 +33,37 @@ public class DAReportExService extends DAReportServiceImpl {
public
DAReport
build
(
DAReport
et
)
{
return
super
.
build
(
et
);
}
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dataAnalyse"
,
allEntries
=
true
)
})
@Override
public
boolean
update
(
DAReport
et
)
{
return
super
.
update
(
et
);
}
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dataAnalyse"
,
allEntries
=
true
)
})
@Override
public
void
updateBatch
(
List
<
DAReport
>
list
)
{
super
.
updateBatch
(
list
);
}
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dataAnalyse"
,
allEntries
=
true
)
})
@Override
public
boolean
save
(
DAReport
et
)
{
return
super
.
save
(
et
);
}
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"dataAnalyse"
,
allEntries
=
true
)
})
@Override
public
void
saveBatch
(
List
<
DAReport
>
list
)
{
super
.
saveBatch
(
list
);
}
}
ibzdst-util/src/main/java/cn/ibizlab/util/dict/Catalog.java
浏览文件 @
0c061a3e
...
...
@@ -2,8 +2,12 @@ package cn.ibizlab.util.dict;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
...
...
@@ -13,9 +17,7 @@ import lombok.experimental.Accessors;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Getter
@Setter
...
...
@@ -50,4 +52,169 @@ public class Catalog
return
null
;
}
private
Map
<
String
,
Object
>
advancedSettings
;
public
Catalog
putAdvancedSettings
(
String
settings
)
{
try
{
if
(!
StringUtils
.
isEmpty
(
settings
))
advancedSettings
=
JSON
.
parseObject
(
settings
,
Map
.
class
);
}
catch
(
Exception
ex
){}
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getUrl
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"url"
)!=
null
?
advancedSettings
.
get
(
"url"
).
toString
():
null
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getRequestMethod
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"requestMethod"
)!=
null
?
advancedSettings
.
get
(
"requestMethod"
).
toString
():
"GET"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getRequestBody
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"requestBody"
)!=
null
?
advancedSettings
.
get
(
"requestBody"
).
toString
():
"{}"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getNodeProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"nodeProp"
)!=
null
?
advancedSettings
.
get
(
"nodeProp"
).
toString
():
""
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getValueProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"valueProp"
)!=
null
?
advancedSettings
.
get
(
"valueProp"
).
toString
():
"value"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getLabelProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"labelProp"
)!=
null
?
advancedSettings
.
get
(
"labelProp"
).
toString
():
"label"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getParentProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"parentProp"
)!=
null
?
advancedSettings
.
get
(
"parentProp"
).
toString
():
"parent"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getChildrenProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"childrenProp"
)!=
null
?
advancedSettings
.
get
(
"childrenProp"
).
toString
():
"children"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getDisabledProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"disabledProp"
)!=
null
?
advancedSettings
.
get
(
"disabledProp"
).
toString
():
"disabled"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getFilterProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"filterProp"
)!=
null
?
advancedSettings
.
get
(
"filterProp"
).
toString
():
"filter"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getExpiredProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"expiredProp"
)!=
null
?
advancedSettings
.
get
(
"expiredProp"
).
toString
():
"expired"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getIconClassProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"iconClassProp"
)!=
null
?
advancedSettings
.
get
(
"iconClassProp"
).
toString
():
"iconClass"
;
}
public
Catalog
setNodes
(
List
<
Map
>
nodes
)
{
return
setNodes
(
nodes
,
null
,
null
);
}
public
Catalog
setNodes
(
List
<
Map
>
nodes
,
String
filter
,
String
subCode
)
{
Map
<
String
,
List
<
Option
>>
map
=
new
LinkedHashMap
<>();
Option
subOption
=
null
;
for
(
Map
item:
unfoldList
(
nodes
,
null
))
{
Map
<
String
,
Object
>
extension
=
new
HashMap
<>();
if
(!
StringUtils
.
isEmpty
(
item
.
get
(
"extension"
)))
extension
=
JSONObject
.
parseObject
(
item
.
get
(
"extension"
).
toString
(),
Map
.
class
);
String
pid
=
DataObject
.
getStringValue
(
item
.
get
(
this
.
getParentProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"pvalue"
),
"_root"
));
if
(
StringUtils
.
isEmpty
(
pid
))
pid
=
"_root"
;
List
<
Option
>
list
=
null
;
if
(!
map
.
containsKey
(
pid
))
{
list
=
new
ArrayList
<>();
map
.
put
(
pid
,
list
);
}
else
list
=
map
.
get
(
pid
);
Option
option
=
new
Option
().
setValue
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getValueProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"id"
),
null
)))
.
setId
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getValueProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"id"
),
null
)))
.
setDisabled
(
DataObject
.
getBooleanValue
(
item
.
get
(
this
.
getDisabledProp
()),
false
)||
DataObject
.
getBooleanValue
(
item
.
get
(
this
.
getExpiredProp
()),
false
))
.
setFilter
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getFilterProp
()),
null
)).
setIconClass
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getIconClassProp
()),
null
))
.
setLabel
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getLabelProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"text"
),
""
)))
.
setParent
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getParentProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"pvalue"
),
""
))).
setExtension
(
extension
);
if
(
option
.
getValue
().
equals
(
subCode
))
subOption
=
option
;
if
(
StringUtils
.
isEmpty
(
filter
)||
option
.
getFilterSet
().
contains
(
filter
))
list
.
add
(
option
);
}
List
<
Option
>
codeItemTreeList
=
loop
(
map
,
(
StringUtils
.
isEmpty
(
subCode
))?
"_root"
:
subCode
);
if
(
subOption
!=
null
)
{
subOption
.
setChildren
(
codeItemTreeList
).
setParent
(
""
);
this
.
getOptions
().
add
(
subOption
.
setParent
(
null
));
}
else
this
.
setOptions
(
codeItemTreeList
);
return
this
;
}
public
List
<
Map
>
unfoldList
(
List
<
Map
>
nodes
,
String
parent
)
{
List
<
Map
>
unfoldList
=
new
ArrayList
<>();
for
(
Map
item:
nodes
)
{
if
((!
StringUtils
.
isEmpty
(
parent
))&&
StringUtils
.
isEmpty
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getParentProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"pvalue"
),
null
))))
item
.
put
(
this
.
getParentProp
(),
parent
);
String
value
=
DataObject
.
getStringValue
(
item
.
get
(
this
.
getValueProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"id"
),
null
));
unfoldList
.
add
(
item
);
Object
child
=
item
.
get
(
this
.
getChildrenProp
());
if
(!
ObjectUtils
.
isEmpty
(
child
))
{
if
(
child
instanceof
List
&&
((
List
)
child
).
get
(
0
)
instanceof
Map
)
unfoldList
.
addAll
(
unfoldList
((
List
)
child
,
value
));
item
.
remove
(
this
.
getChildrenProp
());
}
}
return
unfoldList
;
}
public
List
<
Option
>
loop
(
Map
<
String
,
List
<
Option
>>
listCodeItem
,
Object
parentValue
)
{
List
<
Option
>
trees
=
new
ArrayList
<
Option
>();
if
(
listCodeItem
.
containsKey
(
parentValue
))
{
for
(
Option
codeItem
:
listCodeItem
.
get
(
parentValue
))
{
List
<
Option
>
childCodeItem
=
loop
(
listCodeItem
,
codeItem
.
getValue
());
if
(
childCodeItem
.
size
()
>
0
)
codeItem
.
setChildren
(
childCodeItem
);
trees
.
add
(
codeItem
);
}
}
return
trees
;
}
}
ibzdst-util/src/main/java/cn/ibizlab/util/dict/CodeList.java
浏览文件 @
0c061a3e
package
cn
.
ibizlab
.
util
.
dict
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.*
;
@Getter
@Setter
...
...
@@ -53,4 +58,167 @@ public class CodeList
resultCodeItem
.
setChildren
(
children
);
return
resultCodeItem
;
}
private
Map
<
String
,
Object
>
advancedSettings
;
public
CodeList
putAdvancedSettings
(
String
settings
)
{
try
{
if
(!
StringUtils
.
isEmpty
(
settings
))
advancedSettings
=
JSON
.
parseObject
(
settings
,
Map
.
class
);
}
catch
(
Exception
ex
){}
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getUrl
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"url"
)!=
null
?
advancedSettings
.
get
(
"url"
).
toString
():
null
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getRequestMethod
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"requestMethod"
)!=
null
?
advancedSettings
.
get
(
"requestMethod"
).
toString
():
"GET"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getRequestBody
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"requestBody"
)!=
null
?
advancedSettings
.
get
(
"requestBody"
).
toString
():
"{}"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getNodeProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"nodeProp"
)!=
null
?
advancedSettings
.
get
(
"nodeProp"
).
toString
():
""
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getValueProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"valueProp"
)!=
null
?
advancedSettings
.
get
(
"valueProp"
).
toString
():
"value"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getLabelProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"labelProp"
)!=
null
?
advancedSettings
.
get
(
"labelProp"
).
toString
():
"label"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getParentProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"parentProp"
)!=
null
?
advancedSettings
.
get
(
"parentProp"
).
toString
():
"parent"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getChildrenProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"childrenProp"
)!=
null
?
advancedSettings
.
get
(
"childrenProp"
).
toString
():
"children"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getDisabledProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"disabledProp"
)!=
null
?
advancedSettings
.
get
(
"disabledProp"
).
toString
():
"disabled"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getFilterProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"filterProp"
)!=
null
?
advancedSettings
.
get
(
"filterProp"
).
toString
():
"filter"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getExpiredProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"expiredProp"
)!=
null
?
advancedSettings
.
get
(
"expiredProp"
).
toString
():
"expired"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getIconClassProp
()
{
return
advancedSettings
!=
null
&&
advancedSettings
.
get
(
"iconClassProp"
)!=
null
?
advancedSettings
.
get
(
"iconClassProp"
).
toString
():
"iconClass"
;
}
public
CodeList
setNodes
(
List
<
Map
>
nodes
,
String
filter
,
String
subCode
)
{
Map
<
String
,
List
<
CodeItem
>>
map
=
new
LinkedHashMap
<>();
List
<
CodeItem
>
alllist
=
new
ArrayList
<>();
CodeItem
subOption
=
null
;
for
(
Map
item:
unfoldList
(
nodes
,
null
))
{
Map
<
String
,
Object
>
extension
=
new
HashMap
<>();
if
(!
StringUtils
.
isEmpty
(
item
.
get
(
"extension"
)))
extension
=
JSONObject
.
parseObject
(
item
.
get
(
"extension"
).
toString
(),
Map
.
class
);
String
pid
=
DataObject
.
getStringValue
(
item
.
get
(
this
.
getParentProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"pvalue"
),
"_root"
));
if
(
StringUtils
.
isEmpty
(
pid
))
pid
=
"_root"
;
List
<
CodeItem
>
list
=
null
;
if
(!
map
.
containsKey
(
pid
))
{
list
=
new
ArrayList
<>();
map
.
put
(
pid
,
list
);
}
else
list
=
map
.
get
(
pid
);
CodeItem
option
=
new
CodeItem
().
setValue
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getValueProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"id"
),
null
)))
.
setId
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getValueProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"id"
),
null
)))
.
setDisabled
(
DataObject
.
getBooleanValue
(
item
.
get
(
this
.
getDisabledProp
()),
false
)||
DataObject
.
getBooleanValue
(
item
.
get
(
this
.
getExpiredProp
()),
false
))
.
setFilter
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getFilterProp
()),
null
)).
setIconClass
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getIconClassProp
()),
null
))
.
setLabel
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getLabelProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"text"
),
""
)))
.
setParent
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getParentProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"pvalue"
),
""
))).
setExtension
(
extension
);
if
(
option
.
getValue
().
equals
(
subCode
))
subOption
=
option
;
if
(
StringUtils
.
isEmpty
(
filter
)||
option
.
getFilterSet
().
contains
(
filter
))
{
alllist
.
add
(
option
);
list
.
add
(
option
);
}
}
if
(
subOption
!=
null
)
{
List
<
CodeItem
>
codeItemTreeList
=
loop
(
map
,
(
StringUtils
.
isEmpty
(
subCode
))?
"_root"
:
subCode
);
codeItemTreeList
.
add
(
0
,
subOption
.
setParent
(
null
));
this
.
setOptions
(
codeItemTreeList
);
}
else
this
.
setOptions
(
alllist
);
return
this
;
}
public
List
<
Map
>
unfoldList
(
List
<
Map
>
nodes
,
String
parent
)
{
List
<
Map
>
unfoldList
=
new
ArrayList
<>();
for
(
Map
item:
nodes
)
{
if
((!
StringUtils
.
isEmpty
(
parent
))&&
StringUtils
.
isEmpty
(
DataObject
.
getStringValue
(
item
.
get
(
this
.
getParentProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"pvalue"
),
null
))))
item
.
put
(
this
.
getParentProp
(),
parent
);
String
value
=
DataObject
.
getStringValue
(
item
.
get
(
this
.
getValueProp
()),
DataObject
.
getStringValue
(
item
.
get
(
"id"
),
null
));
unfoldList
.
add
(
item
);
Object
child
=
item
.
get
(
this
.
getChildrenProp
());
if
(!
ObjectUtils
.
isEmpty
(
child
))
{
if
(
child
instanceof
List
&&
((
List
)
child
).
get
(
0
)
instanceof
Map
)
unfoldList
.
addAll
(
unfoldList
((
List
)
child
,
value
));
item
.
remove
(
this
.
getChildrenProp
());
}
}
return
unfoldList
;
}
public
List
<
CodeItem
>
loop
(
Map
<
String
,
List
<
CodeItem
>>
listCodeItem
,
Object
parentValue
)
{
List
<
CodeItem
>
trees
=
new
ArrayList
<
CodeItem
>();
if
(
listCodeItem
.
containsKey
(
parentValue
))
{
for
(
CodeItem
codeItem
:
listCodeItem
.
get
(
parentValue
))
{
trees
.
add
(
codeItem
);
List
<
CodeItem
>
childCodeItem
=
loop
(
listCodeItem
,
codeItem
.
getValue
());
if
(
childCodeItem
.
size
()
>
0
)
trees
.
addAll
(
childCodeItem
);
}
}
return
trees
;
}
}
ibzdst-util/src/main/java/cn/ibizlab/util/helper/DataObject.java
浏览文件 @
0c061a3e
...
...
@@ -159,7 +159,7 @@ public class DataObject {
if
(
objValue
instanceof
Boolean
)
{
return
(
Boolean
)
objValue
;
}
return
objValue
.
toString
().
equalsIgnoreCase
(
"true"
)||
objValue
.
toString
().
equals
(
"1"
)||
objValue
.
toString
().
equals
(
"y"
);
return
objValue
.
toString
().
equalsIgnoreCase
(
"true"
)||
objValue
.
toString
().
equals
(
"1"
)||
objValue
.
toString
().
equals
IgnoreCase
(
"y"
);
}
final
static
public
char
[]
getCharacterValue
(
Object
objValue
,
char
[]
cDefault
)
{
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录