Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
fanxing3
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a498f998
authored
Dec 01, 2021
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
<feat> 数据概览
1 parent
5281b59d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
7 deletions
fanxing-query/src/main/java/com/viontech/fanxing/query/controller/web/TrafficController.java
fanxing-query/src/main/java/com/viontech/fanxing/query/model/DataOverViewModel.java
fanxing-query/src/main/java/com/viontech/fanxing/query/service/adapter/TrafficService.java
fanxing-query/src/main/java/com/viontech/fanxing/query/service/impl/TrafficServiceImpl.java
fanxing-query/src/main/java/com/viontech/fanxing/query/controller/web/TrafficController.java
View file @
a498f99
...
...
@@ -22,6 +22,7 @@ import org.springframework.util.Assert;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -130,11 +131,14 @@ public class TrafficController extends TrafficBaseController {
/**
* 数据概览某个任务某天数据各分析了多少
*/
@GetMapping
(
"over
V
iew"
)
@GetMapping
(
"over
v
iew"
)
@ResponseBody
public
JsonMessageUtil
.
JsonMessage
<
List
<
DataOverViewModel
>>
overView
()
{
List
<
DataOverViewModel
>
dataOverViewModels
=
trafficService
.
dataOverView
(
new
Date
());
public
JsonMessageUtil
.
JsonMessage
<
Collection
<
DataOverViewModel
>>
overview
(
@RequestParam
(
required
=
false
)
Date
date
,
@RequestParam
(
required
=
false
)
Long
taskId
)
{
if
(
date
==
null
)
{
date
=
new
Date
();
}
Collection
<
DataOverViewModel
>
dataOverViewModels
=
trafficService
.
dataOverview
(
date
,
taskId
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
dataOverViewModels
);
}
...
...
fanxing-query/src/main/java/com/viontech/fanxing/query/model/DataOverViewModel.java
0 → 100644
View file @
a498f99
package
com
.
viontech
.
fanxing
.
query
.
model
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* .
*
* @author 谢明辉
* @date 2021/11/30
*/
@Getter
@Setter
public
class
DataOverViewModel
{
private
Long
taskId
;
private
Long
traffic
;
private
Long
flow
;
private
Long
behavior
;
private
Integer
hour
;
}
fanxing-query/src/main/java/com/viontech/fanxing/query/service/adapter/TrafficService.java
View file @
a498f99
package
com
.
viontech
.
fanxing
.
query
.
service
.
adapter
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageInfo
;
import
com.viontech.fanxing.commons.base.BaseExample
;
import
com.viontech.fanxing.commons.base.BaseService
;
import
com.viontech.fanxing.commons.model.Traffic
;
import
com.viontech.fanxing.commons.vo.TrafficVo
;
import
com.viontech.fanxing.query.model.DataOverViewModel
;
import
java.util.Collection
;
import
java.util.Date
;
public
interface
TrafficService
extends
BaseService
<
Traffic
>
{
PageInfo
<
TrafficVo
>
getJsonData
(
BaseExample
example
,
int
pageNum
,
int
pageSize
);
Collection
<
DataOverViewModel
>
dataOverview
(
Date
date
,
Long
taskId
);
}
\ No newline at end of file
fanxing-query/src/main/java/com/viontech/fanxing/query/service/impl/TrafficServiceImpl.java
View file @
a498f99
...
...
@@ -7,14 +7,20 @@ import com.github.pagehelper.PageInfo;
import
com.viontech.fanxing.commons.base.BaseExample
;
import
com.viontech.fanxing.commons.base.BaseMapper
;
import
com.viontech.fanxing.commons.base.BaseServiceImpl
;
import
com.viontech.fanxing.commons.model.Traffic
;
import
com.viontech.fanxing.commons.model.TrafficExample
;
import
com.viontech.fanxing.commons.model.*
;
import
com.viontech.fanxing.commons.vo.TrafficVo
;
import
com.viontech.fanxing.query.mapper.TrafficMapper
;
import
com.viontech.fanxing.query.model.DataOverViewModel
;
import
com.viontech.fanxing.query.service.adapter.BehaviorService
;
import
com.viontech.fanxing.query.service.adapter.FlowEventService
;
import
com.viontech.fanxing.query.service.adapter.TrafficService
;
import
com.viontech.keliu.util.DateUtil
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -22,6 +28,10 @@ import java.util.stream.Collectors;
public
class
TrafficServiceImpl
extends
BaseServiceImpl
<
Traffic
>
implements
TrafficService
{
@Resource
private
TrafficMapper
trafficMapper
;
@Resource
private
FlowEventService
flowEventService
;
@Resource
private
BehaviorService
behaviorService
;
@Override
public
BaseMapper
<
Traffic
>
getMapper
()
{
...
...
@@ -50,4 +60,66 @@ public class TrafficServiceImpl extends BaseServiceImpl<Traffic> implements Traf
page
.
addAll
(
collect
);
return
new
PageInfo
<>(
page
);
}
@Override
public
Collection
<
DataOverViewModel
>
dataOverview
(
Date
date
,
Long
taskId
)
{
Date
min
=
DateUtil
.
setDayMinTime
(
date
);
Date
max
=
DateUtil
.
setDayMaxTime
(
date
);
HashMap
<
Long
,
DataOverViewModel
>
resultMap
=
new
HashMap
<>();
TrafficExample
trafficExample
=
new
TrafficExample
();
TrafficExample
.
Criteria
criteria
=
trafficExample
.
createCriteria
().
andEventTimeGreaterThanOrEqualTo
(
min
).
andEventTimeLessThanOrEqualTo
(
max
);
if
(
taskId
!=
null
)
{
criteria
.
andTaskIdEqualTo
(
taskId
);
}
trafficExample
.
createColumns
().
hasTaskIdColumn
().
addColumnStr
(
"count(*) as count"
);
trafficExample
.
setGroupByClause
(
"task_id"
);
trafficExample
.
setOrderByClause
(
"task_id"
);
List
<
Traffic
>
traffic
=
trafficMapper
.
selectByExample
(
trafficExample
);
for
(
Traffic
t
:
traffic
)
{
DataOverViewModel
dov
=
resultMap
.
computeIfAbsent
(
t
.
getTaskId
(),
x
->
{
DataOverViewModel
temp
=
new
DataOverViewModel
();
temp
.
setTaskId
(
x
);
return
temp
;
});
dov
.
setTraffic
(
t
.
getCount
());
}
FlowEventExample
flowEventExample
=
new
FlowEventExample
();
FlowEventExample
.
Criteria
criteria1
=
flowEventExample
.
createCriteria
().
andEventTimeGreaterThanOrEqualTo
(
min
).
andEventTimeLessThanOrEqualTo
(
max
);
if
(
taskId
!=
null
)
{
criteria1
.
andTaskIdEqualTo
(
taskId
);
}
flowEventExample
.
createColumns
().
hasTaskIdColumn
().
addColumnStr
(
"count(*) as count"
);
flowEventExample
.
setGroupByClause
(
"task_id"
);
flowEventExample
.
setOrderByClause
(
"task_id"
);
List
<
FlowEvent
>
flowEvents
=
flowEventService
.
getMapper
().
selectByExample
(
flowEventExample
);
for
(
FlowEvent
f
:
flowEvents
)
{
DataOverViewModel
dov
=
resultMap
.
computeIfAbsent
(
f
.
getTaskId
(),
x
->
{
DataOverViewModel
temp
=
new
DataOverViewModel
();
temp
.
setTaskId
(
x
);
return
temp
;
});
dov
.
setFlow
(
f
.
getCount
());
}
BehaviorExample
behaviorExample
=
new
BehaviorExample
();
BehaviorExample
.
Criteria
criteria2
=
behaviorExample
.
createCriteria
().
andEventTimeGreaterThanOrEqualTo
(
min
).
andEventTimeLessThanOrEqualTo
(
max
);
if
(
taskId
!=
null
)
{
criteria2
.
andTaskIdEqualTo
(
taskId
);
}
behaviorExample
.
createColumns
().
hasTaskIdColumn
().
addColumnStr
(
"count(*) as count"
);
behaviorExample
.
setGroupByClause
(
"task_id"
);
behaviorExample
.
setOrderByClause
(
"task_id"
);
List
<
Behavior
>
behaviors
=
behaviorService
.
getMapper
().
selectByExample
(
behaviorExample
);
for
(
Behavior
b
:
behaviors
)
{
DataOverViewModel
dov
=
resultMap
.
computeIfAbsent
(
b
.
getTaskId
(),
x
->
{
DataOverViewModel
temp
=
new
DataOverViewModel
();
temp
.
setTaskId
(
x
);
return
temp
;
});
dov
.
setBehavior
(
b
.
getCount
());
}
return
resultMap
.
values
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment