Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
test
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邬友楠
test
Commits
f326c44c
Commit
f326c44c
authored
Aug 28, 2020
by
雍欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
系统参数缓存、初始化逻辑修改
parent
2ab637b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
231 additions
and
184 deletions
+231
-184
SystemCache.java
...ou-common/src/main/java/com/huigou/cache/SystemCache.java
+20
-12
ApplicationContextWrapper.java
.../main/java/com/huigou/util/ApplicationContextWrapper.java
+29
-17
SDO.java
huigou-common/src/main/java/com/huigou/util/SDO.java
+17
-10
OrgRepository.java
...com/huigou/uasp/bmp/opm/repository/org/OrgRepository.java
+2
-1
OrgApplicationImpl.java
...java/com/huigou/uasp/bmp/opm/impl/OrgApplicationImpl.java
+19
-6
ParameterApplicationImpl.java
...figuration/application/impl/ParameterApplicationImpl.java
+9
-1
PlugInFilter.java
...rc/main/java/com/huigou/uasp/bmp/plugin/PlugInFilter.java
+15
-22
ParameterPlugIn.java
...java/com/huigou/uasp/bmp/plugin/impl/ParameterPlugIn.java
+5
-3
WorkflowApplicationImpl.java
.../bpm/engine/application/impl/WorkflowApplicationImpl.java
+115
-111
spring-system.xml
huigou-xt/src/main/resources/config/spring/spring-system.xml
+0
-1
No files found.
huigou-common/src/main/java/com/huigou/cache/SystemCache.java
View file @
f326c44c
package
com
.
huigou
.
cache
;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
com.huigou.cache.service.ICache
;
import
com.huigou.util.ApplicationContextWrapper
;
import
com.huigou.util.ClassHelper
;
import
com.huigou.util.StringUtil
;
/**
* 单态模式保存系统常量使用ehcache缓存数据
*
* @ClassName: Singleton
* @author xx
* @version V1.0
* @ClassName: Singleton
*/
public
class
SystemCache
{
/**
* @deprecated 从1.2.11 开始自动从spring容器中获取缓存管理器。
*/
@Deprecated
private
ICache
icache
;
private
String
startTime
;
// 服务启动时间
...
...
@@ -62,26 +64,32 @@ public class SystemCache {
getInstance
().
startTime
=
startTime
;
}
@Deprecated
public
static
void
setCache
(
ICache
icache
)
{
getInstance
().
icache
=
icache
;
}
private
Optional
<
ICache
>
getIcache
()
{
ICache
iCache
=
this
.
icache
!=
null
?
this
.
icache
:
(
ICache
)
ApplicationContextWrapper
.
getBean
(
"sysDataCache"
);
return
Optional
.
ofNullable
(
iCache
);
}
private
void
put
(
String
cacheKey
,
Serializable
obj
)
{
icache
.
put
(
cacheKey
,
obj
);
getIcache
().
ifPresent
(
icache
->
icache
.
put
(
cacheKey
,
obj
)
);
}
private
Object
get
(
String
cacheKey
)
{
if
(
icache
==
null
)
return
null
;
return
icache
.
get
(
cacheKey
);
return
getIcache
().
map
(
icache
->
icache
.
get
(
cacheKey
))
.
orElse
(
null
);
}
private
<
T
>
T
get
(
String
cacheKey
,
Class
<
T
>
cls
)
{
if
(
icache
==
null
)
return
null
;
return
icache
.
get
(
cacheKey
,
cls
);
return
getIcache
().
map
(
icache
->
icache
.
get
(
cacheKey
,
cls
))
.
orElse
(
null
);
}
private
void
remove
(
String
key
)
{
icache
.
remove
(
key
,
"."
);
getIcache
().
ifPresent
(
icache
->
icache
.
remove
(
key
,
"."
)
);
}
public
static
String
getContextPath
()
{
...
...
@@ -208,7 +216,7 @@ public class SystemCache {
/**
* 国际化信息加入缓存中
*
*
* @param code
* @param Object
*/
...
...
huigou-common/src/main/java/com/huigou/util/ApplicationContextWrapper.java
View file @
f326c44c
package
com
.
huigou
.
util
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
import
java.util.Collection
;
/**
* spring 环境包装类
*
* @author xx
*/
public
class
ApplicationContextWrapper
{
private
ApplicationContext
applicationContext
;
@Component
public
class
ApplicationContextWrapper
implements
ApplicationContextAware
{
static
class
ApplicationContextHolder
{
static
ApplicationContextWrapper
instance
=
new
ApplicationContextWrapper
();
}
private
static
ApplicationContext
applicationContext
;
public
static
ApplicationContextWrapper
getInstance
()
{
return
ApplicationContextHolder
.
instance
;
}
public
void
setApplicationContext
(
ApplicationContext
context
)
{
this
.
applicationContext
=
context
;
ApplicationContextWrapper
.
applicationContext
=
context
;
}
public
ApplicationContext
getApplicationContext
()
{
return
applicationContext
;
}
@Deprecated
public
synchronized
static
void
init
(
ApplicationContext
context
)
{
getInstance
().
setApplicationContext
(
context
);
if
(
context
!=
null
)
{
ApplicationContextWrapper
.
applicationContext
=
context
;
}
}
public
static
ApplicationContext
getContext
()
{
return
getInstance
().
getApplicationContext
()
;
return
applicationContext
;
}
public
static
Object
getBean
(
String
beanName
)
{
if
(
getInstance
().
getApplicationContext
()
==
null
)
{
if
(
applicationContext
==
null
)
{
return
null
;
}
return
getInstance
().
getApplicationContext
()
.
getBean
(
beanName
);
return
applicationContext
.
getBean
(
beanName
);
}
/**
...
...
@@ -49,19 +51,29 @@ public class ApplicationContextWrapper {
* @return
*/
public
static
<
T
>
T
getBean
(
String
name
,
Class
<
T
>
type
)
{
if
(
getInstance
().
getApplicationContext
()
==
null
)
{
if
(
applicationContext
==
null
)
{
return
null
;
}
return
getInstance
().
getApplicationContext
()
.
getBean
(
name
,
type
);
return
applicationContext
.
getBean
(
name
,
type
);
}
/**
* @since 1.1.3
*/
public
static
<
T
>
T
getBean
(
Class
<
T
>
type
)
{
if
(
getInstance
().
getApplicationContext
()
==
null
)
{
if
(
applicationContext
==
null
)
{
return
null
;
}
return
applicationContext
.
getBean
(
type
);
}
/**
* @since 1.2.0
*/
public
static
<
T
>
Collection
<
T
>
getBeans
(
Class
<
T
>
type
)
{
if
(
applicationContext
==
null
)
{
return
null
;
}
return
getInstance
().
getApplicationContext
().
getBean
(
type
);
return
applicationContext
.
getBeansOfType
(
type
).
values
(
);
}
}
huigou-common/src/main/java/com/huigou/util/SDO.java
View file @
f326c44c
...
...
@@ -13,7 +13,7 @@ import org.apache.commons.lang.StringUtils;
/**
* 服务数据对象
*
*
* @author Gelard
*/
public
class
SDO
implements
Serializable
{
...
...
@@ -184,7 +184,7 @@ public class SDO implements Serializable {
return
this
.
getProperty
(
key
,
Integer
.
class
);
}
public
Integer
getInteger
(
String
key
,
Integer
defaultValue
)
{
public
Integer
getInteger
(
String
key
,
Integer
defaultValue
)
{
return
Optional
.
ofNullable
(
getInteger
(
key
)).
orElse
(
defaultValue
);
}
...
...
@@ -224,7 +224,7 @@ public class SDO implements Serializable {
return
null
;
}
@SuppressWarnings
({
"unchecked"
})
@SuppressWarnings
({
"unchecked"
})
public
<
T
>
List
<
T
>
getList
(
String
key
,
Class
<
T
>
clazz
)
{
List
<
T
>
beanList
=
new
ArrayList
<
T
>();
List
<
Object
>
list
=
getList
(
key
);
...
...
@@ -261,6 +261,14 @@ public class SDO implements Serializable {
return
null
;
}
public
<
T
>
Optional
<
T
>
getObject
(
String
key
,
Class
<
T
>
clazz
)
{
Object
value
=
properties
.
get
(
key
);
if
(
value
==
null
)
{
return
Optional
.
empty
();
}
return
Optional
.
ofNullable
((
T
)
value
);
}
public
void
parseJSONString
(
String
jsonStr
)
{
if
(
StringUtil
.
isBlank
(
jsonStr
))
{
return
;
...
...
@@ -275,11 +283,11 @@ public class SDO implements Serializable {
/**
* SDO中数据转换为对象
*
* @author
*
* @param cls
* @return
* @throws Exception
* @author
*/
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
toObject
(
Class
<
T
>
cls
)
{
...
...
@@ -302,7 +310,7 @@ public class SDO implements Serializable {
/**
* 获取查询请求对象
*
*
* @param cls
* @return
*/
...
...
@@ -334,11 +342,10 @@ public class SDO implements Serializable {
/**
* 改变键名称
*
* @author
*
* @param oldName
* @param newName
*
void
* @param newName
void
*
@author
*/
public
void
changKeyName
(
String
oldName
,
String
newName
)
{
Object
value
=
this
.
getProperty
(
oldName
);
...
...
huigou-core-api/src/main/java/com/huigou/uasp/bmp/opm/repository/org/OrgRepository.java
View file @
f326c44c
...
...
@@ -3,6 +3,7 @@ package com.huigou.uasp.bmp.opm.repository.org;
import
java.util.List
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
com.huigou.uasp.bmp.opm.domain.model.org.Org
;
...
...
@@ -13,7 +14,7 @@ import com.huigou.uasp.bmp.opm.domain.model.org.OrgType;
*
* @author gongmm
*/
public
interface
OrgRepository
extends
JpaRepository
<
Org
,
String
>
{
public
interface
OrgRepository
extends
JpaRepository
<
Org
,
String
>
,
JpaSpecificationExecutor
<
Org
>
{
List
<
Org
>
findByFullIdLike
(
String
fullId
);
...
...
huigou-core-impl/src/main/java/com/huigou/uasp/bmp/opm/impl/OrgApplicationImpl.java
View file @
f326c44c
...
...
@@ -35,6 +35,7 @@ import com.huigou.util.*;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.Assert
;
...
...
@@ -67,6 +68,10 @@ public class OrgApplicationImpl extends BaseApplication implements OrgApplicatio
private
ManagementApplication
managementApplication
;
private
LicenseChecker
licenseChecker
;
/**
* 是否强制生成主键
*/
private
boolean
forceGenerateIdentifier
=
true
;
@Autowired
public
void
setOrgPropertyDefinitionRepository
(
OrgPropertyDefinitionRepository
orgPropertyDefinitionRepository
)
{
...
...
@@ -133,6 +138,12 @@ public class OrgApplicationImpl extends BaseApplication implements OrgApplicatio
return
licenseChecker
;
}
@Autowired
(
required
=
false
)
@Value
(
"${org.forceGenerateIdentifier}"
)
public
void
setForceGenerateIdentifier
(
boolean
forceGenerateIdentifier
)
{
this
.
forceGenerateIdentifier
=
forceGenerateIdentifier
;
}
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
@Override
public
String
saveOrgPropertyDefinition
(
OrgPropertyDefinition
orgPropertyDefinition
)
{
...
...
@@ -477,8 +488,10 @@ public class OrgApplicationImpl extends BaseApplication implements OrgApplicatio
parent
=
orgRepository
.
findOne
(
org
.
getParentId
());
}
String
id
=
CommonUtil
.
createGUID
();
org
.
setId
(
id
);
if
(
StringUtils
.
isBlank
(
org
.
getId
())
||
StringUtils
.
isNotBlank
(
org
.
getId
())
&&
forceGenerateIdentifier
)
{
String
id
=
CommonUtil
.
createGUID
();
org
.
setId
(
id
);
}
if
(
StringUtil
.
isBlank
(
org
.
getTenantId
()))
{
setOrgTenantId
(
org
);
...
...
@@ -1464,13 +1477,13 @@ public class OrgApplicationImpl extends BaseApplication implements OrgApplicatio
public
void
initPassword
(
String
personId
,
String
newPassword
)
{
Assert
.
hasText
(
personId
,
String
.
format
(
CommonDomainConstants
.
PARAMETER_NOT_NULL_FORMAT
,
"personId"
));
Person
person
=
this
.
loadPerson
(
personId
);
Util
.
check
(
person
!=
null
,
"没有找到ID“%s”对应的人员。"
,
new
Object
[]
{
personId
});
Util
.
check
(
person
!=
null
,
"没有找到ID“%s”对应的人员。"
,
new
Object
[]
{
personId
});
String
decodedPassword
=
new
String
(
Base64
.
decodeBase64
(
newPassword
));
person
.
setPassword
(
Md5Builder
.
getMd5
(
decodedPassword
));
this
.
personRepository
.
save
(
person
);
if
(
initPasswordListener
!=
null
)
{
if
(
initPasswordListener
!=
null
)
{
//发送邮件
initPasswordListener
.
onInitPassword
(
person
,
decodedPassword
);
initPasswordListener
.
onInitPassword
(
person
,
decodedPassword
);
}
}
...
...
@@ -1490,7 +1503,7 @@ public class OrgApplicationImpl extends BaseApplication implements OrgApplicatio
if
(
person
.
getSecurityGrade
()
!=
null
)
{
String
decodedNewPassword
=
new
String
(
Base64
.
decodeBase64
(
newPassword
));
SecurityPolicy
securityPolicy
=
this
.
securityPolicyApplication
.
findSecurityGrade
(
person
.
getSecurityGrade
(),
ValidStatus
.
ENABLED
.
getId
());
String
securityGradeText
=
DictUtil
.
getDictionaryDetailText
(
"securityGrade"
,
person
.
getSecurityGrade
());
String
securityGradeText
=
DictUtil
.
getDictionaryDetailText
(
"securityGrade"
,
person
.
getSecurityGrade
());
Assert
.
state
(
securityPolicy
!=
null
,
String
.
format
(
"密级“%s”没有设置或启用安全策略。"
,
securityGradeText
));
if
(
decodedNewPassword
.
length
()
<
securityPolicy
.
getPasswordMinimumLength
())
{
...
...
huigou-uasp/src/main/java/com/huigou/uasp/bmp/configuration/application/impl/ParameterApplicationImpl.java
View file @
f326c44c
...
...
@@ -3,6 +3,8 @@ package com.huigou.uasp.bmp.configuration.application.impl;
import
java.util.List
;
import
java.util.Map
;
import
com.huigou.util.LogHome
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -25,7 +27,7 @@ import com.huigou.uasp.bmp.configuration.repository.SysParameterRepository;
* @author gongmm
*/
@Service
(
"parameterApplication"
)
public
class
ParameterApplicationImpl
extends
BaseApplication
implements
ParameterApplication
{
public
class
ParameterApplicationImpl
extends
BaseApplication
implements
ParameterApplication
,
InitializingBean
{
@Autowired
private
CodingGenerator
codingGenerator
;
...
...
@@ -84,4 +86,10 @@ public class ParameterApplicationImpl extends BaseApplication implements Paramet
}
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
LogHome
.
getLog
(
this
).
info
(
"开始加载系统参数;"
);
this
.
syncCache
();
LogHome
.
getLog
(
this
).
info
(
"系统参数加载完成;"
);
}
}
huigou-uasp/src/main/java/com/huigou/uasp/bmp/plugin/PlugInFilter.java
View file @
f326c44c
package
com
.
huigou
.
uasp
.
bmp
.
plugin
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
javax.servlet.Filter
;
import
javax.servlet.FilterChain
;
import
javax.servlet.FilterConfig
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
org.springframework.web.context.support.WebApplicationContextUtils
;
import
com.huigou.cache.SystemCache
;
import
com.huigou.cache.service.ICache
;
import
com.huigou.express.ExpressManager
;
...
...
@@ -23,11 +8,18 @@ import com.huigou.express.LoadExpressClasses;
import
com.huigou.util.ApplicationContextWrapper
;
import
com.huigou.util.Constants
;
import
com.huigou.util.DateUtil
;
import
com.huigou.util.SpringBeanFactory
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.web.context.support.WebApplicationContextUtils
;
import
javax.servlet.*
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
/**
* 系统初始化过滤器
*
*
* @author gongmm
*/
public
class
PlugInFilter
implements
Filter
{
...
...
@@ -36,17 +28,18 @@ public class PlugInFilter implements Filter {
ServletContext
servletContext
=
filterConfig
.
getServletContext
();
String
contextPath
=
servletContext
.
getContextPath
();
String
realPath
=
servletContext
.
getRealPath
(
"/"
);
ApplicationContextWrapper
.
init
(
WebApplicationContextUtils
.
getWebApplicationContext
(
servletContext
));
ApplicationContext
applicationContext
=
WebApplicationContextUtils
.
getWebApplicationContext
(
servletContext
);
ApplicationContextWrapper
.
init
(
applicationContext
);
try
{
// 初始化系统数据缓存
SystemCache
.
setCache
(
SpringBeanFactory
.
getBean
(
servletContext
,
"sysDataCache"
,
ICache
.
class
));
SystemCache
.
setCache
(
applicationContext
.
getBean
(
"sysDataCache"
,
ICache
.
class
));
SystemCache
.
setRealPath
(
realPath
);
SystemCache
.
setContextPath
(
contextPath
);
SystemCache
.
setStartTime
(
DateUtil
.
getDateFormat
(
"yyyyMMddHH"
,
DateUtil
.
getTimestamp
()));
initPath
(
SystemCache
.
getContextPath
(),
SystemCache
.
getRealPath
());
// 创建JS系统文件
ExpressManager
.
initExpress
(
SpringBeanFactory
.
getBean
(
servletContext
,
"expressUtil"
,
ExpressUtil
.
class
),
SpringBeanFactory
.
getBean
(
servletContext
,
"loadExpressClasses"
,
LoadExpressClasses
.
class
));
PlugInManager
pm
=
SpringBeanFactory
.
getBean
(
servletContext
,
"plugInManager"
,
PlugInManager
.
class
);
ExpressManager
.
initExpress
(
applicationContext
.
getBean
(
"expressUtil"
,
ExpressUtil
.
class
),
applicationContext
.
getBean
(
"loadExpressClasses"
,
LoadExpressClasses
.
class
));
PlugInManager
pm
=
applicationContext
.
getBean
(
"plugInManager"
,
PlugInManager
.
class
);
pm
.
init
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
huigou-uasp/src/main/java/com/huigou/uasp/bmp/plugin/impl/ParameterPlugIn.java
View file @
f326c44c
...
...
@@ -9,12 +9,14 @@ import com.huigou.util.LogHome;
/**
* 系统参数插件
*
* @ClassName: ParameterPlugIn
*
* @author
* @date 2014-2-24 上午10:51:46
* @version V1.0
* @ClassName: ParameterPlugIn
* @date 2014-2-24 上午10:51:46
* @deprecated 从1.2.11开始,在{@link com.huigou.uasp.bmp.configuration.application.impl.ParameterApplicationImpl}内部完成初始化缓存
*/
@Deprecated
@Service
(
"parameterPlugIn"
)
public
class
ParameterPlugIn
implements
StartPlugIn
{
...
...
huigou-uasp/src/main/java/com/huigou/uasp/bpm/engine/application/impl/WorkflowApplicationImpl.java
View file @
f326c44c
This diff is collapsed.
Click to expand it.
huigou-xt/src/main/resources/config/spring/spring-system.xml
View file @
f326c44c
...
...
@@ -47,7 +47,6 @@
<property
name=
"plugIns"
>
<list>
<ref
bean=
"sysDictionaryPlugIn"
/>
<ref
bean=
"parameterPlugIn"
/>
<ref
bean=
"tmspmPlugIn"
/>
<ref
bean=
"threeMemberPermissionPlugIn"
/>
<ref
bean=
"applicationSystemPlugIn"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment