Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chuanshan_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖旭伟
chuanshan_gov_platform
Commits
26b3c42c
Commit
26b3c42c
authored
Mar 05, 2024
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
集成到4.0框架下
parent
47125fee
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
599 additions
and
531 deletions
+599
-531
common-lib/src/main/java/com/mortals/xhx/common/pdu/user/UserPdu.java
...rc/main/java/com/mortals/xhx/common/pdu/user/UserPdu.java
+3
-1
common-lib/src/main/java/com/mortals/xhx/feign/user/IUserFeign.java
.../src/main/java/com/mortals/xhx/feign/user/IUserFeign.java
+22
-20
single-matter/pom.xml
single-matter/pom.xml
+3
-4
single-matter/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthTokenServiceImpl.java
.../xhx/base/framework/interceptor/AuthTokenServiceImpl.java
+48
-20
single-matter/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthUserInterceptor.java
...s/xhx/base/framework/interceptor/AuthUserInterceptor.java
+4
-6
single-matter/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
...ase/system/resource/service/impl/ResourceServiceImpl.java
+0
-16
single-matter/src/main/java/com/mortals/xhx/base/system/user/service/UserService.java
...com/mortals/xhx/base/system/user/service/UserService.java
+2
-1
single-matter/src/main/java/com/mortals/xhx/base/system/user/service/impl/UserServiceImpl.java
...ls/xhx/base/system/user/service/impl/UserServiceImpl.java
+2
-7
single-matter/src/main/java/com/mortals/xhx/common/key/RedisKey.java
...er/src/main/java/com/mortals/xhx/common/key/RedisKey.java
+1
-0
single-matter/src/main/java/com/mortals/xhx/common/utils/MenuEncodeUtil.java
...ain/java/com/mortals/xhx/common/utils/MenuEncodeUtil.java
+30
-0
single-matter/src/main/java/com/mortals/xhx/common/utils/SyncTreeSiteThread.java
...java/com/mortals/xhx/common/utils/SyncTreeSiteThread.java
+34
-34
single-matter/src/main/java/com/mortals/xhx/daemon/applicationservice/DemoStartedService.java
...als/xhx/daemon/applicationservice/DemoStartedService.java
+82
-97
single-matter/src/main/java/com/mortals/xhx/daemon/task/MatterDatumConvertTaskImpl.java
...m/mortals/xhx/daemon/task/MatterDatumConvertTaskImpl.java
+202
-202
single-matter/src/main/java/com/mortals/xhx/daemon/task/StatSiteDeptMatterTaskImpl.java
...m/mortals/xhx/daemon/task/StatSiteDeptMatterTaskImpl.java
+0
-60
single-matter/src/main/java/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
...a/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
+103
-0
single-matter/src/main/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
...in/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
+63
-63
No files found.
common-lib/src/main/java/com/mortals/xhx/common/pdu/user/UserPdu.java
View file @
26b3c42c
package
com.mortals.xhx.common.pdu.user
;
package
com.mortals.xhx.common.pdu.user
;
import
com.mortals.framework.model.BaseEntityLong
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
com.mortals.framework.model.BaseEntityLong
;
/**
/**
* 用户信息业务Pdu对象
* 用户信息业务Pdu对象
...
...
common-lib/src/main/java/com/mortals/xhx/feign/user/IUserFeign.java
View file @
26b3c42c
package
com.mortals.xhx.feign.user
;
package
com.mortals.xhx.feign.user
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.feign.IFeign
;
import
com.mortals.xhx.feign.IFeign
;
import
feign.hystrix.FallbackFactory
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -15,11 +15,10 @@ import java.util.List;
...
@@ -15,11 +15,10 @@ import java.util.List;
/**
/**
* 用户信息业务 Feign接口
* 用户信息业务 Feign接口
*
* @author zxfei
* @author zxfei
* @date 2022-07-06
* @date 2022-07-06
*/
*/
//
@FeignClient(name = "portal-manager", path = "/zwfw", fallbackFactory = UserFeignFallbackFactory.class)
@FeignClient
(
name
=
"portal-manager"
,
path
=
"/zwfw"
,
fallbackFactory
=
UserFeignFallbackFactory
.
class
)
public
interface
IUserFeign
extends
IFeign
{
public
interface
IUserFeign
extends
IFeign
{
...
@@ -29,7 +28,7 @@ public interface IUserFeign extends IFeign {
...
@@ -29,7 +28,7 @@ public interface IUserFeign extends IFeign {
* @param userPdu
* @param userPdu
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/user/list"
)
@PostMapping
(
value
=
"/user/
inter
list"
)
Rest
<
RespData
<
List
<
UserPdu
>>>
list
(
@RequestBody
UserPdu
userPdu
);
Rest
<
RespData
<
List
<
UserPdu
>>>
list
(
@RequestBody
UserPdu
userPdu
);
...
@@ -39,7 +38,7 @@ public interface IUserFeign extends IFeign {
...
@@ -39,7 +38,7 @@ public interface IUserFeign extends IFeign {
* @param id
* @param id
* @return
* @return
*/
*/
@GetMapping
(
value
=
"/user/info"
)
@GetMapping
(
value
=
"/user/in
terin
fo"
)
Rest
<
UserPdu
>
info
(
@RequestParam
(
value
=
"id"
)
Long
id
);
Rest
<
UserPdu
>
info
(
@RequestParam
(
value
=
"id"
)
Long
id
);
/**
/**
...
@@ -49,7 +48,7 @@ public interface IUserFeign extends IFeign {
...
@@ -49,7 +48,7 @@ public interface IUserFeign extends IFeign {
* @return
* @return
*/
*/
@GetMapping
(
value
=
"/user/delete"
)
@GetMapping
(
value
=
"/user/delete"
)
Rest
<
Void
>
delete
(
Long
[]
ids
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
Rest
<
Void
>
delete
(
Long
[]
ids
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
/**
/**
...
@@ -59,12 +58,21 @@ public interface IUserFeign extends IFeign {
...
@@ -59,12 +58,21 @@ public interface IUserFeign extends IFeign {
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/user/save"
)
@PostMapping
(
value
=
"/user/save"
)
Rest
<
RespData
<
UserPdu
>>
save
(
@RequestBody
UserPdu
userPdu
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
Rest
<
RespData
<
UserPdu
>>
save
(
@RequestBody
UserPdu
userPdu
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
@PostMapping
(
value
=
"/login/login"
)
@PostMapping
(
value
=
"/login/login"
)
String
portalLogin
(
@RequestBody
UserPdu
userPdu
);
String
portalLogin
(
@RequestBody
UserPdu
userPdu
);
/**
* 查询用户列表
*
* @param userPdu
* @return
*/
@PostMapping
(
"/api/user/findAllUser"
)
String
findAllUser
(
@RequestBody
UserPdu
userPdu
);
/**
/**
* 获取token
* 获取token
...
@@ -76,9 +84,6 @@ public interface IUserFeign extends IFeign {
...
@@ -76,9 +84,6 @@ public interface IUserFeign extends IFeign {
Rest
<
String
>
getToken
(
@RequestParam
(
value
=
"userKey"
)
String
userKey
);
Rest
<
String
>
getToken
(
@RequestParam
(
value
=
"userKey"
)
String
userKey
);
@PostMapping
(
value
=
"/user/synchSiteAuth"
)
Rest
<
String
>
synchSiteAuth
();
}
}
...
@@ -87,7 +92,6 @@ public interface IUserFeign extends IFeign {
...
@@ -87,7 +92,6 @@ public interface IUserFeign extends IFeign {
class
UserFeignFallbackFactory
implements
FallbackFactory
<
IUserFeign
>
{
class
UserFeignFallbackFactory
implements
FallbackFactory
<
IUserFeign
>
{
@Override
@Override
public
IUserFeign
create
(
Throwable
t
)
{
public
IUserFeign
create
(
Throwable
t
)
{
log
.
error
(
"feign error"
,
t
);
return
new
IUserFeign
()
{
return
new
IUserFeign
()
{
@Override
@Override
public
Rest
<
RespData
<
List
<
UserPdu
>>>
list
(
UserPdu
userPdu
)
{
public
Rest
<
RespData
<
List
<
UserPdu
>>>
list
(
UserPdu
userPdu
)
{
...
@@ -115,16 +119,14 @@ class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> {
...
@@ -115,16 +119,14 @@ class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> {
}
}
@Override
@Override
public
Rest
<
String
>
getToken
(
String
userKey
)
{
public
String
findAllUser
(
UserPdu
userPdu
)
{
return
Rest
.
fail
(
"token获取失败"
)
;
return
null
;
}
}
@Override
@Override
public
Rest
<
String
>
synchSiteAuth
(
)
{
public
Rest
<
String
>
getToken
(
String
userKey
)
{
return
Rest
.
fail
(
"
同步请求失败,稍后再试!
"
);
return
Rest
.
fail
(
"
token获取失败
"
);
}
}
};
};
}
}
}
}
...
...
single-matter/pom.xml
View file @
26b3c42c
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.namespace>
smart-gov
-chuanshan
</profiles.nacos.namespace>
<profiles.nacos.namespace>
smart-gov
</profiles.nacos.namespace>
<profiles.log.path>
/home/mortals/app/logs
</profiles.log.path>
<profiles.log.path>
/home/mortals/app/logs
</profiles.log.path>
<profiles.log.level>
INFO
</profiles.log.level>
<profiles.log.level>
INFO
</profiles.log.level>
<package.environment>
test
</package.environment>
<package.environment>
test
</package.environment>
...
@@ -38,14 +38,13 @@
...
@@ -38,14 +38,13 @@
</profile>
</profile>
<profile>
<profile>
<id>
test
</id>
<id>
test
</id>
<properties>
<properties>
<profiles.active>
test
</profiles.active>
<profiles.active>
test
</profiles.active>
<profiles.server.path>
/sm
</profiles.server.path>
<profiles.server.path>
/sm
</profiles.server.path>
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.namespace>
smart-gov
-chuanshan
</profiles.nacos.namespace>
<profiles.nacos.namespace>
smart-gov
</profiles.nacos.namespace>
<profiles.log.path>
/home/mortals/app/logs
</profiles.log.path>
<profiles.log.path>
/home/mortals/app/logs
</profiles.log.path>
<profiles.log.level>
INFO
</profiles.log.level>
<profiles.log.level>
INFO
</profiles.log.level>
<package.environment>
test
</package.environment>
<package.environment>
test
</package.environment>
...
@@ -62,7 +61,7 @@
...
@@ -62,7 +61,7 @@
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.nacos.server-addr>
127.0.0.1:8848
</profiles.nacos.server-addr>
<profiles.nacos.server-addr>
127.0.0.1:8848
</profiles.nacos.server-addr>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.namespace>
smart-gov
-chuanshan
</profiles.nacos.namespace>
<profiles.nacos.namespace>
smart-gov
</profiles.nacos.namespace>
<profiles.log.path>
/home/mortals/app/logs
</profiles.log.path>
<profiles.log.path>
/home/mortals/app/logs
</profiles.log.path>
<profiles.log.level>
INFO
</profiles.log.level>
<profiles.log.level>
INFO
</profiles.log.level>
<package.environment>
build
</package.environment>
<package.environment>
build
</package.environment>
...
...
single-matter/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthTokenServiceImpl.java
View file @
26b3c42c
...
@@ -7,10 +7,11 @@ import com.mortals.framework.service.ICacheService;
...
@@ -7,10 +7,11 @@ import com.mortals.framework.service.ICacheService;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.utils.MenuEncodeUtil
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
io.jsonwebtoken.SignatureAlgorithm
;
...
@@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
import
java.util.Base64
;
import
java.util.Base64
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
/**
/**
* token验证处理
* token验证处理
...
@@ -33,7 +36,7 @@ import java.util.Map;
...
@@ -33,7 +36,7 @@ import java.util.Map;
* @author zxfei
* @author zxfei
*/
*/
@Primary
@Primary
@Service
@Service
(
"authTokenService"
)
@Order
(
1
)
@Order
(
1
)
@Slf4j
@Slf4j
public
class
AuthTokenServiceImpl
implements
IAuthTokenService
{
public
class
AuthTokenServiceImpl
implements
IAuthTokenService
{
...
@@ -78,6 +81,10 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -78,6 +81,10 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
@Autowired
@Autowired
private
ICacheService
cacheService
;
private
ICacheService
cacheService
;
@Autowired
private
ResourceService
resourceService
;
/**
/**
* 获取信息
* 获取信息
*
*
...
@@ -90,28 +97,42 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -90,28 +97,42 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
String
token
=
getToken
(
request
);
String
token
=
getToken
(
request
);
if
(
StringUtils
.
isNotEmpty
(
token
))
{
if
(
StringUtils
.
isNotEmpty
(
token
))
{
try
{
try
{
boolean
signed
=
Jwts
.
parser
().
isSigned
(
token
);
if
(!
signed
)
{
log
.
error
(
"token非法!=>{}"
,
token
);
return
null
;
}
Claims
claims
=
parseToken
(
token
);
Claims
claims
=
parseToken
(
token
);
String
uuid
=
(
String
)
claims
.
get
(
SysConstains
.
LOGIN_USER_KEY
);
String
uuid
=
(
String
)
claims
.
get
(
SysConstains
.
LOGIN_USER_KEY
);
String
userKey
=
getTokenKey
(
uuid
);
String
userKey
=
getTokenKey
(
uuid
);
//cacheService.select(portalDb);
/* cacheService.select(portalDb);
String
userStr
=
cacheService
.
get
(
userKey
);
String userStr = cacheService.get(userKey);*/
//cacheService.select(db);
// Rest<String> rest = userFeign.getToken(userKey
);
RedisTemplate
<
String
,
String
>
redisTemplate
=
cacheService
.
selectDbRedisTemplate
(
portalDb
);
// String userStr = rest.getData(
);
String
userStr
=
redisTemplate
.
opsForValue
().
get
(
userKey
);
if
(
StringUtils
.
isNotEmpty
(
userStr
))
{
//刷新token时间
UserEntity
userEntity
=
JSONObject
.
parseObject
(
userStr
,
UserEntity
.
class
);
UserEntity
userEntity
=
JSONObject
.
parseObject
(
userStr
,
UserEntity
.
class
);
userEntity
.
setToken
(
token
);
if
(!
ObjectUtils
.
isEmpty
(
userEntity
))
{
verifyToken
(
userEntity
);
UserEntity
temp
=
userService
.
selectOne
(
new
UserQuery
().
loginName
(
userEntity
.
getLoginName
()));
}
if
(!
ObjectUtils
.
isEmpty
(
temp
)){
// cacheService.select(db);
if
(!
ObjectUtils
.
isEmpty
(
userEntity
))
{
UserEntity
temp
=
userService
.
getExtCache
(
userEntity
.
getLoginName
());
if
(!
ObjectUtils
.
isEmpty
(
temp
))
{
userEntity
.
setId
(
temp
.
getId
());
userEntity
.
setId
(
temp
.
getId
());
}
}
//更新resource 路径
String
menuUrlCode
=
cacheService
.
hget
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userEntity
.
getId
().
toString
(),
String
.
class
);
if
(
ObjectUtils
.
isEmpty
(
menuUrlCode
))
{
Set
<
String
>
urls
=
resourceService
.
findUrlSetByUserId
(
userEntity
.
getId
());
menuUrlCode
=
MenuEncodeUtil
.
generateMenuUrlCode
(
urls
);
cacheService
.
hset
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userEntity
.
getId
().
toString
(),
menuUrlCode
);
}
userEntity
.
setMenuUrl
(
menuUrlCode
);
return
userEntity
;
return
userEntity
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"解析jwt token异常!
"
,
e
);
log
.
error
(
"解析jwt token异常!
,token:{}"
,
token
,
e
);
return
null
;
return
null
;
}
}
}
}
...
@@ -165,8 +186,8 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -165,8 +186,8 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
public
void
verifyToken
(
IUser
user
)
{
public
void
verifyToken
(
IUser
user
)
{
long
expireTime
=
user
.
getExpireTime
();
long
expireTime
=
user
.
getExpireTime
();
long
currentTime
=
System
.
currentTimeMillis
();
long
currentTime
=
System
.
currentTimeMillis
();
if
(
expireTime
-
currentTime
<=
SECOND_MINUTE_TEN
)
{
if
(
expireTime
-
currentTime
<=
SECOND_MINUTE_TEN
*
1000
)
{
log
.
info
(
"不足十分钟,刷新过期时间"
);
log
.
info
(
"不足
二
十分钟,刷新过期时间"
);
refreshToken
(
user
);
refreshToken
(
user
);
}
}
}
}
...
@@ -178,7 +199,7 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -178,7 +199,7 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
*/
*/
public
void
refreshToken
(
IUser
user
)
{
public
void
refreshToken
(
IUser
user
)
{
//user.setLoginTime(System.currentTimeMillis());
//user.setLoginTime(System.currentTimeMillis());
user
.
setExpireTime
(
user
.
getLoginTime
()
==
null
?
System
.
currentTimeMillis
()
:
user
.
getLoginTime
()
+
expireTime
*
SECOND_MINUTE
);
user
.
setExpireTime
(
user
.
getLoginTime
()
==
null
?
System
.
currentTimeMillis
()
:
user
.
getLoginTime
()
+
expireTime
*
SECOND_MINUTE
*
1000
);
// 根据uuid将user缓存
// 根据uuid将user缓存
String
userKey
=
getTokenKey
(
user
.
getToken
());
String
userKey
=
getTokenKey
(
user
.
getToken
());
//设置有效时间 单位秒
//设置有效时间 单位秒
...
@@ -245,4 +266,11 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -245,4 +266,11 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
private
String
getTokenKey
(
String
uuid
)
{
private
String
getTokenKey
(
String
uuid
)
{
return
SysConstains
.
LOGIN_TOKEN_KEY
+
uuid
;
return
SysConstains
.
LOGIN_TOKEN_KEY
+
uuid
;
}
}
public
static
void
main
(
String
[]
args
)
{
// boolean signed = Jwts.parser().isSigned("123");
boolean
signed
=
Jwts
.
parser
().
isSigned
(
"eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuaW5naGFvLm5ldCIsImV4cCI6IjE0Mzg5NTU0NDUiLCJuYW1lIjoid2FuZ2hhbyIsImFkbWluIjp0cnVlfQ.SwyHTEx_RQppr97g4J5lKXtabJecpejuef8AqKYMAJc"
);
System
.
out
.
println
(
signed
);
}
}
}
single-matter/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthUserInterceptor.java
View file @
26b3c42c
...
@@ -9,7 +9,6 @@ import com.mortals.framework.util.AESUtil;
...
@@ -9,7 +9,6 @@ import com.mortals.framework.util.AESUtil;
import
com.mortals.framework.utils.ServletUtils
;
import
com.mortals.framework.utils.ServletUtils
;
import
com.mortals.framework.web.interceptor.BaseInterceptor
;
import
com.mortals.framework.web.interceptor.BaseInterceptor
;
import
com.mortals.xhx.base.framework.config.InterceptorConfig
;
import
com.mortals.xhx.base.framework.config.InterceptorConfig
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -43,8 +42,8 @@ public class AuthUserInterceptor extends BaseInterceptor {
...
@@ -43,8 +42,8 @@ public class AuthUserInterceptor extends BaseInterceptor {
@Override
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
throws
Exception
{
//response.setContentType("application/json"
);
JSONObject
ret
=
new
JSONObject
(
);
if
(
handler
instanceof
HandlerMethod
)
{
if
(
handler
instanceof
HandlerMethod
)
{
HandlerMethod
handlerMethod
=
(
HandlerMethod
)
handler
;
HandlerMethod
handlerMethod
=
(
HandlerMethod
)
handler
;
Method
method
=
handlerMethod
.
getMethod
();
Method
method
=
handlerMethod
.
getMethod
();
UnAuth
annotation
=
method
.
getAnnotation
(
UnAuth
.
class
);
UnAuth
annotation
=
method
.
getAnnotation
(
UnAuth
.
class
);
...
@@ -52,7 +51,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
...
@@ -52,7 +51,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
//取消校验
//取消校验
return
true
;
return
true
;
}
}
}
else
if
(
handler
instanceof
ResourceHttpRequestHandler
)
{
}
else
if
(
handler
instanceof
ResourceHttpRequestHandler
)
{
return
true
;
return
true
;
}
}
try
{
try
{
...
@@ -73,7 +72,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
...
@@ -73,7 +72,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
if
(
ObjectUtils
.
isEmpty
(
loginUser
))
{
if
(
ObjectUtils
.
isEmpty
(
loginUser
))
{
ServletUtils
.
renderString
(
response
,
JSONObject
.
toJSONString
(
Rest
.
fail
(
ERROR_TOKEN_EXPIRED
,
ERROR_TOKEN_EXPIRED_CONTENT
)));
ServletUtils
.
renderString
(
response
,
JSONObject
.
toJSONString
(
Rest
.
fail
(
ERROR_TOKEN_EXPIRED
,
ERROR_TOKEN_EXPIRED_CONTENT
)));
return
false
;
return
false
;
}
else
if
(
loginUser
.
isAdmin
()
||
loginUser
.
getUserType
()
==
1
||
loginUser
.
getUserType
()
==
2
)
{
}
else
if
(
loginUser
.
isAdmin
()
||
loginUser
.
getUserType
()
==
1
)
{
return
super
.
preHandle
(
request
,
response
,
handler
);
return
super
.
preHandle
(
request
,
response
,
handler
);
}
else
{
}
else
{
ServletUtils
.
renderString
(
response
,
JSONObject
.
toJSONString
(
Rest
.
fail
(
ERROR_USER_OPERATION
,
ERROR_USER_OPERATION_CONTENT
)));
ServletUtils
.
renderString
(
response
,
JSONObject
.
toJSONString
(
Rest
.
fail
(
ERROR_USER_OPERATION
,
ERROR_USER_OPERATION_CONTENT
)));
...
@@ -105,5 +104,4 @@ public class AuthUserInterceptor extends BaseInterceptor {
...
@@ -105,5 +104,4 @@ public class AuthUserInterceptor extends BaseInterceptor {
return
false
;
return
false
;
}
}
}
}
single-matter/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
View file @
26b3c42c
...
@@ -8,30 +8,14 @@
...
@@ -8,30 +8,14 @@
package
com.mortals.xhx.base.system.resource.service.impl
;
package
com.mortals.xhx.base.system.resource.service.impl
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.xhx.base.system.resource.dao.ResourceDao
;
import
com.mortals.xhx.base.system.resource.dao.ResourceDao
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.model.ResourceQuery
;
import
com.mortals.xhx.base.system.resource.model.ResourceQuery
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.SyncTreeSiteThread
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
...
...
single-matter/src/main/java/com/mortals/xhx/base/system/user/service/UserService.java
View file @
26b3c42c
...
@@ -10,6 +10,7 @@ package com.mortals.xhx.base.system.user.service;
...
@@ -10,6 +10,7 @@ package com.mortals.xhx.base.system.user.service;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.ICRUDCacheService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.xhx.base.system.menu.model.MenuEntity
;
import
com.mortals.xhx.base.system.menu.model.MenuEntity
;
...
@@ -29,7 +30,7 @@ import java.util.Set;
...
@@ -29,7 +30,7 @@ import java.util.Set;
* @version 1.0.0
* @version 1.0.0
*/
*/
public
interface
UserService
extends
ICRUDService
<
UserEntity
,
Long
>
{
public
interface
UserService
extends
ICRUD
Cache
Service
<
UserEntity
,
Long
>
{
/**
/**
* 用户登录
* 用户登录
*
*
...
...
single-matter/src/main/java/com/mortals/xhx/base/system/user/service/impl/UserServiceImpl.java
View file @
26b3c42c
...
@@ -15,11 +15,11 @@ import com.mortals.framework.model.Context;
...
@@ -15,11 +15,11 @@ import com.mortals.framework.model.Context;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.util.DataUtil
;
import
com.mortals.framework.util.DataUtil
;
import
com.mortals.framework.util.SecurityUtil
;
import
com.mortals.framework.util.SecurityUtil
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.xhx.base.system.menu.model.MenuEntity
;
import
com.mortals.xhx.base.system.menu.model.MenuEntity
;
import
com.mortals.xhx.base.system.menu.service.MenuService
;
import
com.mortals.xhx.base.system.menu.service.MenuService
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
...
@@ -32,12 +32,7 @@ import com.mortals.xhx.base.system.user.dao.UserDao;
...
@@ -32,12 +32,7 @@ import com.mortals.xhx.base.system.user.dao.UserDao;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.common.pdu.user.UserPhpPdu
;
import
com.mortals.xhx.common.pdu.user.UserPhpPdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.SyncTreeSiteThread
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -56,7 +51,7 @@ import java.util.stream.Collectors;
...
@@ -56,7 +51,7 @@ import java.util.stream.Collectors;
* @version 1.0.0
* @version 1.0.0
*/
*/
@Service
(
"userService"
)
@Service
(
"userService"
)
public
class
UserServiceImpl
extends
AbstractCRUDServiceImpl
<
UserDao
,
UserEntity
,
Long
>
implements
UserService
{
public
class
UserServiceImpl
extends
AbstractCRUD
Cache
ServiceImpl
<
UserDao
,
UserEntity
,
Long
>
implements
UserService
{
@Autowired
@Autowired
...
...
single-matter/src/main/java/com/mortals/xhx/common/key/RedisKey.java
View file @
26b3c42c
...
@@ -10,4 +10,5 @@ public class RedisKey {
...
@@ -10,4 +10,5 @@ public class RedisKey {
*/
*/
public
static
final
String
KEY_MENU_CACHE
=
"iot:base:MenuCacheKey:"
;
public
static
final
String
KEY_MENU_CACHE
=
"iot:base:MenuCacheKey:"
;
public
static
final
String
KEY_USER_MENU_CACHE
=
"user:menu"
;
}
}
single-matter/src/main/java/com/mortals/xhx/common/utils/MenuEncodeUtil.java
0 → 100644
View file @
26b3c42c
package
com.mortals.xhx.common.utils
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.ap.SysConstains
;
import
com.mortals.framework.util.AESUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Set
;
@Slf4j
public
class
MenuEncodeUtil
{
public
static
String
generateMenuUrlCode
(
Set
<
String
>
urls
)
{
try
{
String
securityKey
=
GlobalSysInfo
.
getPropertyValue
(
SysConstains
.
PROP_COOKIE_SECURITY_KEY
);
StringBuilder
sb
=
new
StringBuilder
();
if
(
urls
!=
null
&&
urls
.
size
()
>
0
)
{
for
(
String
url
:
urls
)
{
int
index
=
url
.
hashCode
()
&
(
Integer
.
MAX_VALUE
-
1
);
sb
.
append
(
index
).
append
(
","
);
}
}
String
menuUrl
=
sb
.
toString
();
return
AESUtil
.
encrypt
(
menuUrl
,
securityKey
);
}
catch
(
Throwable
e
)
{
log
.
error
(
"编码异常"
,
e
);
return
null
;
}
}
}
single-matter/src/main/java/com/mortals/xhx/common/utils/SyncTreeSiteThread.java
View file @
26b3c42c
package
com.mortals.xhx.common.utils
;
//
package com.mortals.xhx.common.utils;
//
import
com.alibaba.fastjson.JSON
;
//
import com.alibaba.fastjson.JSON;
import
com.mortals.framework.model.Context
;
//
import com.mortals.framework.model.Context;
import
com.mortals.xhx.module.site.model.SiteTreeSelect
;
//
import com.mortals.xhx.module.site.model.SiteTreeSelect;
import
com.mortals.xhx.module.site.service.SiteService
;
//
import com.mortals.xhx.module.site.service.SiteService;
import
com.mortals.xhx.utils.SpringUtils
;
//
import com.mortals.xhx.utils.SpringUtils;
import
lombok.AllArgsConstructor
;
//
import lombok.AllArgsConstructor;
import
lombok.extern.apachecommons.CommonsLog
;
//
import lombok.extern.apachecommons.CommonsLog;
import
lombok.extern.slf4j.Slf4j
;
//
import lombok.extern.slf4j.Slf4j;
import
org.springframework.util.ObjectUtils
;
//
import org.springframework.util.ObjectUtils;
//
import
java.util.List
;
//
import java.util.List;
//
/**
/
//
**
* @author: zxfei
//
* @author: zxfei
* @date: 2022/4/13 13:34
//
* @date: 2022/4/13 13:34
* @description:
//
* @description:
**/
//
**/
@AllArgsConstructor
//
@AllArgsConstructor
@Slf4j
//
@Slf4j
public
class
SyncTreeSiteThread
implements
Runnable
{
//
public class SyncTreeSiteThread implements Runnable {
//
private
Context
context
;
//
private Context context;
//
@Override
//
@Override
public
void
run
()
{
//
public void run() {
SiteService
siteService
=
SpringUtils
.
getBean
(
SiteService
.
class
);
//
SiteService siteService = SpringUtils.getBean(SiteService.class);
List
<
SiteTreeSelect
>
siteTreeSelects
=
siteService
.
siteTree
(
context
);
//
List<SiteTreeSelect> siteTreeSelects = siteService.siteTree(context);
siteService
.
setSiteTree
(
siteTreeSelects
,
context
);
//
siteService.setSiteTree(siteTreeSelects, context);
log
.
info
(
"刷新用户站点树=》userID:{} siteIds:{} siteTree:{}"
,
context
.
getUser
().
getId
(),
context
.
getUser
().
getSiteIds
(),
JSON
.
toJSONString
(
siteService
.
getSiteTree
(
context
)));
//
log.info("刷新用户站点树=》userID:{} siteIds:{} siteTree:{}",context.getUser().getId(),context.getUser().getSiteIds(), JSON.toJSONString(siteService.getSiteTree(context)));
}
//
}
//
}
//
}
single-matter/src/main/java/com/mortals/xhx/daemon/applicationservice/DemoStartedService.java
View file @
26b3c42c
package
com.mortals.xhx.daemon.applicationservice
;
//package com.mortals.xhx.daemon.applicationservice;
//
import
com.mortals.framework.model.Context
;
//import com.mortals.framework.model.Context;
import
com.mortals.framework.service.ICacheService
;
//import com.mortals.framework.springcloud.service.IApplicationStartedService;
import
com.mortals.framework.service.IUser
;
//import com.mortals.framework.util.ThreadPool;
import
com.mortals.framework.springcloud.config.web.BaseWebMvcConfigurer
;
//import com.mortals.xhx.base.system.user.model.UserEntity;
import
com.mortals.framework.util.ThreadPool
;
//import com.mortals.xhx.base.system.user.service.UserService;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
//import com.mortals.xhx.common.utils.SyncTreeSiteThread;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
//import lombok.extern.slf4j.Slf4j;
import
com.mortals.xhx.base.system.user.service.UserService
;
//import org.apache.commons.logging.Log;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
//import org.apache.commons.logging.LogFactory;
import
com.mortals.xhx.common.utils.BeanUtil
;
//import org.springframework.beans.factory.annotation.Autowired;
import
com.mortals.xhx.common.utils.SyncTreeSiteThread
;
//import org.springframework.stereotype.Component;
import
com.mortals.xhx.feign.user.IUserFeign
;
//@Component
import
com.mortals.xhx.module.site.model.SiteTreeSelect
;
//@Slf4j
import
com.mortals.xhx.module.site.service.SiteService
;
//public class DemoStartedService implements IApplicationStartedService {
import
lombok.extern.slf4j.Slf4j
;
//
import
org.apache.commons.logging.Log
;
// private static Log logger = LogFactory.getLog(DemoStartedService.class);
import
org.apache.commons.logging.LogFactory
;
//// @Autowired
import
org.springframework.beans.BeanUtils
;
//// private IUserFeign userFeign;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.stereotype.Component
;
import
com.mortals.framework.springcloud.service.IApplicationStartedService
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
@Component
@Slf4j
public
class
DemoStartedService
implements
IApplicationStartedService
{
private
static
Log
logger
=
LogFactory
.
getLog
(
DemoStartedService
.
class
);
// @Autowired
// @Autowired
// private IUserFeign userFeign;
// private UserService userService;
@Autowired
//
private
UserService
userService
;
// @Override
// public void start() {
@Override
// logger.info("开始服务..[初始化用户站点树]");
public
void
start
()
{
// UserEntity userEntity = new UserEntity();
logger
.
info
(
"开始服务..[初始化用户站点树]"
);
// userEntity.initAttrValue();
UserEntity
userEntity
=
new
UserEntity
();
// userEntity.setId(0L);
userEntity
.
initAttrValue
();
// Context contextTemp = new Context();
userEntity
.
setId
(
0L
);
// contextTemp.setUser(userEntity);
Context
contextTemp
=
new
Context
();
// SyncTreeSiteThread syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
contextTemp
.
setUser
(
userEntity
);
// ThreadPool.getInstance().execute(syncTreeSiteThread);
SyncTreeSiteThread
syncTreeSiteThread
=
new
SyncTreeSiteThread
(
contextTemp
);
//
ThreadPool
.
getInstance
().
execute
(
syncTreeSiteThread
);
// userEntity = new UserEntity();
// userEntity.initAttrValue();
userEntity
=
new
UserEntity
();
// userEntity.setId(1L);
userEntity
.
initAttrValue
();
// contextTemp = new Context();
userEntity
.
setId
(
1L
);
// contextTemp.setUser(userEntity);
contextTemp
=
new
Context
();
// syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
contextTemp
.
setUser
(
userEntity
);
// ThreadPool.getInstance().execute(syncTreeSiteThread);
syncTreeSiteThread
=
new
SyncTreeSiteThread
(
contextTemp
);
//
ThreadPool
.
getInstance
().
execute
(
syncTreeSiteThread
);
//
///* userService.find(new UserQuery()).forEach(user->{
// Context context = new Context();
/* userService.find(new UserQuery()).forEach(user->{
// context.setUser(user);
Context context = new Context();
// ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
context.setUser(user);
// });*/
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
//
});*/
///* if(ObjectUtils.isEmpty(userFeign)){
// logger.info("userFeign未加载,加载本地用户");
/* if(ObjectUtils.isEmpty(userFeign)){
// userService.find(new UserQuery()).forEach(user->{
logger.info("userFeign未加载,加载本地用户");
// Context context = new Context();
userService.find(new UserQuery()).forEach(user->{
// context.setUser(user);
Context context = new Context();
// ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
context.setUser(user);
// });
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
//
});
// return;
// }*/
return;
//
}*/
///* userFeign.list(new UserPdu()).getData().getData().stream().forEach(userPdu->{
// Context context = new Context();
/* userFeign.list(new UserPdu()).getData().getData().stream().forEach(userPdu->{
//
Context context = new Context();
// UserEntity entity = new UserEntity();
// entity.initAttrValue();
UserEntity entity = new UserEntity();
// BeanUtils.copyProperties(userPdu, entity, BeanUtil.getNullPropertyNames(userPdu));
entity.initAttrValue();
//
BeanUtils.copyProperties(userPdu, entity, BeanUtil.getNullPropertyNames(userPdu));
// context.setUser(entity);
// ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
context.setUser(entity);
// });*/
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
// }
});*/
//
}
// @Override
// public void stop() {
@Override
// logger.info("停止服务..");
public
void
stop
()
{
// }
logger
.
info
(
"停止服务.."
);
//
}
// @Override
// public int getOrder() {
@Override
// return 10;
public
int
getOrder
()
{
// }
return
10
;
//
}
//}
}
single-matter/src/main/java/com/mortals/xhx/daemon/task/MatterDatumConvertTaskImpl.java
View file @
26b3c42c
package
com.mortals.xhx.daemon.task
;
//
package com.mortals.xhx.daemon.task;
//
import
cn.hutool.core.io.FileUtil
;
//
import cn.hutool.core.io.FileUtil;
import
cn.hutool.core.util.RandomUtil
;
//
import cn.hutool.core.util.RandomUtil;
import
com.alibaba.fastjson.JSONObject
;
//
import com.alibaba.fastjson.JSONObject;
import
com.mortals.framework.exception.AppException
;
//
import com.mortals.framework.exception.AppException;
import
com.mortals.framework.model.PageInfo
;
//
import com.mortals.framework.model.PageInfo;
import
com.mortals.framework.model.Result
;
//
import com.mortals.framework.model.Result;
import
com.mortals.framework.service.ITask
;
//
import com.mortals.framework.service.ITask;
import
com.mortals.framework.service.ITaskExcuteService
;
//
import com.mortals.framework.service.ITaskExcuteService;
import
com.mortals.framework.util.HttpUtil
;
//
import com.mortals.framework.util.HttpUtil;
import
com.mortals.xhx.common.utils.HttpDownloadUtil
;
//
import com.mortals.xhx.common.utils.HttpDownloadUtil;
import
com.mortals.xhx.common.utils.StringUtils
;
//
import com.mortals.xhx.common.utils.StringUtils;
import
com.mortals.xhx.common.utils.WordUtil
;
//
import com.mortals.xhx.common.utils.WordUtil;
import
com.mortals.xhx.module.matter.model.MatterDatumEntity
;
//
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
import
com.mortals.xhx.module.matter.model.MatterDatumFileEntity
;
//
import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
import
com.mortals.xhx.module.matter.model.MatterDatumFileQuery
;
//
import com.mortals.xhx.module.matter.model.MatterDatumFileQuery;
import
com.mortals.xhx.module.matter.model.MatterDatumQuery
;
//
import com.mortals.xhx.module.matter.model.MatterDatumQuery;
import
com.mortals.xhx.module.matter.service.MatterDatumFileService
;
//
import com.mortals.xhx.module.matter.service.MatterDatumFileService;
import
com.mortals.xhx.module.matter.service.MatterDatumService
;
//
import com.mortals.xhx.module.matter.service.MatterDatumService;
import
com.mortals.xhx.module.site.model.SiteMatterEntity
;
//
import com.mortals.xhx.module.site.model.SiteMatterEntity;
import
com.mortals.xhx.module.site.model.SiteMatterQuery
;
//
import com.mortals.xhx.module.site.model.SiteMatterQuery;
import
com.mortals.xhx.module.site.service.SiteMatterService
;
//
import com.mortals.xhx.module.site.service.SiteMatterService;
import
lombok.extern.slf4j.Slf4j
;
//
import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
//
import org.apache.commons.collections4.CollectionUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
//
import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
//
import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
//
import org.springframework.stereotype.Service;
//
import
java.io.File
;
//
import java.io.File;
import
java.io.FileNotFoundException
;
//
import java.io.FileNotFoundException;
import
java.util.ArrayList
;
//
import java.util.ArrayList;
import
java.util.Date
;
//
import java.util.Date;
import
java.util.List
;
//
import java.util.List;
//
/**
/
//
**
* 事项材料附件本地转换
//
* 事项材料附件本地转换
*/
//
*/
@Slf4j
//
@Slf4j
@Service
(
"MatterDatumConvertTask"
)
//
@Service("MatterDatumConvertTask")
public
class
MatterDatumConvertTaskImpl
implements
ITaskExcuteService
{
//
public class MatterDatumConvertTaskImpl implements ITaskExcuteService {
//
@Autowired
//
@Autowired
private
SiteMatterService
siteMatterService
;
//
private SiteMatterService siteMatterService;
@Autowired
//
@Autowired
private
MatterDatumService
matterDatumService
;
//
private MatterDatumService matterDatumService;
@Autowired
//
@Autowired
private
MatterDatumFileService
matterDatumFileService
;
//
private MatterDatumFileService matterDatumFileService;
//
@Value
(
"${upload.path}"
)
//
@Value("${upload.path}")
private
String
filePath
;
//
private String filePath;
//
public
static
String
word
[]
=
{
"doc"
,
"dot"
,
"wps"
,
"wpt"
,
"docx"
,
"dotx"
,
"docm"
,
"dotm"
};
//
public static String word[] = {"doc", "dot", "wps", "wpt", "docx", "dotx", "docm", "dotm"};
public
static
String
imgs
[]
=
{
"jpg"
,
"png"
,
"jpeg"
,
"gif"
};
//
public static String imgs[] = {"jpg", "png", "jpeg", "gif"};
public
static
String
pdf
[]
=
{
"pdf"
};
//
public static String pdf[] = {"pdf"};
//
public
static
String
downLoadUrl
=
"http://www.sczwfw.gov.cn/jiq/interface/item/annex/encryptUrl?id="
;
//
public static String downLoadUrl = "http://www.sczwfw.gov.cn/jiq/interface/item/annex/encryptUrl?id=";
//
@Override
//
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
//
public void excuteTask(ITask task) throws AppException {
log
.
info
(
"事项材料处理..."
);
//
log.info("事项材料处理...");
SiteMatterQuery
siteMatterQuery
=
new
SiteMatterQuery
();
//
SiteMatterQuery siteMatterQuery = new SiteMatterQuery();
siteMatterQuery
.
setIsConvert
(
0
);
//
siteMatterQuery.setIsConvert(0);
PageInfo
pageInfo
=
new
PageInfo
();
//
PageInfo pageInfo = new PageInfo();
Result
<
SiteMatterEntity
>
resultList
=
siteMatterService
.
find
(
siteMatterQuery
,
pageInfo
,
null
);
//
Result<SiteMatterEntity> resultList = siteMatterService.find(siteMatterQuery,pageInfo,null);
List
<
SiteMatterEntity
>
siteMatterEntities
=
resultList
.
getList
();
//
List<SiteMatterEntity> siteMatterEntities = resultList.getList();
if
(
CollectionUtils
.
isNotEmpty
(
siteMatterEntities
)){
//
if(CollectionUtils.isNotEmpty(siteMatterEntities)){
List
<
Long
>
matterIds
=
new
ArrayList
<>();
//
List<Long> matterIds = new ArrayList<>();
for
(
SiteMatterEntity
siteMatterEntity:
siteMatterEntities
){
//
for(SiteMatterEntity siteMatterEntity:siteMatterEntities){
matterIds
.
add
(
siteMatterEntity
.
getMatterId
());
//
matterIds.add(siteMatterEntity.getMatterId());
}
//
}
MatterDatumQuery
matterDatumQuery
=
new
MatterDatumQuery
();
//
MatterDatumQuery matterDatumQuery = new MatterDatumQuery();
matterDatumQuery
.
setMatterIdList
(
matterIds
);
//
matterDatumQuery.setMatterIdList(matterIds);
List
<
MatterDatumEntity
>
matterDatumEntityList
=
matterDatumService
.
find
(
matterDatumQuery
);
//
List<MatterDatumEntity> matterDatumEntityList = matterDatumService.find(matterDatumQuery);
//
if
(
CollectionUtils
.
isNotEmpty
(
matterDatumEntityList
)){
//
if(CollectionUtils.isNotEmpty(matterDatumEntityList)){
List
<
Long
>
convertIdList
=
new
ArrayList
<>();
//
List<Long> convertIdList = new ArrayList<>();
List
<
Long
>
errorConvertIdList
=
new
ArrayList
<>();
//
List<Long> errorConvertIdList = new ArrayList<>();
for
(
MatterDatumEntity
datumEntity:
matterDatumEntityList
){
//
for(MatterDatumEntity datumEntity:matterDatumEntityList){
MatterDatumFileQuery
fileQuery
=
new
MatterDatumFileQuery
();
//
MatterDatumFileQuery fileQuery = new MatterDatumFileQuery();
fileQuery
.
setDatumId
(
datumEntity
.
getId
());
//
fileQuery.setDatumId(datumEntity.getId());
List
<
MatterDatumFileEntity
>
datumFileEntityList
=
matterDatumFileService
.
find
(
fileQuery
);
//
List<MatterDatumFileEntity> datumFileEntityList = matterDatumFileService.find(fileQuery);
if
(
CollectionUtils
.
isNotEmpty
(
datumFileEntityList
)){
//
if(CollectionUtils.isNotEmpty(datumFileEntityList)){
String
rootPath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
;
//
String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/";
String
prePath
=
"file/preview/"
;
//
String prePath = "file/preview/";
String
savePath
=
"file/uploadfile/"
;
//
String savePath = "file/uploadfile/";
for
(
MatterDatumFileEntity
datumFileEntity:
datumFileEntityList
){
//
for(MatterDatumFileEntity datumFileEntity:datumFileEntityList){
if
(
StringUtils
.
isEmpty
(
datumFileEntity
.
getFileUrl
())||
StringUtils
.
isNotEmpty
(
datumFileEntity
.
getLocalFileUrl
())){
//
if(StringUtils.isEmpty(datumFileEntity.getFileUrl())||StringUtils.isNotEmpty(datumFileEntity.getLocalFileUrl())){
continue
;
//
continue;
}
//
}
String
fileName
=
datumFileEntity
.
getFileName
();
//
String fileName = datumFileEntity.getFileName();
String
fileUrl
=
datumFileEntity
.
getFileUrl
();
//
String fileUrl = datumFileEntity.getFileUrl();
try
{
//
try {
String
[]
urlList
=
fileUrl
.
split
(
"'"
);
//
String[] urlList = fileUrl.split("'");
String
requestUrl
=
downLoadUrl
+
urlList
[
1
];
//
String requestUrl = downLoadUrl + urlList[1];
String
result
=
HttpUtil
.
doGet
(
requestUrl
,
null
);
//
String result = HttpUtil.doGet(requestUrl,null);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
//
JSONObject jsonObject = JSONObject.parseObject(result);
if
(
jsonObject
.
getString
(
"code"
).
equals
(
"0"
))
{
//
if(jsonObject.getString("code").equals("0")) {
String
downLoadFromUrl
=
jsonObject
.
getString
(
"data"
);
//
String downLoadFromUrl = jsonObject.getString("data");
HttpDownloadUtil
.
downLoadFromUrl
(
downLoadFromUrl
,
fileName
,
rootPath
+
savePath
);
//
HttpDownloadUtil.downLoadFromUrl(downLoadFromUrl, fileName, rootPath + savePath);
}
else
{
//
}else {
continue
;
//
continue;
}
//
}
MatterDatumFileEntity
update
=
new
MatterDatumFileEntity
();
//
MatterDatumFileEntity update = new MatterDatumFileEntity();
update
.
setId
(
datumFileEntity
.
getId
());
//
update.setId(datumFileEntity.getId());
update
.
setLocalFileUrl
(
savePath
+
fileName
);
//
update.setLocalFileUrl(savePath+fileName);
String
newName
=
genPreviewPath
(
rootPath
,
prePath
,
savePath
+
fileName
);
//
String newName = genPreviewPath(rootPath, prePath, savePath+fileName);
update
.
setPreviewUrl
(
prePath
+
newName
);
//
update.setPreviewUrl(prePath+newName);
update
.
setUpdateTime
(
new
Date
());
//
update.setUpdateTime(new Date());
matterDatumFileService
.
update
(
update
);
//
matterDatumFileService.update(update);
}
catch
(
Exception
e
){
//
}catch (Exception e){
log
.
error
(
"DatumId:"
+
datumFileEntity
.
getDatumId
()+
",文件下载失败..."
,
e
);
//
log.error("DatumId:"+datumFileEntity.getDatumId()+",文件下载失败...",e);
errorConvertIdList
.
add
(
datumEntity
.
getMatterId
());
//
errorConvertIdList.add(datumEntity.getMatterId());
}
//
}
}
//
}
convertIdList
.
add
(
datumEntity
.
getMatterId
());
//
convertIdList.add(datumEntity.getMatterId());
}
//
}
}
//
}
if
(
convertIdList
.
size
()>
0
){
//
if(convertIdList.size()>0){
SiteMatterQuery
matterQuery
=
new
SiteMatterQuery
();
//
SiteMatterQuery matterQuery = new SiteMatterQuery();
matterQuery
.
setMatterIdList
(
convertIdList
);
//
matterQuery.setMatterIdList(convertIdList);
List
<
SiteMatterEntity
>
matterEntities
=
siteMatterService
.
find
(
matterQuery
);
//
List<SiteMatterEntity> matterEntities = siteMatterService.find(matterQuery);
for
(
SiteMatterEntity
matterEntity:
matterEntities
){
//
for(SiteMatterEntity matterEntity:matterEntities){
SiteMatterEntity
updateEntity
=
new
SiteMatterEntity
();
//
SiteMatterEntity updateEntity = new SiteMatterEntity();
updateEntity
.
setId
(
matterEntity
.
getId
());
//
updateEntity.setId(matterEntity.getId());
updateEntity
.
setIsConvert
(
1
);
//
updateEntity.setIsConvert(1);
updateEntity
.
setUpdateTime
(
new
Date
());
//
updateEntity.setUpdateTime(new Date());
siteMatterService
.
update
(
updateEntity
);
//
siteMatterService.update(updateEntity);
log
.
info
(
"站点事项已更新,id:"
+
matterEntity
.
getId
());
//
log.info("站点事项已更新,id:"+matterEntity.getId());
}
//
}
}
//
}
if
(
errorConvertIdList
.
size
()>
0
){
//
if(errorConvertIdList.size()>0){
SiteMatterQuery
matterQuery
=
new
SiteMatterQuery
();
//
SiteMatterQuery matterQuery = new SiteMatterQuery();
matterQuery
.
setMatterIdList
(
errorConvertIdList
);
//
matterQuery.setMatterIdList(errorConvertIdList);
List
<
SiteMatterEntity
>
matterEntities
=
siteMatterService
.
find
(
matterQuery
);
//
List<SiteMatterEntity> matterEntities = siteMatterService.find(matterQuery);
for
(
SiteMatterEntity
matterEntity:
matterEntities
){
//
for(SiteMatterEntity matterEntity:matterEntities){
SiteMatterEntity
updateEntity
=
new
SiteMatterEntity
();
//
SiteMatterEntity updateEntity = new SiteMatterEntity();
updateEntity
.
setId
(
matterEntity
.
getId
());
//
updateEntity.setId(matterEntity.getId());
updateEntity
.
setIsConvert
(
2
);
//转换失败
//
updateEntity.setIsConvert(2); //转换失败
updateEntity
.
setUpdateTime
(
new
Date
());
//
updateEntity.setUpdateTime(new Date());
siteMatterService
.
update
(
updateEntity
);
//
siteMatterService.update(updateEntity);
log
.
info
(
"站点事项已更新,id:"
+
matterEntity
.
getId
());
//
log.info("站点事项已更新,id:"+matterEntity.getId());
}
//
}
}
//
}
}
//
}
//
}
//
}
log
.
info
(
"事项材料处理完成..."
);
//
log.info("事项材料处理完成...");
}
//
}
//
@Override
//
@Override
public
void
stopTask
(
ITask
task
)
throws
AppException
{
//
public void stopTask(ITask task) throws AppException {
//
}
//
}
//
private
String
genPreviewPath
(
String
rootPath
,
String
prePath
,
String
tempPath
)
{
//
private String genPreviewPath(String rootPath, String prePath, String tempPath) {
//生成样表预览图片
//
//生成样表预览图片
String
samplePath
=
rootPath
+
tempPath
;
//
String samplePath = rootPath + tempPath;
String
filePath
=
rootPath
+
prePath
;
//
String filePath = rootPath + prePath;
File
pathDir
=
new
File
(
filePath
);
//
File pathDir = new File(filePath);
if
(!
pathDir
.
exists
())
{
//
if (!pathDir.exists()) {
pathDir
.
mkdirs
();
//
pathDir.mkdirs();
}
//
}
String
newName
=
RandomUtil
.
randomNumbers
(
12
)
+
".jpg"
;
//
String newName = RandomUtil.randomNumbers(12) + ".jpg";
String
filePathAll
=
filePath
+
newName
;
//
String filePathAll = filePath + newName;
//判断文件类型是否为doc pdf jpg png 等
//
//判断文件类型是否为doc pdf jpg png 等
String
extName
=
FileUtil
.
getSuffix
(
samplePath
);
//
String extName = FileUtil.getSuffix(samplePath);
if
(
this
.
isExsitArry
(
extName
,
word
))
{
//
if (this.isExsitArry(extName, word)) {
WordUtil
.
convertWordToJPEG
(
samplePath
,
filePathAll
);
//
WordUtil.convertWordToJPEG(samplePath, filePathAll);
}
else
if
(
this
.
isExsitArry
(
extName
,
pdf
))
{
//
} else if (this.isExsitArry(extName, pdf)) {
WordUtil
.
pdfToImages
(
samplePath
,
filePathAll
);
//
WordUtil.pdfToImages(samplePath, filePathAll);
}
else
if
(
this
.
isExsitArry
(
extName
,
imgs
))
{
//
} else if (this.isExsitArry(extName, imgs)) {
try
{
//
try {
com
.
mortals
.
framework
.
util
.
FileUtil
.
copyFile
(
samplePath
,
filePathAll
);
//
com.mortals.framework.util.FileUtil.copyFile(samplePath, filePathAll);
}
catch
(
FileNotFoundException
e
)
{
//
} catch (FileNotFoundException e) {
throw
new
RuntimeException
(
e
);
//
throw new RuntimeException(e);
}
//
}
}
//
}
return
newName
;
//
return newName;
}
//
}
//
public
boolean
isExsitArry
(
String
chex
,
String
arry
[])
{
//
public boolean isExsitArry(String chex, String arry[]) {
for
(
String
ex
:
arry
)
{
//
for (String ex : arry) {
if
(
chex
.
equalsIgnoreCase
(
ex
))
{
//
if (chex.equalsIgnoreCase(ex)) {
return
true
;
//
return true;
}
//
}
}
//
}
return
false
;
//
return false;
}
//
}
//
public
static
void
main
(
String
[]
args
){
//
public static void main(String[] args){
try
{
//
try {
String
s
=
HttpUtil
.
doGet
(
"http://www.sczwfw.gov.cn/jiq/interface/item/annex/encryptUrl?id=5c05a70bb7fe494d8ca6e6a382470e34"
,
null
);
//
String s = HttpUtil.doGet("http://www.sczwfw.gov.cn/jiq/interface/item/annex/encryptUrl?id=5c05a70bb7fe494d8ca6e6a382470e34",null);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
s
);
//
JSONObject jsonObject = JSONObject.parseObject(s);
String
fileUrl
=
jsonObject
.
getString
(
"data"
);
//
String fileUrl = jsonObject.getString("data");
HttpDownloadUtil
.
downLoadFromUrl
(
fileUrl
,
"bbb.pdf"
,
"D:\\Download"
);
//
HttpDownloadUtil.downLoadFromUrl(fileUrl,"bbb.pdf","D:\\Download");
}
catch
(
Exception
e
){
//
}catch (Exception e){
//
}
//
}
//
}
//
}
}
//
}
single-matter/src/main/java/com/mortals/xhx/daemon/task/StatSiteDeptMatterTaskImpl.java
deleted
100644 → 0
View file @
47125fee
package
com.mortals.xhx.daemon.task
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.service.DeptService
;
import
com.mortals.xhx.module.matter.model.MatterEntity
;
import
com.mortals.xhx.module.matter.model.MatterQuery
;
import
com.mortals.xhx.module.matter.service.MatterService
;
import
com.mortals.xhx.module.matters.service.MattersService
;
import
com.mortals.xhx.module.site.model.SiteMatterQuery
;
import
com.mortals.xhx.module.site.service.SiteMatterService
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
/**
* 统计站点部门事项
*/
@Slf4j
@Service
(
"StatSiteDeptMatterTask"
)
public
class
StatSiteDeptMatterTaskImpl
implements
ITaskExcuteService
{
@Autowired
private
DeptService
deptService
;
@Autowired
private
MatterService
matterService
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
log
.
info
(
"开始同步事项列表!"
);
List
<
DeptEntity
>
deptEntities
=
deptService
.
find
(
new
DeptQuery
());
for
(
DeptEntity
deptEntity
:
deptEntities
)
{
int
total
=
matterService
.
count
(
new
MatterQuery
().
deptCode
(
deptEntity
.
getDeptNumber
()),
null
);
if
(
total
>
0
)
{
DeptEntity
deptQuery
=
new
DeptEntity
();
deptQuery
.
setTotal
(
total
);
deptQuery
.
setUpdateTime
(
new
Date
());
DeptEntity
condition
=
new
DeptEntity
();
condition
.
setId
(
deptEntity
.
getId
());
deptService
.
getDao
().
update
(
deptQuery
,
condition
);
// deptService.update(deptEntity, null);
}
}
}
@Override
public
void
stopTask
(
ITask
task
)
throws
AppException
{
}
}
single-matter/src/main/java/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
0 → 100644
View file @
26b3c42c
package
com.mortals.xhx.daemon.task
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 同步门户用户
*/
@Slf4j
@Service
(
"SyncPortalUserTask"
)
public
class
SyncPortalUserTaskImpl
implements
ITaskExcuteService
{
@Autowired
private
IUserFeign
userFeign
;
@Autowired
private
UserService
userService
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
try
{
log
.
info
(
"同步门户用户"
);
syncPersons
();
}
catch
(
Exception
e
)
{
log
.
error
(
"同步门户异常"
,
e
);
}
}
private
void
syncPersons
()
{
UserPdu
userPdu
=
new
UserPdu
();
userPdu
.
setPage
(
1
);
userPdu
.
setSize
(-
1
);
Rest
<
RespData
<
List
<
UserPdu
>>>
resp
=
userFeign
.
list
(
userPdu
);
if
(
resp
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
List
<
UserPdu
>
userPduList
=
resp
.
getData
().
getData
();
log
.
info
(
"用户总数量:{}"
,
userPduList
.
size
());
if
(!
ObjectUtils
.
isEmpty
(
userPduList
))
{
List
<
UserEntity
>
newUserList
=
userPduList
.
stream
().
map
(
newUser
->
{
UserEntity
userEntity
=
new
UserEntity
();
userEntity
.
initAttrValue
();
BeanUtils
.
copyProperties
(
newUser
,
userEntity
,
new
String
[]{
"id"
,
"lastLoginTime"
,
"lastLoginAddress"
});
return
userEntity
;
}).
collect
(
Collectors
.
toList
());
List
<
UserEntity
>
oldUserList
=
userService
.
find
(
new
UserQuery
());
log
.
info
(
" oldUserList size:{}"
,
oldUserList
.
size
());
//当前用户map
Map
<
String
,
UserEntity
>
oldUserMap
=
oldUserList
.
parallelStream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getLoginName
(),
y
->
y
,
(
o
,
n
)
->
n
));
//门户用户map
// Map<String, UserEntity> newUserMap = newUserList.stream().collect(Collectors.toMap(x -> x.getLoginName(), y -> y, (o, n) -> n));
List
<
UserEntity
>
saveUserList
=
newUserList
.
stream
().
map
(
item
->
{
if
(!
oldUserMap
.
containsKey
(
item
.
getLoginName
()))
{
item
.
setCreateUserId
(
1L
);
item
.
setCreateUserName
(
"系统管理员"
);
item
.
setCreateTime
(
new
Date
());
return
item
;
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
if
(!
ObjectUtils
.
isEmpty
(
saveUserList
))
{
log
.
info
(
"用户新增,size:{}"
,
saveUserList
.
size
());
saveUserList
.
stream
().
forEach
(
item
->
{
userService
.
getUserDao
().
insert
(
item
);
});
}
}
//查找新增 与更新
}
}
@Override
public
void
stopTask
(
ITask
task
)
throws
AppException
{
}
}
single-matter/src/main/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
View file @
26b3c42c
package
com.mortals.xhx.daemon.task
;
//
package com.mortals.xhx.daemon.task;
//
import
com.alibaba.fastjson.JSON
;
//
import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONArray
;
//
import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
//
import com.alibaba.fastjson.JSONObject;
import
com.mortals.framework.ap.GlobalSysInfo
;
//
import com.mortals.framework.ap.GlobalSysInfo;
import
com.mortals.framework.common.Rest
;
//
import com.mortals.framework.common.Rest;
import
com.mortals.framework.exception.AppException
;
//
import com.mortals.framework.exception.AppException;
import
com.mortals.framework.service.ITask
;
//
import com.mortals.framework.service.ITask;
import
com.mortals.framework.service.ITaskExcuteService
;
//
import com.mortals.framework.service.ITaskExcuteService;
import
com.mortals.framework.util.HttpUtil
;
//
import com.mortals.framework.util.HttpUtil;
import
com.mortals.xhx.base.system.user.service.UserService
;
//
import com.mortals.xhx.base.system.user.service.UserService;
import
com.mortals.xhx.common.pdu.user.UserPhpPdu
;
//
import com.mortals.xhx.common.pdu.user.UserPhpPdu;
import
com.mortals.xhx.module.apply.service.ApproverService
;
//
import com.mortals.xhx.module.apply.service.ApproverService;
import
lombok.extern.slf4j.Slf4j
;
//
import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
//
import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
//
import org.springframework.stereotype.Service;
//
import
java.util.HashMap
;
//
import java.util.HashMap;
import
java.util.List
;
//
import java.util.List;
//
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
PARAM_SERVER_PHP_HTTP_URL
;
//
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL;
//
/**
/
//
**
* 同步用户
//
* 同步用户
*/
//
*/
@Slf4j
//
@Slf4j
@Service
(
"SyncUserTask"
)
//
@Service("SyncUserTask")
public
class
SyncUserTaskImpl
implements
ITaskExcuteService
{
//
public class SyncUserTaskImpl implements ITaskExcuteService {
//
@Autowired
//
@Autowired
private
UserService
userService
;
//
private UserService userService;
@Autowired
//
@Autowired
private
ApproverService
approverService
;
//
private ApproverService approverService;
//
@Override
//
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
//
public void excuteTask(ITask task) throws AppException {
//
log
.
info
(
"同步用户"
);
//
log.info("同步用户");
String
phpUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_HTTP_URL
,
"http://172.15.28.116:8090"
);
//
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl
+=
"/doors/inter/user/userList"
;
//
phpUrl += "/doors/inter/user/userList";
String
resp
=
null
;
//
String resp = null;
try
{
//
try {
HashMap
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
//
HashMap<String, String> paramsMap = new HashMap<>();
resp
=
HttpUtil
.
doGet
(
phpUrl
,
paramsMap
);
//
resp = HttpUtil.doGet(phpUrl, paramsMap);
Rest
<
List
<
JSONObject
>>
list
=
JSON
.
parseObject
(
resp
,
Rest
.
class
);
//
Rest<List<JSONObject>> list = JSON.parseObject(resp,Rest.class);
List
<
UserPhpPdu
>
upp
=
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
list
.
getData
()),
UserPhpPdu
.
class
);
//
List<UserPhpPdu> upp = JSONArray.parseArray(JSONObject.toJSONString(list.getData()),UserPhpPdu.class);
userService
.
updateUserList
(
upp
);
//
userService.updateUserList(upp);
approverService
.
updateUserList
(
upp
);
//
approverService.updateUserList(upp);
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
log
.
error
(
"同步用户发生异常"
,
e
);
//
log.error("同步用户发生异常",e);
}
//
}
//
}
//
}
//
//
@Override
//
@Override
public
void
stopTask
(
ITask
task
)
throws
AppException
{
//
public void stopTask(ITask task) throws AppException {
//
}
//
}
//
//
}
//
}
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