Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
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 5a8023a0
authored
Mar 17, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
首页统计-数据精确授权处理
1 parent
3c6a537a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
18 deletions
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleDeviceMapper.java
src/main/java/cn/com/glsx/admin/modules/model/ActiveDeviceVo.java
src/main/java/cn/com/glsx/admin/modules/model/DeviceBindVo.java
src/main/java/cn/com/glsx/admin/modules/model/stat/StatSearch.java
src/main/java/cn/com/glsx/admin/modules/service/HomeService.java
src/main/resources/mapper/VehicleDeviceMapper.xml
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleDeviceMapper.java
View file @
5a8023a
...
@@ -3,6 +3,7 @@ package cn.com.glsx.admin.modules.mapper;
...
@@ -3,6 +3,7 @@ package cn.com.glsx.admin.modules.mapper;
import
cn.com.glsx.admin.modules.entity.VehicleDevice
;
import
cn.com.glsx.admin.modules.entity.VehicleDevice
;
import
cn.com.glsx.admin.modules.model.stat.StatActiveVehicleDevice
;
import
cn.com.glsx.admin.modules.model.stat.StatActiveVehicleDevice
;
import
cn.com.glsx.admin.modules.model.stat.StatCountModel
;
import
cn.com.glsx.admin.modules.model.stat.StatCountModel
;
import
cn.com.glsx.admin.modules.model.stat.StatSearch
;
import
com.glsx.plat.common.annotation.DataPerm
;
import
com.glsx.plat.common.annotation.DataPerm
;
import
com.glsx.plat.common.annotation.DataPermShare
;
import
com.glsx.plat.common.annotation.DataPermShare
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
...
@@ -73,7 +74,7 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
...
@@ -73,7 +74,7 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
*/
*/
@DataPerm
(
permTable
=
"tv"
,
showSql
=
true
)
@DataPerm
(
permTable
=
"tv"
,
showSql
=
true
)
@DataPermShare
(
linkTable
=
"t_vehicle"
,
showSql
=
true
)
@DataPermShare
(
linkTable
=
"t_vehicle"
,
showSql
=
true
)
List
<
StatActiveVehicleDevice
>
getActiveDeviceWithAuth
();
List
<
StatActiveVehicleDevice
>
getActiveDeviceWithAuth
(
@Param
(
"search"
)
StatSearch
search
);
/**
/**
* 根据权限获取该账户下 所有激活设备和当天激活的设备总数
* 根据权限获取该账户下 所有激活设备和当天激活的设备总数
...
...
src/main/java/cn/com/glsx/admin/modules/model/ActiveDeviceVo.java
View file @
5a8023a
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
;
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
/**
* 设备激活Vo
* 设备激活Vo
...
@@ -8,15 +10,18 @@ import lombok.Data;
...
@@ -8,15 +10,18 @@ import lombok.Data;
* @author yll
* @author yll
*/
*/
@Data
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
ActiveDeviceVo
{
public
class
ActiveDeviceVo
{
/**
/**
*
已激活设备的数量
*
激活设备的时间
*/
*/
private
int
activeNumber
;
private
String
activeDate
;
/**
/**
*
激活设备的时间
*
已激活设备的数量
*/
*/
private
String
activeDate
;
private
int
activeNumber
;
}
}
src/main/java/cn/com/glsx/admin/modules/model/DeviceBindVo.java
View file @
5a8023a
...
@@ -8,7 +8,9 @@ package cn.com.glsx.admin.modules.model;
...
@@ -8,7 +8,9 @@ package cn.com.glsx.admin.modules.model;
* @history 2018-9-4
* @history 2018-9-4
*/
*/
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
/**
* 绑定设备VO
* 绑定设备VO
...
@@ -16,14 +18,18 @@ import lombok.Data;
...
@@ -16,14 +18,18 @@ import lombok.Data;
* @author yll
* @author yll
*/
*/
@Data
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
DeviceBindVo
{
public
class
DeviceBindVo
{
/**
* 已绑定设备的数量
*/
private
int
bindDeviceNumber
;
/**
/**
* 绑定设备的时间
* 绑定设备的时间
*/
*/
private
String
bindDate
;
private
String
bindDate
;
/**
* 已绑定设备的数量
*/
private
int
bindDeviceNumber
;
}
}
src/main/java/cn/com/glsx/admin/modules/model/stat/StatSearch.java
0 → 100644
View file @
5a8023a
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
.
stat
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
@Data
@Accessors
(
chain
=
true
)
public
class
StatSearch
{
private
String
statPattern
;
private
String
statScope
;
private
String
statBeginScope
;
private
String
statEndScope
;
private
String
appendSql
;
}
src/main/java/cn/com/glsx/admin/modules/service/HomeService.java
View file @
5a8023a
...
@@ -9,6 +9,7 @@ import cn.com.glsx.admin.modules.model.comparator.ComparatorBindDeviceModel;
...
@@ -9,6 +9,7 @@ import cn.com.glsx.admin.modules.model.comparator.ComparatorBindDeviceModel;
import
cn.com.glsx.admin.modules.model.comparator.ComparatorDeviceModel
;
import
cn.com.glsx.admin.modules.model.comparator.ComparatorDeviceModel
;
import
cn.com.glsx.admin.modules.model.stat.StatActiveVehicleDevice
;
import
cn.com.glsx.admin.modules.model.stat.StatActiveVehicleDevice
;
import
cn.com.glsx.admin.modules.model.stat.StatCountModel
;
import
cn.com.glsx.admin.modules.model.stat.StatCountModel
;
import
cn.com.glsx.admin.modules.model.stat.StatSearch
;
import
cn.com.glsx.admin.modules.remote.RemoteAlarmService
;
import
cn.com.glsx.admin.modules.remote.RemoteAlarmService
;
import
cn.com.glsx.admin.modules.remote.RemoteStuJudgeAlarmService
;
import
cn.com.glsx.admin.modules.remote.RemoteStuJudgeAlarmService
;
import
cn.com.glsx.admin.modules.utils.DateUtil
;
import
cn.com.glsx.admin.modules.utils.DateUtil
;
...
@@ -19,6 +20,7 @@ import com.glsx.plat.context.utils.PropertiesUtils;
...
@@ -19,6 +20,7 @@ import com.glsx.plat.context.utils.PropertiesUtils;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -75,9 +77,12 @@ public class HomeService {
...
@@ -75,9 +77,12 @@ public class HomeService {
// Integer activeNumForToday = activeStatList.stream().map(StatCountModel::getCnt1).filter(Objects::nonNull).reduce(0, Integer::sum);
// Integer activeNumForToday = activeStatList.stream().map(StatCountModel::getCnt1).filter(Objects::nonNull).reduce(0, Integer::sum);
//方案二
//方案二
List
<
StatActiveVehicleDevice
>
activeDeviceList
=
vehicleDeviceMapper
.
getActiveDeviceWithAuth
();
List
<
StatActiveVehicleDevice
>
activeDeviceList
=
vehicleDeviceMapper
.
getActiveDeviceWithAuth
(
new
StatSearch
().
setStatPattern
(
"%Y-%m-%d"
)
);
List
<
StatActiveVehicleDevice
>
activeTodayList
=
activeDeviceList
.
stream
().
filter
(
device
->
today
.
equals
(
device
.
getActiveTime
())).
collect
(
Collectors
.
toList
());
List
<
StatActiveVehicleDevice
>
activeTodayList
=
activeDeviceList
.
stream
().
filter
(
device
->
today
.
equals
(
device
.
getActiveTime
())).
collect
(
Collectors
.
toList
());
Set
<
Long
>
allBindVehicles
=
activeDeviceList
.
stream
().
map
(
StatActiveVehicleDevice:
:
getVehicleId
).
collect
(
Collectors
.
toSet
());
Set
<
Long
>
bindForTodayVehicles
=
activeTodayList
.
stream
().
map
(
StatActiveVehicleDevice:
:
getVehicleId
).
collect
(
Collectors
.
toSet
());
//总激活数
//总激活数
returnMap
.
put
(
"allActiveNumber"
,
activeDeviceList
.
size
());
returnMap
.
put
(
"allActiveNumber"
,
activeDeviceList
.
size
());
//今日激活数
//今日激活数
...
@@ -87,9 +92,6 @@ public class HomeService {
...
@@ -87,9 +92,6 @@ public class HomeService {
// Integer allBindNumber = bindStatList.stream().map(StatCountModel::getCnt).filter(Objects::nonNull).reduce(0, Integer::sum);
// Integer allBindNumber = bindStatList.stream().map(StatCountModel::getCnt).filter(Objects::nonNull).reduce(0, Integer::sum);
// Integer bindNumForToday = bindStatList.stream().map(StatCountModel::getCnt1).filter(Objects::nonNull).reduce(0, Integer::sum);
// Integer bindNumForToday = bindStatList.stream().map(StatCountModel::getCnt1).filter(Objects::nonNull).reduce(0, Integer::sum);
Set
<
Long
>
allBindVehicles
=
activeDeviceList
.
stream
().
map
(
StatActiveVehicleDevice:
:
getVehicleId
).
collect
(
Collectors
.
toSet
());
Set
<
Long
>
bindForTodayVehicles
=
activeTodayList
.
stream
().
map
(
StatActiveVehicleDevice:
:
getVehicleId
).
collect
(
Collectors
.
toSet
());
//总绑定数
//总绑定数
returnMap
.
put
(
"allBindNumber"
,
allBindVehicles
.
size
());
returnMap
.
put
(
"allBindNumber"
,
allBindVehicles
.
size
());
//今日绑定数
//今日绑定数
...
@@ -164,7 +166,22 @@ public class HomeService {
...
@@ -164,7 +166,22 @@ public class HomeService {
public
List
<
ActiveDeviceVo
>
getActiveDeviceInfo
(
Integer
period
)
throws
ParseException
{
public
List
<
ActiveDeviceVo
>
getActiveDeviceInfo
(
Integer
period
)
throws
ParseException
{
String
appendSql
=
DateUtil
.
appendSqlByTimeRange
(
period
,
"tvd.created_date"
);
String
appendSql
=
DateUtil
.
appendSqlByTimeRange
(
period
,
"tvd.created_date"
);
List
<
ActiveDeviceVo
>
list
=
vehicleMapper
.
getActiveDeviceInfoWithAuth
(
appendSql
,
period
);
//List<ActiveDeviceVo> list = vehicleMapper.getActiveDeviceInfoWithAuth(appendSql, period);
StatSearch
search
=
new
StatSearch
();
if
(
period
==
1
||
period
==
2
)
{
search
.
setStatPattern
(
"%H"
);
}
else
{
search
.
setStatPattern
(
"%Y-%m-%d"
);
}
search
.
setAppendSql
(
appendSql
);
List
<
StatActiveVehicleDevice
>
activeDeviceList
=
vehicleDeviceMapper
.
getActiveDeviceWithAuth
(
search
);
Map
<
String
,
List
<
StatActiveVehicleDevice
>>
groupByActiveTimeMap
=
activeDeviceList
.
stream
().
collect
(
Collectors
.
groupingBy
(
StatActiveVehicleDevice:
:
getActiveTime
));
List
<
ActiveDeviceVo
>
list
=
convertActiveDeviceVoList
(
groupByActiveTimeMap
);
if
(
list
!=
null
&&
list
.
size
()
==
0
)
{
if
(
list
!=
null
&&
list
.
size
()
==
0
)
{
list
=
null
;
list
=
null
;
}
}
...
@@ -213,6 +230,12 @@ public class HomeService {
...
@@ -213,6 +230,12 @@ public class HomeService {
return
retList
;
return
retList
;
}
}
public
List
<
ActiveDeviceVo
>
convertActiveDeviceVoList
(
Map
<
String
,
List
<
StatActiveVehicleDevice
>>
groupByActiveTimeMap
)
{
List
<
ActiveDeviceVo
>
list
=
Lists
.
newArrayList
();
groupByActiveTimeMap
.
forEach
((
k
,
v
)
->
list
.
add
(
new
ActiveDeviceVo
(
k
,
v
.
size
())));
return
list
;
}
/**
/**
* 当列表中不包含1到24小时对应的DeviceVo对象,则填充之
* 当列表中不包含1到24小时对应的DeviceVo对象,则填充之
*
*
...
@@ -310,12 +333,20 @@ public class HomeService {
...
@@ -310,12 +333,20 @@ public class HomeService {
return
retList
;
return
retList
;
}
}
public
List
<
DeviceBindVo
>
getNewBindDeviceInfo
()
throws
ParseException
{
public
List
<
DeviceBindVo
>
getNewBindDeviceInfo
()
throws
ParseException
{
List
<
DeviceBindVo
>
retList
=
Lists
.
newArrayList
();
List
<
DeviceBindVo
>
retList
=
Lists
.
newArrayList
();
String
appendSql
=
DateUtil
.
appendSqlByTimeRange
(
11
,
"tvd.created_date"
);
String
appendSql
=
DateUtil
.
appendSqlByTimeRange
(
11
,
"tvd.created_date"
);
List
<
DeviceBindVo
>
list
=
vehicleMapper
.
getBindDeviceInfoWithAuth
(
appendSql
);
if
(
list
!=
null
&&
list
.
size
()
==
0
)
{
//List<DeviceBindVo> list = vehicleMapper.getBindDeviceInfoWithAuth(appendSql);
StatSearch
search
=
new
StatSearch
().
setStatPattern
(
"%Y-%m-%d"
);
search
.
setAppendSql
(
appendSql
);
List
<
StatActiveVehicleDevice
>
activeDeviceList
=
vehicleDeviceMapper
.
getActiveDeviceWithAuth
(
search
);
Map
<
String
,
List
<
StatActiveVehicleDevice
>>
groupByActiveTimeMap
=
activeDeviceList
.
stream
().
collect
(
Collectors
.
groupingBy
(
StatActiveVehicleDevice:
:
getActiveTime
));
List
<
DeviceBindVo
>
list
=
convertDeviceBindVoList
(
groupByActiveTimeMap
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
list
=
null
;
list
=
null
;
}
}
Date
recThirtyBegin
=
DateUtils
.
parseDate
(
DateUtil
.
getReductionDay
(
29
),
PARSE_PATTERN
);
Date
recThirtyBegin
=
DateUtils
.
parseDate
(
DateUtil
.
getReductionDay
(
29
),
PARSE_PATTERN
);
...
@@ -327,6 +358,12 @@ public class HomeService {
...
@@ -327,6 +358,12 @@ public class HomeService {
return
retList
;
return
retList
;
}
}
public
List
<
DeviceBindVo
>
convertDeviceBindVoList
(
Map
<
String
,
List
<
StatActiveVehicleDevice
>>
groupByActiveTimeMap
)
{
List
<
DeviceBindVo
>
list
=
Lists
.
newArrayList
();
groupByActiveTimeMap
.
forEach
((
k
,
v
)
->
list
.
add
(
new
DeviceBindVo
(
k
,
v
.
size
())));
return
list
;
}
/**
/**
* 当列表中不包含开始日期到结束日期的对应的DeviceVo对象,则填充之
* 当列表中不包含开始日期到结束日期的对应的DeviceVo对象,则填充之
*
*
...
...
src/main/resources/mapper/VehicleDeviceMapper.xml
View file @
5a8023a
...
@@ -86,12 +86,15 @@
...
@@ -86,12 +86,15 @@
</update>
</update>
<select
id=
"getActiveDeviceWithAuth"
resultType=
"cn.com.glsx.admin.modules.model.stat.StatActiveVehicleDevice"
>
<select
id=
"getActiveDeviceWithAuth"
resultType=
"cn.com.glsx.admin.modules.model.stat.StatActiveVehicleDevice"
>
select tvd.id, tvd.vehicle_id vehicleId, date_format(tvd.created_date,
'%Y-%m-%d'
) activeTime
select tvd.id, tvd.vehicle_id vehicleId, date_format(tvd.created_date,
#{search.statPattern}
) activeTime
from t_vehicle tv
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
where tvd.bind_status = 1
where tvd.bind_status = 1
and tvd.del_flag = 0
and tvd.del_flag = 0
and tv.del_flag = 0
and tv.del_flag = 0
<if
test=
"search.appendSql != null and search.appendSql !=''"
>
${search.appendSql}
</if>
</select>
</select>
<select
id=
"getActiveNumberWithAuth"
resultType=
"cn.com.glsx.admin.modules.model.stat.StatCountModel"
>
<select
id=
"getActiveNumberWithAuth"
resultType=
"cn.com.glsx.admin.modules.model.stat.StatCountModel"
>
...
...
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