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 353acb15
authored
Dec 23, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加线形图接口
1 parent
9000422b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
148 additions
and
2 deletions
src/main/java/cn/com/glsx/admin/modules/controller/HomeController.java
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
src/main/java/cn/com/glsx/admin/modules/model/DeviceBindVo.java
src/main/java/cn/com/glsx/admin/modules/model/comparator/ComparatorBindDeviceModel.java
src/main/java/cn/com/glsx/admin/modules/service/HomeService.java
src/main/resources/mapper/VehicleMapper.xml
src/main/java/cn/com/glsx/admin/modules/controller/HomeController.java
View file @
353acb1
package
cn
.
com
.
glsx
.
admin
.
modules
.
controller
;
import
cn.com.glsx.admin.modules.model.ActiveDeviceVo
;
import
cn.com.glsx.admin.modules.model.DeviceBindVo
;
import
cn.com.glsx.admin.modules.service.HomeService
;
import
cn.com.glsx.auth.utils.ShieldContextHolder
;
import
com.glsx.plat.core.web.R
;
...
...
@@ -102,6 +103,17 @@ public class HomeController {
return
R
.
ok
().
data
(
activeDeviceList
);
}
@GetMapping
(
"getnewbinddeviceinfo"
)
@ApiOperation
(
"设备绑定趋势"
)
public
R
<
List
<
DeviceBindVo
>>
getNewBindDeviceInfo
()
{
List
<
DeviceBindVo
>
deviceBindList
=
Lists
.
newArrayList
();
try
{
deviceBindList
=
homeService
.
getNewBindDeviceInfo
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
R
.
ok
().
data
(
deviceBindList
);
}
/**
* 总数查询刷新间隔,判断是否需要重新刷新
...
...
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
View file @
353acb1
...
...
@@ -182,4 +182,13 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
*/
@DataPerm
(
showSql
=
true
)
List
<
ActiveDeviceVo
>
getActiveDeviceInfoWithAuth
(
@Param
(
"appendSql"
)
String
appendSql
,
@Param
(
"period"
)
Integer
period
);
/**
* 根据权限获取该账户下 获取设备绑定数据
*
* @param appendSql 拼接SQl
* @return
*/
@DataPerm
(
showSql
=
true
)
List
<
DeviceBindVo
>
getBindDeviceInfoWithAuth
(
@Param
(
"appendSql"
)
String
appendSql
);
}
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/model/DeviceBindVo.java
0 → 100644
View file @
353acb1
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
;
/**
* 设备VO
*
* @author mym
* @version 2.2
* @history 2018-9-4
*/
import
lombok.Data
;
/**
* 绑定设备VO
*
* @author yll
*/
@Data
public
class
DeviceBindVo
{
/**
* 已绑定设备的数量
*/
private
int
bindDeviceNumber
;
/**
* 绑定设备的时间
*/
private
String
bindDate
;
}
src/main/java/cn/com/glsx/admin/modules/model/comparator/ComparatorBindDeviceModel.java
0 → 100644
View file @
353acb1
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
.
comparator
;
import
cn.com.glsx.admin.modules.model.DeviceBindVo
;
import
java.util.Comparator
;
/**
* 设备绑定比较器
*
* @author yll
*/
public
class
ComparatorBindDeviceModel
implements
Comparator
<
DeviceBindVo
>
{
@Override
public
int
compare
(
DeviceBindVo
dm1
,
DeviceBindVo
dm2
)
{
return
dm1
.
getBindDate
().
compareTo
(
dm2
.
getBindDate
());
}
}
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/service/HomeService.java
View file @
353acb1
...
...
@@ -4,6 +4,8 @@ import cn.com.glsx.admin.common.constants.Constants;
import
cn.com.glsx.admin.modules.mapper.VehicleDeviceMapper
;
import
cn.com.glsx.admin.modules.mapper.VehicleMapper
;
import
cn.com.glsx.admin.modules.model.ActiveDeviceVo
;
import
cn.com.glsx.admin.modules.model.DeviceBindVo
;
import
cn.com.glsx.admin.modules.model.comparator.ComparatorBindDeviceModel
;
import
cn.com.glsx.admin.modules.model.comparator.ComparatorDeviceModel
;
import
cn.com.glsx.admin.modules.remote.RemoteAlarmService
;
import
cn.com.glsx.admin.modules.remote.RemoteDeviceLoginService
;
...
...
@@ -290,4 +292,67 @@ public class HomeService {
}
return
retList
;
}
public
List
<
DeviceBindVo
>
getNewBindDeviceInfo
()
throws
ParseException
{
List
<
DeviceBindVo
>
retList
=
Lists
.
newArrayList
();
String
appendSql
=
DateUtil
.
appendSqlByTimeRange
(
11
,
"tvd.created_date"
);
List
<
DeviceBindVo
>
list
=
vehicleMapper
.
getBindDeviceInfoWithAuth
(
appendSql
);
if
(
list
!=
null
&&
list
.
size
()
==
0
)
{
list
=
null
;
}
Date
recThirtyBegin
=
DateUtils
.
parseDate
(
DateUtil
.
getReductionDay
(
29
),
PARSE_PATTERN
);
Date
recThirtyEnd
=
DateUtils
.
parseDate
(
DateUtil
.
getTodayDate
(),
PARSE_PATTERN
);
retList
=
fillIfNullByDateForBind
(
recThirtyBegin
,
recThirtyEnd
,
list
);
ComparatorBindDeviceModel
comparator
=
new
ComparatorBindDeviceModel
();
retList
.
sort
(
comparator
);
return
retList
;
}
/**
* 当列表中不包含开始日期到结束日期的对应的DeviceVo对象,则填充之
*
* @param dateBegin 开始日期
* @param dateEnd 结束日期
* @param list
* @return list
*/
private
List
<
DeviceBindVo
>
fillIfNullByDateForBind
(
Date
dateBegin
,
Date
dateEnd
,
List
<
DeviceBindVo
>
list
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
List
<
DeviceBindVo
>
retList
=
Lists
.
newArrayList
();
if
(
null
!=
list
)
{
retList
.
addAll
(
list
);
}
Calendar
ca
=
Calendar
.
getInstance
();
DeviceBindVo
dm
=
null
;
while
(
dateBegin
.
compareTo
(
dateEnd
)
<=
0
)
{
if
(
null
!=
list
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
if
(
sdf
.
format
(
dateBegin
).
equals
(
list
.
get
(
i
).
getBindDate
()))
{
break
;
}
if
(
i
==
list
.
size
()
-
1
)
{
dm
=
new
DeviceBindVo
();
dm
.
setBindDeviceNumber
(
0
);
dm
.
setBindDate
(
sdf
.
format
(
dateBegin
));
retList
.
add
(
dm
);
}
}
}
else
{
dm
=
new
DeviceBindVo
();
dm
.
setBindDeviceNumber
(
0
);
dm
.
setBindDate
(
sdf
.
format
(
dateBegin
));
retList
.
add
(
dm
);
}
ca
.
setTime
(
dateBegin
);
// 把dateBegin加上1天然后重新赋值给date1
ca
.
add
(
Calendar
.
DATE
,
1
);
dateBegin
=
ca
.
getTime
();
}
return
retList
;
}
}
src/main/resources/mapper/VehicleMapper.xml
View file @
353acb1
...
...
@@ -718,13 +718,25 @@
GROUP BY DATE_FORMAT(tvd.created_date,'%H')
</when>
<otherwise>
DATE_FORMAT(
dti.activeD
ate,'%Y-%m-%d') as activeDate
DATE_FORMAT(
tvd.created_d
ate,'%Y-%m-%d') as activeDate
FROM t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
WHERE tvd.bind_status = 1 and tv.del_flag = 0 and tvd.del_flag = 0
${appendSql}
GROUP BY DATE_FORMAT(
dti.activeD
ate,'%Y-%m-%d')
GROUP BY DATE_FORMAT(
tvd.created_d
ate,'%Y-%m-%d')
</otherwise>
</choose>
</select>
<select
id=
"getBindDeviceInfoWithAuth"
resultType=
"cn.com.glsx.admin.modules.model.DeviceBindVo"
>
SELECT count(0) AS bindDeviceNumber,
DATE_FORMAT(tvd.created_date, '%Y-%m-%d') as bindDate
FROM t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
WHERE tvd.bind_status = 1
and tv.del_flag = 0
and tvd.del_flag = 0
${appendSql}
GROUP BY DATE_FORMAT(tvd.created_date, '%Y-%m-%d')
</select>
</mapper>
\ 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