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
;
import
com.mortals.framework.model.BaseEntityLong
;
import
java.util.Date
;
import
java.util.List
;
import
com.mortals.framework.model.BaseEntityLong
;
/**
* 用户信息业务Pdu对象
...
...
common-lib/src/main/java/com/mortals/xhx/feign/user/IUserFeign.java
View file @
26b3c42c
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.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
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -15,11 +15,10 @@ import java.util.List;
/**
* 用户信息业务 Feign接口
*
* @author zxfei
* @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
{
...
...
@@ -29,7 +28,7 @@ public interface IUserFeign extends IFeign {
* @param userPdu
* @return
*/
@PostMapping
(
value
=
"/user/list"
)
@PostMapping
(
value
=
"/user/
inter
list"
)
Rest
<
RespData
<
List
<
UserPdu
>>>
list
(
@RequestBody
UserPdu
userPdu
);
...
...
@@ -39,7 +38,7 @@ public interface IUserFeign extends IFeign {
* @param id
* @return
*/
@GetMapping
(
value
=
"/user/info"
)
@GetMapping
(
value
=
"/user/in
terin
fo"
)
Rest
<
UserPdu
>
info
(
@RequestParam
(
value
=
"id"
)
Long
id
);
/**
...
...
@@ -49,7 +48,7 @@ public interface IUserFeign extends IFeign {
* @return
*/
@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 {
* @return
*/
@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"
)
String
portalLogin
(
@RequestBody
UserPdu
userPdu
);
/**
* 查询用户列表
*
* @param userPdu
* @return
*/
@PostMapping
(
"/api/user/findAllUser"
)
String
findAllUser
(
@RequestBody
UserPdu
userPdu
);
/**
* 获取token
...
...
@@ -76,9 +84,6 @@ public interface IUserFeign extends IFeign {
Rest
<
String
>
getToken
(
@RequestParam
(
value
=
"userKey"
)
String
userKey
);
@PostMapping
(
value
=
"/user/synchSiteAuth"
)
Rest
<
String
>
synchSiteAuth
();
}
...
...
@@ -87,7 +92,6 @@ public interface IUserFeign extends IFeign {
class
UserFeignFallbackFactory
implements
FallbackFactory
<
IUserFeign
>
{
@Override
public
IUserFeign
create
(
Throwable
t
)
{
log
.
error
(
"feign error"
,
t
);
return
new
IUserFeign
()
{
@Override
public
Rest
<
RespData
<
List
<
UserPdu
>>>
list
(
UserPdu
userPdu
)
{
...
...
@@ -115,16 +119,14 @@ class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> {
}
@Override
public
Rest
<
String
>
getToken
(
String
userKey
)
{
return
Rest
.
fail
(
"token获取失败"
)
;
public
String
findAllUser
(
UserPdu
userPdu
)
{
return
null
;
}
@Override
public
Rest
<
String
>
synchSiteAuth
(
)
{
return
Rest
.
fail
(
"
同步请求失败,稍后再试!
"
);
public
Rest
<
String
>
getToken
(
String
userKey
)
{
return
Rest
.
fail
(
"
token获取失败
"
);
}
};
}
}
...
...
single-matter/pom.xml
View file @
26b3c42c
...
...
@@ -29,7 +29,7 @@
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<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.level>
INFO
</profiles.log.level>
<package.environment>
test
</package.environment>
...
...
@@ -38,14 +38,13 @@
</profile>
<profile>
<id>
test
</id>
<properties>
<profiles.active>
test
</profiles.active>
<profiles.server.path>
/sm
</profiles.server.path>
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<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.level>
INFO
</profiles.log.level>
<package.environment>
test
</package.environment>
...
...
@@ -62,7 +61,7 @@
<profiles.publish.path>
/home/publish
</profiles.publish.path>
<profiles.nacos.server-addr>
127.0.0.1:8848
</profiles.nacos.server-addr>
<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.level>
INFO
</profiles.log.level>
<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;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.util.DateUtils
;
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.UserQuery
;
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.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
...
...
@@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
import
java.util.Base64
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
/**
* token验证处理
...
...
@@ -33,7 +36,7 @@ import java.util.Map;
* @author zxfei
*/
@Primary
@Service
@Service
(
"authTokenService"
)
@Order
(
1
)
@Slf4j
public
class
AuthTokenServiceImpl
implements
IAuthTokenService
{
...
...
@@ -78,6 +81,10 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
@Autowired
private
ICacheService
cacheService
;
@Autowired
private
ResourceService
resourceService
;
/**
* 获取信息
*
...
...
@@ -90,28 +97,42 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
String
token
=
getToken
(
request
);
if
(
StringUtils
.
isNotEmpty
(
token
))
{
try
{
boolean
signed
=
Jwts
.
parser
().
isSigned
(
token
);
if
(!
signed
)
{
log
.
error
(
"token非法!=>{}"
,
token
);
return
null
;
}
Claims
claims
=
parseToken
(
token
);
String
uuid
=
(
String
)
claims
.
get
(
SysConstains
.
LOGIN_USER_KEY
);
String
userKey
=
getTokenKey
(
uuid
);
//cacheService.select(portalDb);
String
userStr
=
cacheService
.
get
(
userKey
);
//cacheService.select(db);
/* cacheService.select(portalDb);
String userStr = cacheService.get(userKey);*/
// Rest<String> rest = userFeign.getToken(userKey
);
// String userStr = rest.getData(
);
if
(
StringUtils
.
isNotEmpty
(
userStr
))
{
RedisTemplate
<
String
,
String
>
redisTemplate
=
cacheService
.
selectDbRedisTemplate
(
portalDb
);
String
userStr
=
redisTemplate
.
opsForValue
().
get
(
userKey
);
//刷新token时间
UserEntity
userEntity
=
JSONObject
.
parseObject
(
userStr
,
UserEntity
.
class
);
userEntity
.
setToken
(
token
);
UserEntity
temp
=
userService
.
selectOne
(
new
UserQuery
().
loginName
(
userEntity
.
getLoginName
()));
if
(!
ObjectUtils
.
isEmpty
(
temp
)){
if
(!
ObjectUtils
.
isEmpty
(
userEntity
))
{
verifyToken
(
userEntity
);
}
// cacheService.select(db);
if
(!
ObjectUtils
.
isEmpty
(
userEntity
))
{
UserEntity
temp
=
userService
.
getExtCache
(
userEntity
.
getLoginName
());
if
(!
ObjectUtils
.
isEmpty
(
temp
))
{
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
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"解析jwt token异常!
"
,
e
);
log
.
error
(
"解析jwt token异常!
,token:{}"
,
token
,
e
);
return
null
;
}
}
...
...
@@ -165,8 +186,8 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
public
void
verifyToken
(
IUser
user
)
{
long
expireTime
=
user
.
getExpireTime
();
long
currentTime
=
System
.
currentTimeMillis
();
if
(
expireTime
-
currentTime
<=
SECOND_MINUTE_TEN
)
{
log
.
info
(
"不足十分钟,刷新过期时间"
);
if
(
expireTime
-
currentTime
<=
SECOND_MINUTE_TEN
*
1000
)
{
log
.
info
(
"不足
二
十分钟,刷新过期时间"
);
refreshToken
(
user
);
}
}
...
...
@@ -178,7 +199,7 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
*/
public
void
refreshToken
(
IUser
user
)
{
//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缓存
String
userKey
=
getTokenKey
(
user
.
getToken
());
//设置有效时间 单位秒
...
...
@@ -245,4 +266,11 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
private
String
getTokenKey
(
String
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;
import
com.mortals.framework.utils.ServletUtils
;
import
com.mortals.framework.web.interceptor.BaseInterceptor
;
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.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -43,8 +42,8 @@ public class AuthUserInterceptor extends BaseInterceptor {
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
//response.setContentType("application/json"
);
if
(
handler
instanceof
HandlerMethod
)
{
JSONObject
ret
=
new
JSONObject
(
);
if
(
handler
instanceof
HandlerMethod
)
{
HandlerMethod
handlerMethod
=
(
HandlerMethod
)
handler
;
Method
method
=
handlerMethod
.
getMethod
();
UnAuth
annotation
=
method
.
getAnnotation
(
UnAuth
.
class
);
...
...
@@ -52,7 +51,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
//取消校验
return
true
;
}
}
else
if
(
handler
instanceof
ResourceHttpRequestHandler
)
{
}
else
if
(
handler
instanceof
ResourceHttpRequestHandler
)
{
return
true
;
}
try
{
...
...
@@ -73,7 +72,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
if
(
ObjectUtils
.
isEmpty
(
loginUser
))
{
ServletUtils
.
renderString
(
response
,
JSONObject
.
toJSONString
(
Rest
.
fail
(
ERROR_TOKEN_EXPIRED
,
ERROR_TOKEN_EXPIRED_CONTENT
)));
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
);
}
else
{
ServletUtils
.
renderString
(
response
,
JSONObject
.
toJSONString
(
Rest
.
fail
(
ERROR_USER_OPERATION
,
ERROR_USER_OPERATION_CONTENT
)));
...
...
@@ -105,5 +104,4 @@ public class AuthUserInterceptor extends BaseInterceptor {
return
false
;
}
}
single-matter/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
View file @
26b3c42c
...
...
@@ -8,30 +8,14 @@
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.model.Context
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
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.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.model.ResourceQuery
;
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.util.ObjectUtils
;
import
java.util.HashSet
;
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;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.ICRUDCacheService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.xhx.base.system.menu.model.MenuEntity
;
...
...
@@ -29,7 +30,7 @@ import java.util.Set;
* @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;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.util.DataUtil
;
import
com.mortals.framework.util.SecurityUtil
;
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.service.MenuService
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
...
...
@@ -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.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
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.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -56,7 +51,7 @@ import java.util.stream.Collectors;
* @version 1.0.0
*/
@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
...
...
single-matter/src/main/java/com/mortals/xhx/common/key/RedisKey.java
View file @
26b3c42c
...
...
@@ -10,4 +10,5 @@ public class RedisKey {
*/
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
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.model.Context
;
import
com.mortals.xhx.module.site.model.SiteTreeSelect
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.utils.SpringUtils
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.apachecommons.CommonsLog
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
/**
* @author: zxfei
* @date: 2022/4/13 13:34
* @description:
**/
@AllArgsConstructor
@Slf4j
public
class
SyncTreeSiteThread
implements
Runnable
{
private
Context
context
;
@Override
public
void
run
()
{
SiteService
siteService
=
SpringUtils
.
getBean
(
SiteService
.
class
);
List
<
SiteTreeSelect
>
siteTreeSelects
=
siteService
.
siteTree
(
context
);
siteService
.
setSiteTree
(
siteTreeSelects
,
context
);
log
.
info
(
"刷新用户站点树=》userID:{} siteIds:{} siteTree:{}"
,
context
.
getUser
().
getId
(),
context
.
getUser
().
getSiteIds
(),
JSON
.
toJSONString
(
siteService
.
getSiteTree
(
context
)));
}
}
//
package com.mortals.xhx.common.utils;
//
//
import com.alibaba.fastjson.JSON;
//
import com.mortals.framework.model.Context;
//
import com.mortals.xhx.module.site.model.SiteTreeSelect;
//
import com.mortals.xhx.module.site.service.SiteService;
//
import com.mortals.xhx.utils.SpringUtils;
//
import lombok.AllArgsConstructor;
//
import lombok.extern.apachecommons.CommonsLog;
//
import lombok.extern.slf4j.Slf4j;
//
import org.springframework.util.ObjectUtils;
//
//
import java.util.List;
//
/
//
**
//
* @author: zxfei
//
* @date: 2022/4/13 13:34
//
* @description:
//
**/
//
@AllArgsConstructor
//
@Slf4j
//
public class SyncTreeSiteThread implements Runnable {
//
//
private Context context;
//
//
@Override
//
public void run() {
//
SiteService siteService = SpringUtils.getBean(SiteService.class);
//
List<SiteTreeSelect> siteTreeSelects = siteService.siteTree(context);
//
siteService.setSiteTree(siteTreeSelects, 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
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.springcloud.config.web.BaseWebMvcConfigurer
;
import
com.mortals.framework.util.ThreadPool
;
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.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.model.SiteTreeSelect
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.BeanUtils
;
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
);
//package com.mortals.xhx.daemon.applicationservice;
//
//import com.mortals.framework.model.Context;
//import com.mortals.framework.springcloud.service.IApplicationStartedService;
//import com.mortals.framework.util.ThreadPool;
//import com.mortals.xhx.base.system.user.model.UserEntity;
//import com.mortals.xhx.base.system.user.service.UserService;
//import com.mortals.xhx.common.utils.SyncTreeSiteThread;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//@Component
//@Slf4j
//public class DemoStartedService implements IApplicationStartedService {
//
// private static Log logger = LogFactory.getLog(DemoStartedService.class);
//// @Autowired
//// private IUserFeign userFeign;
// @Autowired
// private IUserFeign userFeign;
@Autowired
private
UserService
userService
;
@Override
public
void
start
()
{
logger
.
info
(
"开始服务..[初始化用户站点树]"
);
UserEntity
userEntity
=
new
UserEntity
();
userEntity
.
initAttrValue
();
userEntity
.
setId
(
0L
);
Context
contextTemp
=
new
Context
();
contextTemp
.
setUser
(
userEntity
);
SyncTreeSiteThread
syncTreeSiteThread
=
new
SyncTreeSiteThread
(
contextTemp
);
ThreadPool
.
getInstance
().
execute
(
syncTreeSiteThread
);
userEntity
=
new
UserEntity
();
userEntity
.
initAttrValue
();
userEntity
.
setId
(
1L
);
contextTemp
=
new
Context
();
contextTemp
.
setUser
(
userEntity
);
syncTreeSiteThread
=
new
SyncTreeSiteThread
(
contextTemp
);
ThreadPool
.
getInstance
().
execute
(
syncTreeSiteThread
);
/* userService.find(new UserQuery()).forEach(user->{
Context context = new Context();
context.setUser(user);
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
});*/
/* if(ObjectUtils.isEmpty(userFeign)){
logger.info("userFeign未加载,加载本地用户");
userService.find(new UserQuery()).forEach(user->{
Context context = new Context();
context.setUser(user);
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
});
return;
}*/
/* userFeign.list(new UserPdu()).getData().getData().stream().forEach(userPdu->{
Context context = new Context();
UserEntity entity = new UserEntity();
entity.initAttrValue();
BeanUtils.copyProperties(userPdu, entity, BeanUtil.getNullPropertyNames(userPdu));
context.setUser(entity);
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
});*/
}
@Override
public
void
stop
()
{
logger
.
info
(
"停止服务.."
);
}
@Override
public
int
getOrder
()
{
return
10
;
}
}
// private UserService userService;
//
// @Override
// public void start() {
// logger.info("开始服务..[初始化用户站点树]");
// UserEntity userEntity = new UserEntity();
// userEntity.initAttrValue();
// userEntity.setId(0L);
// Context contextTemp = new Context();
// contextTemp.setUser(userEntity);
// SyncTreeSiteThread syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
// ThreadPool.getInstance().execute(syncTreeSiteThread);
//
// userEntity = new UserEntity();
// userEntity.initAttrValue();
// userEntity.setId(1L);
// contextTemp = new Context();
// contextTemp.setUser(userEntity);
// syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
// ThreadPool.getInstance().execute(syncTreeSiteThread);
//
//
///* userService.find(new UserQuery()).forEach(user->{
// Context context = new Context();
// context.setUser(user);
// ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
// });*/
//
///* if(ObjectUtils.isEmpty(userFeign)){
// logger.info("userFeign未加载,加载本地用户");
// userService.find(new UserQuery()).forEach(user->{
// Context context = new Context();
// context.setUser(user);
// ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
// });
//
// return;
// }*/
//
///* userFeign.list(new UserPdu()).getData().getData().stream().forEach(userPdu->{
// Context context = new Context();
//
// UserEntity entity = new UserEntity();
// entity.initAttrValue();
// BeanUtils.copyProperties(userPdu, entity, BeanUtil.getNullPropertyNames(userPdu));
//
// context.setUser(entity);
// ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
// });*/
// }
//
// @Override
// public void stop() {
// logger.info("停止服务..");
// }
//
// @Override
// 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
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.util.HttpUtil
;
import
com.mortals.xhx.common.utils.HttpDownloadUtil
;
import
com.mortals.xhx.common.utils.StringUtils
;
import
com.mortals.xhx.common.utils.WordUtil
;
import
com.mortals.xhx.module.matter.model.MatterDatumEntity
;
import
com.mortals.xhx.module.matter.model.MatterDatumFileEntity
;
import
com.mortals.xhx.module.matter.model.MatterDatumFileQuery
;
import
com.mortals.xhx.module.matter.model.MatterDatumQuery
;
import
com.mortals.xhx.module.matter.service.MatterDatumFileService
;
import
com.mortals.xhx.module.matter.service.MatterDatumService
;
import
com.mortals.xhx.module.site.model.SiteMatterEntity
;
import
com.mortals.xhx.module.site.model.SiteMatterQuery
;
import
com.mortals.xhx.module.site.service.SiteMatterService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* 事项材料附件本地转换
*/
@Slf4j
@Service
(
"MatterDatumConvertTask"
)
public
class
MatterDatumConvertTaskImpl
implements
ITaskExcuteService
{
@Autowired
private
SiteMatterService
siteMatterService
;
@Autowired
private
MatterDatumService
matterDatumService
;
@Autowired
private
MatterDatumFileService
matterDatumFileService
;
@Value
(
"${upload.path}"
)
private
String
filePath
;
public
static
String
word
[]
=
{
"doc"
,
"dot"
,
"wps"
,
"wpt"
,
"docx"
,
"dotx"
,
"docm"
,
"dotm"
};
public
static
String
imgs
[]
=
{
"jpg"
,
"png"
,
"jpeg"
,
"gif"
};
public
static
String
pdf
[]
=
{
"pdf"
};
public
static
String
downLoadUrl
=
"http://www.sczwfw.gov.cn/jiq/interface/item/annex/encryptUrl?id="
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
log
.
info
(
"事项材料处理..."
);
SiteMatterQuery
siteMatterQuery
=
new
SiteMatterQuery
();
siteMatterQuery
.
setIsConvert
(
0
);
PageInfo
pageInfo
=
new
PageInfo
();
Result
<
SiteMatterEntity
>
resultList
=
siteMatterService
.
find
(
siteMatterQuery
,
pageInfo
,
null
);
List
<
SiteMatterEntity
>
siteMatterEntities
=
resultList
.
getList
();
if
(
CollectionUtils
.
isNotEmpty
(
siteMatterEntities
)){
List
<
Long
>
matterIds
=
new
ArrayList
<>();
for
(
SiteMatterEntity
siteMatterEntity:
siteMatterEntities
){
matterIds
.
add
(
siteMatterEntity
.
getMatterId
());
}
MatterDatumQuery
matterDatumQuery
=
new
MatterDatumQuery
();
matterDatumQuery
.
setMatterIdList
(
matterIds
);
List
<
MatterDatumEntity
>
matterDatumEntityList
=
matterDatumService
.
find
(
matterDatumQuery
);
if
(
CollectionUtils
.
isNotEmpty
(
matterDatumEntityList
)){
List
<
Long
>
convertIdList
=
new
ArrayList
<>();
List
<
Long
>
errorConvertIdList
=
new
ArrayList
<>();
for
(
MatterDatumEntity
datumEntity:
matterDatumEntityList
){
MatterDatumFileQuery
fileQuery
=
new
MatterDatumFileQuery
();
fileQuery
.
setDatumId
(
datumEntity
.
getId
());
List
<
MatterDatumFileEntity
>
datumFileEntityList
=
matterDatumFileService
.
find
(
fileQuery
);
if
(
CollectionUtils
.
isNotEmpty
(
datumFileEntityList
)){
String
rootPath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
;
String
prePath
=
"file/preview/"
;
String
savePath
=
"file/uploadfile/"
;
for
(
MatterDatumFileEntity
datumFileEntity:
datumFileEntityList
){
if
(
StringUtils
.
isEmpty
(
datumFileEntity
.
getFileUrl
())||
StringUtils
.
isNotEmpty
(
datumFileEntity
.
getLocalFileUrl
())){
continue
;
}
String
fileName
=
datumFileEntity
.
getFileName
();
String
fileUrl
=
datumFileEntity
.
getFileUrl
();
try
{
String
[]
urlList
=
fileUrl
.
split
(
"'"
);
String
requestUrl
=
downLoadUrl
+
urlList
[
1
];
String
result
=
HttpUtil
.
doGet
(
requestUrl
,
null
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
if
(
jsonObject
.
getString
(
"code"
).
equals
(
"0"
))
{
String
downLoadFromUrl
=
jsonObject
.
getString
(
"data"
);
HttpDownloadUtil
.
downLoadFromUrl
(
downLoadFromUrl
,
fileName
,
rootPath
+
savePath
);
}
else
{
continue
;
}
MatterDatumFileEntity
update
=
new
MatterDatumFileEntity
();
update
.
setId
(
datumFileEntity
.
getId
());
update
.
setLocalFileUrl
(
savePath
+
fileName
);
String
newName
=
genPreviewPath
(
rootPath
,
prePath
,
savePath
+
fileName
);
update
.
setPreviewUrl
(
prePath
+
newName
);
update
.
setUpdateTime
(
new
Date
());
matterDatumFileService
.
update
(
update
);
}
catch
(
Exception
e
){
log
.
error
(
"DatumId:"
+
datumFileEntity
.
getDatumId
()+
",文件下载失败..."
,
e
);
errorConvertIdList
.
add
(
datumEntity
.
getMatterId
());
}
}
convertIdList
.
add
(
datumEntity
.
getMatterId
());
}
}
if
(
convertIdList
.
size
()>
0
){
SiteMatterQuery
matterQuery
=
new
SiteMatterQuery
();
matterQuery
.
setMatterIdList
(
convertIdList
);
List
<
SiteMatterEntity
>
matterEntities
=
siteMatterService
.
find
(
matterQuery
);
for
(
SiteMatterEntity
matterEntity:
matterEntities
){
SiteMatterEntity
updateEntity
=
new
SiteMatterEntity
();
updateEntity
.
setId
(
matterEntity
.
getId
());
updateEntity
.
setIsConvert
(
1
);
updateEntity
.
setUpdateTime
(
new
Date
());
siteMatterService
.
update
(
updateEntity
);
log
.
info
(
"站点事项已更新,id:"
+
matterEntity
.
getId
());
}
}
if
(
errorConvertIdList
.
size
()>
0
){
SiteMatterQuery
matterQuery
=
new
SiteMatterQuery
();
matterQuery
.
setMatterIdList
(
errorConvertIdList
);
List
<
SiteMatterEntity
>
matterEntities
=
siteMatterService
.
find
(
matterQuery
);
for
(
SiteMatterEntity
matterEntity:
matterEntities
){
SiteMatterEntity
updateEntity
=
new
SiteMatterEntity
();
updateEntity
.
setId
(
matterEntity
.
getId
());
updateEntity
.
setIsConvert
(
2
);
//转换失败
updateEntity
.
setUpdateTime
(
new
Date
());
siteMatterService
.
update
(
updateEntity
);
log
.
info
(
"站点事项已更新,id:"
+
matterEntity
.
getId
());
}
}
}
}
log
.
info
(
"事项材料处理完成..."
);
}
@Override
public
void
stopTask
(
ITask
task
)
throws
AppException
{
}
private
String
genPreviewPath
(
String
rootPath
,
String
prePath
,
String
tempPath
)
{
//生成样表预览图片
String
samplePath
=
rootPath
+
tempPath
;
String
filePath
=
rootPath
+
prePath
;
File
pathDir
=
new
File
(
filePath
);
if
(!
pathDir
.
exists
())
{
pathDir
.
mkdirs
();
}
String
newName
=
RandomUtil
.
randomNumbers
(
12
)
+
".jpg"
;
String
filePathAll
=
filePath
+
newName
;
//判断文件类型是否为doc pdf jpg png 等
String
extName
=
FileUtil
.
getSuffix
(
samplePath
);
if
(
this
.
isExsitArry
(
extName
,
word
))
{
WordUtil
.
convertWordToJPEG
(
samplePath
,
filePathAll
);
}
else
if
(
this
.
isExsitArry
(
extName
,
pdf
))
{
WordUtil
.
pdfToImages
(
samplePath
,
filePathAll
);
}
else
if
(
this
.
isExsitArry
(
extName
,
imgs
))
{
try
{
com
.
mortals
.
framework
.
util
.
FileUtil
.
copyFile
(
samplePath
,
filePathAll
);
}
catch
(
FileNotFoundException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
return
newName
;
}
public
boolean
isExsitArry
(
String
chex
,
String
arry
[])
{
for
(
String
ex
:
arry
)
{
if
(
chex
.
equalsIgnoreCase
(
ex
))
{
return
true
;
}
}
return
false
;
}
public
static
void
main
(
String
[]
args
){
try
{
String
s
=
HttpUtil
.
doGet
(
"http://www.sczwfw.gov.cn/jiq/interface/item/annex/encryptUrl?id=5c05a70bb7fe494d8ca6e6a382470e34"
,
null
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
s
);
String
fileUrl
=
jsonObject
.
getString
(
"data"
);
HttpDownloadUtil
.
downLoadFromUrl
(
fileUrl
,
"bbb.pdf"
,
"D:\\Download"
);
}
catch
(
Exception
e
){
}
}
}
//
package com.mortals.xhx.daemon.task;
//
//
import cn.hutool.core.io.FileUtil;
//
import cn.hutool.core.util.RandomUtil;
//
import com.alibaba.fastjson.JSONObject;
//
import com.mortals.framework.exception.AppException;
//
import com.mortals.framework.model.PageInfo;
//
import com.mortals.framework.model.Result;
//
import com.mortals.framework.service.ITask;
//
import com.mortals.framework.service.ITaskExcuteService;
//
import com.mortals.framework.util.HttpUtil;
//
import com.mortals.xhx.common.utils.HttpDownloadUtil;
//
import com.mortals.xhx.common.utils.StringUtils;
//
import com.mortals.xhx.common.utils.WordUtil;
//
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
//
import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
//
import com.mortals.xhx.module.matter.model.MatterDatumFileQuery;
//
import com.mortals.xhx.module.matter.model.MatterDatumQuery;
//
import com.mortals.xhx.module.matter.service.MatterDatumFileService;
//
import com.mortals.xhx.module.matter.service.MatterDatumService;
//
import com.mortals.xhx.module.site.model.SiteMatterEntity;
//
import com.mortals.xhx.module.site.model.SiteMatterQuery;
//
import com.mortals.xhx.module.site.service.SiteMatterService;
//
import lombok.extern.slf4j.Slf4j;
//
import org.apache.commons.collections4.CollectionUtils;
//
import org.springframework.beans.factory.annotation.Autowired;
//
import org.springframework.beans.factory.annotation.Value;
//
import org.springframework.stereotype.Service;
//
//
import java.io.File;
//
import java.io.FileNotFoundException;
//
import java.util.ArrayList;
//
import java.util.Date;
//
import java.util.List;
//
/
//
**
//
* 事项材料附件本地转换
//
*/
//
@Slf4j
//
@Service("MatterDatumConvertTask")
//
public class MatterDatumConvertTaskImpl implements ITaskExcuteService {
//
//
@Autowired
//
private SiteMatterService siteMatterService;
//
@Autowired
//
private MatterDatumService matterDatumService;
//
@Autowired
//
private MatterDatumFileService matterDatumFileService;
//
//
@Value("${upload.path}")
//
private String filePath;
//
//
public static String word[] = {"doc", "dot", "wps", "wpt", "docx", "dotx", "docm", "dotm"};
//
public static String imgs[] = {"jpg", "png", "jpeg", "gif"};
//
public static String pdf[] = {"pdf"};
//
//
public static String downLoadUrl = "http://www.sczwfw.gov.cn/jiq/interface/item/annex/encryptUrl?id=";
//
//
@Override
//
public void excuteTask(ITask task) throws AppException {
//
log.info("事项材料处理...");
//
SiteMatterQuery siteMatterQuery = new SiteMatterQuery();
//
siteMatterQuery.setIsConvert(0);
//
PageInfo pageInfo = new PageInfo();
//
Result<SiteMatterEntity> resultList = siteMatterService.find(siteMatterQuery,pageInfo,null);
//
List<SiteMatterEntity> siteMatterEntities = resultList.getList();
//
if(CollectionUtils.isNotEmpty(siteMatterEntities)){
//
List<Long> matterIds = new ArrayList<>();
//
for(SiteMatterEntity siteMatterEntity:siteMatterEntities){
//
matterIds.add(siteMatterEntity.getMatterId());
//
}
//
MatterDatumQuery matterDatumQuery = new MatterDatumQuery();
//
matterDatumQuery.setMatterIdList(matterIds);
//
List<MatterDatumEntity> matterDatumEntityList = matterDatumService.find(matterDatumQuery);
//
//
if(CollectionUtils.isNotEmpty(matterDatumEntityList)){
//
List<Long> convertIdList = new ArrayList<>();
//
List<Long> errorConvertIdList = new ArrayList<>();
//
for(MatterDatumEntity datumEntity:matterDatumEntityList){
//
MatterDatumFileQuery fileQuery = new MatterDatumFileQuery();
//
fileQuery.setDatumId(datumEntity.getId());
//
List<MatterDatumFileEntity> datumFileEntityList = matterDatumFileService.find(fileQuery);
//
if(CollectionUtils.isNotEmpty(datumFileEntityList)){
//
String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/";
//
String prePath = "file/preview/";
//
String savePath = "file/uploadfile/";
//
for(MatterDatumFileEntity datumFileEntity:datumFileEntityList){
//
if(StringUtils.isEmpty(datumFileEntity.getFileUrl())||StringUtils.isNotEmpty(datumFileEntity.getLocalFileUrl())){
//
continue;
//
}
//
String fileName = datumFileEntity.getFileName();
//
String fileUrl = datumFileEntity.getFileUrl();
//
try {
//
String[] urlList = fileUrl.split("'");
//
String requestUrl = downLoadUrl + urlList[1];
//
String result = HttpUtil.doGet(requestUrl,null);
//
JSONObject jsonObject = JSONObject.parseObject(result);
//
if(jsonObject.getString("code").equals("0")) {
//
String downLoadFromUrl = jsonObject.getString("data");
//
HttpDownloadUtil.downLoadFromUrl(downLoadFromUrl, fileName, rootPath + savePath);
//
}else {
//
continue;
//
}
//
MatterDatumFileEntity update = new MatterDatumFileEntity();
//
update.setId(datumFileEntity.getId());
//
update.setLocalFileUrl(savePath+fileName);
//
String newName = genPreviewPath(rootPath, prePath, savePath+fileName);
//
update.setPreviewUrl(prePath+newName);
//
update.setUpdateTime(new Date());
//
matterDatumFileService.update(update);
//
}catch (Exception e){
//
log.error("DatumId:"+datumFileEntity.getDatumId()+",文件下载失败...",e);
//
errorConvertIdList.add(datumEntity.getMatterId());
//
}
//
}
//
convertIdList.add(datumEntity.getMatterId());
//
}
//
}
//
if(convertIdList.size()>0){
//
SiteMatterQuery matterQuery = new SiteMatterQuery();
//
matterQuery.setMatterIdList(convertIdList);
//
List<SiteMatterEntity> matterEntities = siteMatterService.find(matterQuery);
//
for(SiteMatterEntity matterEntity:matterEntities){
//
SiteMatterEntity updateEntity = new SiteMatterEntity();
//
updateEntity.setId(matterEntity.getId());
//
updateEntity.setIsConvert(1);
//
updateEntity.setUpdateTime(new Date());
//
siteMatterService.update(updateEntity);
//
log.info("站点事项已更新,id:"+matterEntity.getId());
//
}
//
}
//
if(errorConvertIdList.size()>0){
//
SiteMatterQuery matterQuery = new SiteMatterQuery();
//
matterQuery.setMatterIdList(errorConvertIdList);
//
List<SiteMatterEntity> matterEntities = siteMatterService.find(matterQuery);
//
for(SiteMatterEntity matterEntity:matterEntities){
//
SiteMatterEntity updateEntity = new SiteMatterEntity();
//
updateEntity.setId(matterEntity.getId());
//
updateEntity.setIsConvert(2); //转换失败
//
updateEntity.setUpdateTime(new Date());
//
siteMatterService.update(updateEntity);
//
log.info("站点事项已更新,id:"+matterEntity.getId());
//
}
//
}
//
}
//
//
}
//
log.info("事项材料处理完成...");
//
}
//
//
@Override
//
public void stopTask(ITask task) throws AppException {
//
//
}
//
//
private String genPreviewPath(String rootPath, String prePath, String tempPath) {
//
//生成样表预览图片
//
String samplePath = rootPath + tempPath;
//
String filePath = rootPath + prePath;
//
File pathDir = new File(filePath);
//
if (!pathDir.exists()) {
//
pathDir.mkdirs();
//
}
//
String newName = RandomUtil.randomNumbers(12) + ".jpg";
//
String filePathAll = filePath + newName;
//
//判断文件类型是否为doc pdf jpg png 等
//
String extName = FileUtil.getSuffix(samplePath);
//
if (this.isExsitArry(extName, word)) {
//
WordUtil.convertWordToJPEG(samplePath, filePathAll);
//
} else if (this.isExsitArry(extName, pdf)) {
//
WordUtil.pdfToImages(samplePath, filePathAll);
//
} else if (this.isExsitArry(extName, imgs)) {
//
try {
//
com.mortals.framework.util.FileUtil.copyFile(samplePath, filePathAll);
//
} catch (FileNotFoundException e) {
//
throw new RuntimeException(e);
//
}
//
}
//
return newName;
//
}
//
//
public boolean isExsitArry(String chex, String arry[]) {
//
for (String ex : arry) {
//
if (chex.equalsIgnoreCase(ex)) {
//
return true;
//
}
//
}
//
return false;
//
}
//
//
public static void main(String[] args){
//
try {
//
String s = HttpUtil.doGet("http://www.sczwfw.gov.cn/jiq/interface/item/annex/encryptUrl?id=5c05a70bb7fe494d8ca6e6a382470e34",null);
//
JSONObject jsonObject = JSONObject.parseObject(s);
//
String fileUrl = jsonObject.getString("data");
//
HttpDownloadUtil.downLoadFromUrl(fileUrl,"bbb.pdf","D:\\Download");
//
}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
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.ap.GlobalSysInfo
;
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.framework.util.HttpUtil
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.common.pdu.user.UserPhpPdu
;
import
com.mortals.xhx.module.apply.service.ApproverService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
PARAM_SERVER_PHP_HTTP_URL
;
/**
* 同步用户
*/
@Slf4j
@Service
(
"SyncUserTask"
)
public
class
SyncUserTaskImpl
implements
ITaskExcuteService
{
@Autowired
private
UserService
userService
;
@Autowired
private
ApproverService
approverService
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
log
.
info
(
"同步用户"
);
String
phpUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_HTTP_URL
,
"http://172.15.28.116:8090"
);
phpUrl
+=
"/doors/inter/user/userList"
;
String
resp
=
null
;
try
{
HashMap
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
resp
=
HttpUtil
.
doGet
(
phpUrl
,
paramsMap
);
Rest
<
List
<
JSONObject
>>
list
=
JSON
.
parseObject
(
resp
,
Rest
.
class
);
List
<
UserPhpPdu
>
upp
=
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
list
.
getData
()),
UserPhpPdu
.
class
);
userService
.
updateUserList
(
upp
);
approverService
.
updateUserList
(
upp
);
}
catch
(
Exception
e
)
{
log
.
error
(
"同步用户发生异常"
,
e
);
}
}
@Override
public
void
stopTask
(
ITask
task
)
throws
AppException
{
}
}
//
package com.mortals.xhx.daemon.task;
//
//
import com.alibaba.fastjson.JSON;
//
import com.alibaba.fastjson.JSONArray;
//
import com.alibaba.fastjson.JSONObject;
//
import com.mortals.framework.ap.GlobalSysInfo;
//
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.framework.util.HttpUtil;
//
import com.mortals.xhx.base.system.user.service.UserService;
//
import com.mortals.xhx.common.pdu.user.UserPhpPdu;
//
import com.mortals.xhx.module.apply.service.ApproverService;
//
import lombok.extern.slf4j.Slf4j;
//
import org.springframework.beans.factory.annotation.Autowired;
//
import org.springframework.stereotype.Service;
//
//
import java.util.HashMap;
//
import java.util.List;
//
//
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL;
//
/
//
**
//
* 同步用户
//
*/
//
@Slf4j
//
@Service("SyncUserTask")
//
public class SyncUserTaskImpl implements ITaskExcuteService {
//
//
@Autowired
//
private UserService userService;
//
@Autowired
//
private ApproverService approverService;
//
//
@Override
//
public void excuteTask(ITask task) throws AppException {
//
//
log.info("同步用户");
//
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
//
phpUrl += "/doors/inter/user/userList";
//
String resp = null;
//
try {
//
HashMap<String, String> paramsMap = new HashMap<>();
//
resp = HttpUtil.doGet(phpUrl, paramsMap);
//
Rest<List<JSONObject>> list = JSON.parseObject(resp,Rest.class);
//
List<UserPhpPdu> upp = JSONArray.parseArray(JSONObject.toJSONString(list.getData()),UserPhpPdu.class);
//
userService.updateUserList(upp);
//
approverService.updateUserList(upp);
//
} catch (Exception e) {
//
log.error("同步用户发生异常",e);
//
}
//
//
}
//
//
//
@Override
//
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