Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bill-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
赵啸非
bill-platform
Commits
58eda78b
Commit
58eda78b
authored
Jul 03, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加首页统计模块
parent
f954d7dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
3 deletions
+133
-3
bill-manager/src/main/java/com/mortals/xhx/base/login/web/LoginController.java
.../java/com/mortals/xhx/base/login/web/LoginController.java
+133
-3
No files found.
bill-manager/src/main/java/com/mortals/xhx/base/login/web/LoginController.java
View file @
58eda78b
package
com.mortals.xhx.base.login.web
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.ap.CookieService
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.IUser
;
...
...
@@ -18,11 +22,26 @@ import com.mortals.xhx.base.system.valid.service.ValidCodeService;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.common.utils.MenuEncodeUtil
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
import
com.mortals.xhx.module.access.service.AccessService
;
import
com.mortals.xhx.module.ph.model.PhQueueStatEntity
;
import
com.mortals.xhx.module.ph.model.PhQueueStatQuery
;
import
com.mortals.xhx.module.ph.service.PhQueueStatService
;
import
com.mortals.xhx.module.pj.model.PjEvaluateEntity
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatEntity
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatQuery
;
import
com.mortals.xhx.module.pj.service.PjEvaluateStatService
;
import
com.mortals.xhx.module.stat.model.StatEntity
;
import
com.mortals.xhx.module.stat.model.StatQuery
;
import
com.mortals.xhx.module.stat.service.StatService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -30,8 +49,8 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.
util.Lis
t
;
import
java.util.
Set
;
import
java.
lang.foreign.StructLayou
t
;
import
java.util.
*
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
ErrorCode
.
ERROR_TOKEN_EXPIRED
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
ErrorCode
.
ERROR_TOKEN_EXPIRED_CONTENT
;
...
...
@@ -51,6 +70,20 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
private
IAuthTokenService
authTokenService
;
@Autowired
private
IUserFeign
userFeign
;
@Autowired
private
StatService
statService
;
@Autowired
private
PhQueueStatService
phQueueStatService
;
@Autowired
private
PjEvaluateStatService
pjEvaluateStatService
;
@Autowired
private
ISiteFeign
siteFeign
;
@Autowired
private
AccessService
accessService
;
@RequestMapping
(
"login"
)
public
String
login
(
@RequestBody
LoginForm
loginForm
)
throws
Exception
{
...
...
@@ -79,7 +112,7 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
return
JSONObject
.
toJSONString
(
Rest
.
fail
(
ERROR_TOKEN_EXPIRED
,
ERROR_TOKEN_EXPIRED_CONTENT
));
}
Set
<
String
>
urls
=
resourceService
.
findUrlSetByUserId
(
user
.
getId
());
log
.
info
(
"userId:{},urls:{}"
,
user
.
getId
(),
JSON
.
toJSONString
(
urls
));
log
.
info
(
"userId:{},urls:{}"
,
user
.
getId
(),
JSON
.
toJSONString
(
urls
));
List
<
MenuEntity
>
outlookBarList
=
menuService
.
findTreeMenu
(
user
,
urls
);
String
currUserName
=
user
.
getRealName
();
if
(
currUserName
==
null
||
currUserName
.
trim
().
length
()
==
0
)
{
...
...
@@ -99,11 +132,108 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_MSG
,
"用户登录系统成功!"
);
ret
.
put
(
"resources"
,
urls
);
//todo 首页统计报表
int
totalAccessSite
=
0
;
List
<
AccessEntity
>
accessEntities
=
new
ArrayList
<>();
RedisTemplate
<
String
,
String
>
baseRedisTemplate
=
cacheService
.
selectDbRedisTemplate
(
1
);
//com:mortals:xhx:module:site:model:SiteEntity redis调用
String
siteTreeStr
=
(
String
)
baseRedisTemplate
.
opsForHash
().
get
(
"user:site:tree"
,
String
.
valueOf
(
user
.
getId
()));
if
(!
ObjectUtils
.
isEmpty
(
siteTreeStr
))
{
log
.
info
(
"siteTreeStr:{}"
,
siteTreeStr
);
//获取当前用户所拥有的站点列表
accessEntities
=
accessService
.
find
(
new
AccessQuery
());
totalAccessSite
=
accessEntities
.
size
();
if
(!
ObjectUtils
.
isEmpty
(
accessEntities
))
{
//当前用户存在的区域或者站点列表
//遍历 如果不存在 正则
Iterator
<
AccessEntity
>
iterator
=
accessEntities
.
iterator
();
while
(
iterator
.
hasNext
())
{
AccessEntity
next
=
iterator
.
next
();
String
type
=
next
.
getType
();
if
(
"area"
.
equals
(
type
))
{
boolean
contains
=
StrUtil
.
contains
(
siteTreeStr
,
next
.
getAreaCode
());
if
(!
contains
)
{
iterator
.
remove
();
}
}
else
if
(
"site"
.
equals
(
type
))
{
boolean
contains
=
StrUtil
.
contains
(
siteTreeStr
,
next
.
getSiteCode
());
if
(!
contains
)
{
iterator
.
remove
();
}
}
else
{
log
.
info
(
"未知类型节点,不做过滤!"
);
}
}
}
}
data
.
put
(
"accessList"
,
accessEntities
);
data
.
put
(
"totalAccessSite"
,
totalAccessSite
);
int
totalCount
=
0
;
StatQuery
statQuery
=
new
StatQuery
();
statQuery
.
setGroupList
(
Arrays
.
asList
(
"year"
));
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setPrePageResult
(-
1
);
List
<
StatEntity
>
list
=
statService
.
find
(
statQuery
,
pageInfo
,
getContext
()).
getList
();
if
(!
ObjectUtils
.
isEmpty
(
list
))
{
totalCount
=
list
.
stream
().
mapToInt
(
i
->
i
.
getCount
()).
sum
();
}
data
.
put
(
"totalCount"
,
totalCount
);
//近三十天数据总量趋势
getThirtyStats
(
data
);
getThirtyPhStats
(
data
);
getThirtyPjStats
(
data
);
return
ret
.
toJSONString
();
}
private
void
getThirtyStats
(
JSONObject
data
)
{
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setPrePageResult
(-
1
);
StatQuery
statThirtyQuery
=
new
StatQuery
();
statThirtyQuery
.
setTimeStart
(
DateUtil
.
offsetDay
(
new
Date
(),
30
).
toDateStr
());
statThirtyQuery
.
setTimeEnd
(
DateUtil
.
today
());
statThirtyQuery
.
setGroupList
(
Arrays
.
asList
(
"year"
,
"month"
,
"day"
));
List
<
StatEntity
>
thirtyStatList
=
statService
.
find
(
statThirtyQuery
,
pageInfo
,
getContext
()).
getList
();
if
(!
ObjectUtils
.
isEmpty
(
thirtyStatList
))
{
//todo 日期排序趋势降序图
data
.
put
(
"thirtyStatList"
,
thirtyStatList
);
}
}
private
void
getThirtyPhStats
(
JSONObject
data
)
{
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setPrePageResult
(-
1
);
PhQueueStatQuery
statThirtyQuery
=
new
PhQueueStatQuery
();
statThirtyQuery
.
setTimeStart
(
DateUtil
.
offsetDay
(
new
Date
(),
30
).
toDateStr
());
statThirtyQuery
.
setTimeEnd
(
DateUtil
.
today
());
statThirtyQuery
.
setGroupList
(
Arrays
.
asList
(
"year"
,
"month"
,
"day"
));
List
<
PhQueueStatEntity
>
thirtyStatList
=
phQueueStatService
.
find
(
statThirtyQuery
,
pageInfo
,
getContext
()).
getList
();
if
(!
ObjectUtils
.
isEmpty
(
thirtyStatList
))
{
//todo 日期排序趋势降序图
data
.
put
(
"thirtyPhStatList"
,
thirtyStatList
);
}
}
private
void
getThirtyPjStats
(
JSONObject
data
)
{
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setPrePageResult
(-
1
);
PjEvaluateStatQuery
statThirtyQuery
=
new
PjEvaluateStatQuery
();
statThirtyQuery
.
setTimeStart
(
DateUtil
.
offsetDay
(
new
Date
(),
30
).
toDateStr
());
statThirtyQuery
.
setTimeEnd
(
DateUtil
.
today
());
statThirtyQuery
.
setGroupList
(
Arrays
.
asList
(
"year"
,
"month"
,
"day"
));
List
<
PjEvaluateStatEntity
>
thirtyStatList
=
pjEvaluateStatService
.
find
(
statThirtyQuery
,
pageInfo
,
getContext
()).
getList
();
if
(!
ObjectUtils
.
isEmpty
(
thirtyStatList
))
{
//todo 日期排序趋势降序图
data
.
put
(
"thirtyPjStatList"
,
thirtyStatList
);
}
}
@Override
...
...
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