Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
存储配置服务
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8033818e
authored
Feb 09, 2022
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
缓存
1 parent
1b130e8f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
src/main/java/com/viontech/storage/entity/Generator.java
src/main/java/com/viontech/storage/entity/Generator.java
View file @
8033818
package
com
.
viontech
.
storage
.
entity
;
package
com
.
viontech
.
storage
.
entity
;
import
cn.hutool.cache.CacheUtil
;
import
cn.hutool.cache.impl.TimedCache
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.core.util.XmlUtil
;
import
cn.hutool.core.util.XmlUtil
;
...
@@ -21,6 +23,7 @@ import org.w3c.dom.Document;
...
@@ -21,6 +23,7 @@ import org.w3c.dom.Document;
import
org.w3c.dom.Element
;
import
org.w3c.dom.Element
;
import
org.w3c.dom.Node
;
import
org.w3c.dom.Node
;
import
java.time.Duration
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -35,7 +38,7 @@ import java.util.stream.Collectors;
...
@@ -35,7 +38,7 @@ import java.util.stream.Collectors;
public
class
Generator
{
public
class
Generator
{
private
static
final
String
ROOT_ELEMENT_NAME
=
"StorageConfig"
;
private
static
final
String
ROOT_ELEMENT_NAME
=
"StorageConfig"
;
private
static
final
String
FILE_VERSION
=
"001-012-000-000"
;
private
static
final
String
FILE_VERSION
=
"001-012-000-000"
;
private
static
final
TimedCache
<
Long
,
Generator
>
CACHE
=
CacheUtil
.
newTimedCache
(
Duration
.
ofSeconds
(
5
).
toMillis
());
private
final
Document
document
=
XmlUtil
.
createXml
(
ROOT_ELEMENT_NAME
);
private
final
Document
document
=
XmlUtil
.
createXml
(
ROOT_ELEMENT_NAME
);
/** 来自 StorageConfig, 对应 Solution */
/** 来自 StorageConfig, 对应 Solution */
private
final
List
<
Context
>
contexts
;
private
final
List
<
Context
>
contexts
;
...
@@ -43,8 +46,11 @@ public class Generator {
...
@@ -43,8 +46,11 @@ public class Generator {
private
final
Map
<
Long
,
PicConfigVo
>
picConfigMap
;
private
final
Map
<
Long
,
PicConfigVo
>
picConfigMap
;
/** key: captionSetId */
/** key: captionSetId */
private
final
Map
<
Long
,
List
<
CaptionVo
>>
captionSetMap
;
private
final
Map
<
Long
,
List
<
CaptionVo
>>
captionSetMap
;
private
String
config
;
public
Generator
(
Long
storageConfigId
)
{
public
Generator
(
Long
storageConfigId
)
{
Generator
generator
=
CACHE
.
get
(
storageConfigId
);
if
(
generator
==
null
)
{
StorageConfigService
storageConfigService
=
SpringUtil
.
getBean
(
StorageConfigService
.
class
);
StorageConfigService
storageConfigService
=
SpringUtil
.
getBean
(
StorageConfigService
.
class
);
PicConfigService
picConfigService
=
SpringUtil
.
getBean
(
PicConfigService
.
class
);
PicConfigService
picConfigService
=
SpringUtil
.
getBean
(
PicConfigService
.
class
);
CaptionService
captionService
=
SpringUtil
.
getBean
(
CaptionService
.
class
);
CaptionService
captionService
=
SpringUtil
.
getBean
(
CaptionService
.
class
);
...
@@ -69,9 +75,17 @@ public class Generator {
...
@@ -69,9 +75,17 @@ public class Generator {
List
<
Caption
>
captions
=
captionService
.
list
(
captionService
.
query
().
in
(
"caption_set_id"
,
captionSetIds
).
getWrapper
());
List
<
Caption
>
captions
=
captionService
.
list
(
captionService
.
query
().
in
(
"caption_set_id"
,
captionSetIds
).
getWrapper
());
this
.
captionSetMap
=
captions
.
stream
().
map
(
CaptionVo:
:
copy
).
collect
(
Collectors
.
groupingBy
(
CaptionVo:
:
getCaptionSetId
,
Collectors
.
toList
()));
this
.
captionSetMap
=
captions
.
stream
().
map
(
CaptionVo:
:
copy
).
collect
(
Collectors
.
groupingBy
(
CaptionVo:
:
getCaptionSetId
,
Collectors
.
toList
()));
CACHE
.
put
(
storageConfigId
,
this
);
}
else
{
this
.
contexts
=
generator
.
contexts
;
this
.
picConfigMap
=
generator
.
picConfigMap
;
this
.
captionSetMap
=
generator
.
captionSetMap
;
this
.
config
=
generator
.
config
;
}
}
}
public
String
build
()
{
public
String
build
()
{
if
(
this
.
config
==
null
)
{
// 基本上算是固定写法
// 基本上算是固定写法
Node
rootNode
=
document
.
getFirstChild
();
Node
rootNode
=
document
.
getFirstChild
();
rootNode
.
appendChild
(
createTextNode
(
"FileVersion"
,
FILE_VERSION
));
rootNode
.
appendChild
(
createTextNode
(
"FileVersion"
,
FILE_VERSION
));
...
@@ -92,7 +106,9 @@ public class Generator {
...
@@ -92,7 +106,9 @@ public class Generator {
standard
.
appendChild
(
solution
);
standard
.
appendChild
(
solution
);
}
}
}
}
return
XmlUtil
.
toStr
(
document
,
"GBK"
,
false
);
this
.
config
=
XmlUtil
.
toStr
(
document
,
"GBK"
,
false
);
}
return
this
.
config
;
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment