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 d6951415
authored
Aug 27, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
e45d9f1d
54c2438d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
20 deletions
src/main/java/cn/com/glsx/admin/common/enums/ResultEnum.java
src/main/java/cn/com/glsx/admin/modules/controller/VehicleMonitorController.java
src/main/java/cn/com/glsx/admin/modules/model/param/VehicleTreeSearch.java
src/main/java/cn/com/glsx/admin/modules/service/VehicleMonitorSevice.java
src/main/java/cn/com/glsx/admin/modules/service/VehicleService.java
src/main/resources/mapper/VehicleMapper.xml
src/main/java/cn/com/glsx/admin/common/enums/ResultEnum.java
View file @
d695141
...
@@ -24,7 +24,7 @@ public enum ResultEnum {
...
@@ -24,7 +24,7 @@ public enum ResultEnum {
/**
/**
* 试驾车辆管理相关业务异常错误码,错误信息 1212开头
* 试驾车辆管理相关业务异常错误码,错误信息 1212开头
*/
*/
TRIAL_DRIVE_DEVICE_EXISTS
(
12120001
,
"该设备已绑定车辆,vehicleId:%s"
),
TRIAL_DRIVE_DEVICE_EXISTS
(
12120001
,
"该设备已绑定车辆
(%s)
,vehicleId:%s"
),
IMPORT_FAIL_FILE
(
12120002
,
"导入文件与指定模板不匹配"
),
IMPORT_FAIL_FILE
(
12120002
,
"导入文件与指定模板不匹配"
),
IMPORT_FILE_TYPE_ERROR
(
12120003
,
"导入文件类型错误"
),
IMPORT_FILE_TYPE_ERROR
(
12120003
,
"导入文件类型错误"
),
IMPORT_FAIL_NOT_FOUND
(
12120004
,
"未找到失败的文件"
),
IMPORT_FAIL_NOT_FOUND
(
12120004
,
"未找到失败的文件"
),
...
...
src/main/java/cn/com/glsx/admin/modules/controller/VehicleMonitorController.java
View file @
d695141
...
@@ -63,6 +63,17 @@ public class VehicleMonitorController {
...
@@ -63,6 +63,17 @@ public class VehicleMonitorController {
return
R
.
ok
().
data
(
list
);
return
R
.
ok
().
data
(
list
);
}
}
/**
* @param oId
* @return
*/
@ApiOperation
(
value
=
"选择监控车辆树节点,获取组织所有车辆设备id"
)
@GetMapping
(
"/ovlist"
)
public
R
<
List
<
String
>>
selectTree
(
@RequestParam
(
"oId"
)
Long
oId
)
{
List
<
String
>
list
=
vehicleMonitorSevice
.
selectTree
(
oId
);
return
R
.
ok
().
data
(
list
);
}
@ApiOperation
(
value
=
"查询车辆位置信息接口"
)
@ApiOperation
(
value
=
"查询车辆位置信息接口"
)
@GetMapping
(
"/vehiclelocation"
)
@GetMapping
(
"/vehiclelocation"
)
public
R
vehicleLocationInfo
(
String
sn
)
{
public
R
vehicleLocationInfo
(
String
sn
)
{
...
...
src/main/java/cn/com/glsx/admin/modules/model/param/VehicleTreeSearch.java
View file @
d695141
...
@@ -29,9 +29,4 @@ public class VehicleTreeSearch {
...
@@ -29,9 +29,4 @@ public class VehicleTreeSearch {
*/
*/
private
Collection
<
Long
>
userIds
;
private
Collection
<
Long
>
userIds
;
/**
* 用户id
*/
private
Long
userId
;
}
}
src/main/java/cn/com/glsx/admin/modules/service/VehicleMonitorSevice.java
View file @
d695141
...
@@ -38,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -38,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
java
.
util
.
stream
.
Collectors
.
groupingBy
;
import
static
java
.
util
.
stream
.
Collectors
.
groupingBy
;
...
@@ -128,6 +129,37 @@ public class VehicleMonitorSevice {
...
@@ -128,6 +129,37 @@ public class VehicleMonitorSevice {
});
});
}
}
public
List
<
String
>
selectTree
(
Long
oid
)
{
VehicleTreeSearch
search
=
new
VehicleTreeSearch
();
search
.
setOrgIds
(
Lists
.
newArrayList
(
oid
));
//待优化,这里只需要拿组织下的用户即可,可以在用户服务端过滤掉组织
List
<
OrgTreeModel
>
orgTreeModelList
=
organizationApiService
.
orgTree
(
search
);
List
<
OrgTreeModel
>
userList
=
orgTreeModelList
.
stream
().
filter
(
index
->
"u"
.
equals
(
index
.
getOrigin
().
getType
())).
collect
(
Collectors
.
toList
());
Set
<
String
>
userIdSet
=
userList
.
stream
().
map
(
OrgTreeModel:
:
getId
).
collect
(
Collectors
.
toSet
());
List
<
Long
>
userIdList
=
Lists
.
newArrayList
();
userIdSet
.
forEach
(
uid
->
{
userIdList
.
add
(
Long
.
valueOf
(
uid
.
replace
(
"u"
,
""
)));
});
List
<
OrgVehicleModel
>
modelList
=
vehicleMapper
.
selectVehicleSns
(
new
VehicleTreeSearch
().
setUserIds
(
userIdList
));
log
.
info
(
"组织{}下面总车辆设备数{}"
,
oid
,
modelList
.
size
());
List
<
String
>
deviceIdList
=
Lists
.
newArrayList
();
modelList
.
forEach
(
model
->
{
deviceIdList
.
add
(
"d"
+
model
.
getId
());
});
return
deviceIdList
;
}
/**
/**
* 根据用户id获取车辆列表
* 根据用户id获取车辆列表
*
*
...
@@ -139,7 +171,7 @@ public class VehicleMonitorSevice {
...
@@ -139,7 +171,7 @@ public class VehicleMonitorSevice {
return
Lists
.
newArrayList
();
return
Lists
.
newArrayList
();
}
}
List
<
OrgVehicleModel
>
modelList
=
vehicleMapper
.
selectVehicleSns
(
new
VehicleTreeSearch
().
setUserId
(
userId
));
List
<
OrgVehicleModel
>
modelList
=
vehicleMapper
.
selectVehicleSns
(
new
VehicleTreeSearch
().
setUserId
s
(
Lists
.
newArrayList
(
userId
)
));
List
<
OrgVehicleTree
>
vehicleList
=
convert2ovt
(
modelList
);
List
<
OrgVehicleTree
>
vehicleList
=
convert2ovt
(
modelList
);
...
...
src/main/java/cn/com/glsx/admin/modules/service/VehicleService.java
View file @
d695141
...
@@ -203,7 +203,7 @@ public class VehicleService {
...
@@ -203,7 +203,7 @@ public class VehicleService {
//存在绑定多个设备的情况
//存在绑定多个设备的情况
String
[]
snArr
=
sns
.
split
(
","
);
String
[]
snArr
=
sns
.
split
(
","
);
for
(
String
sn
:
snArr
)
{
for
(
String
sn
:
snArr
)
{
saveSnBindDevice
(
sn
,
vehicle
.
getId
()
,
driveVehicleBo
.
getShopNameId
());
saveSnBindDevice
(
sn
,
vehicle
,
driveVehicleBo
.
getShopNameId
());
}
}
}
}
...
@@ -224,7 +224,7 @@ public class VehicleService {
...
@@ -224,7 +224,7 @@ public class VehicleService {
}
}
}
}
public
void
saveSnBindDevice
(
String
sn
,
Long
vehicleId
,
Long
createId
)
{
public
void
saveSnBindDevice
(
String
sn
,
Vehicle
vehicle
,
Long
createId
)
{
//查询该设备是否存在 不存在 则从旧e盾查询
//查询该设备是否存在 不存在 则从旧e盾查询
if
(!
deviceService
.
checkSnExist
(
sn
))
{
if
(!
deviceService
.
checkSnExist
(
sn
))
{
// 旧e盾不存在 抛出异常 存在则保存数据
// 旧e盾不存在 抛出异常 存在则保存数据
...
@@ -241,12 +241,12 @@ public class VehicleService {
...
@@ -241,12 +241,12 @@ public class VehicleService {
VehicleDevice
vdBind
=
vehicleDeviceService
.
getVehicleDeviceBySnBind
(
sn
);
VehicleDevice
vdBind
=
vehicleDeviceService
.
getVehicleDeviceBySnBind
(
sn
);
if
(
vdBind
!=
null
)
{
if
(
vdBind
!=
null
)
{
throw
new
AdminException
(
ResultEnum
.
TRIAL_DRIVE_DEVICE_EXISTS
.
getCode
(),
throw
new
AdminException
(
ResultEnum
.
TRIAL_DRIVE_DEVICE_EXISTS
.
getCode
(),
String
.
format
(
ResultEnum
.
TRIAL_DRIVE_DEVICE_EXISTS
.
getMessage
(),
vdBind
.
getVehicleId
()));
String
.
format
(
ResultEnum
.
TRIAL_DRIVE_DEVICE_EXISTS
.
getMessage
(),
v
ehicle
.
getVin
(),
v
dBind
.
getVehicleId
()));
}
}
VehicleDevice
vehicleDevice
=
new
VehicleDevice
();
VehicleDevice
vehicleDevice
=
new
VehicleDevice
();
vehicleDevice
.
setBindStatus
(
ConstantsDevice
.
BIND_VEHICLE_STATUS
);
vehicleDevice
.
setBindStatus
(
ConstantsDevice
.
BIND_VEHICLE_STATUS
);
vehicleDevice
.
setSn
(
sn
);
vehicleDevice
.
setSn
(
sn
);
vehicleDevice
.
setVehicleId
(
vehicle
Id
);
vehicleDevice
.
setVehicleId
(
vehicle
.
getId
()
);
vehicleDevice
.
setCreatedBy
(
createId
);
vehicleDevice
.
setCreatedBy
(
createId
);
vehicleDevice
.
setCreatedDate
(
new
Date
());
vehicleDevice
.
setCreatedDate
(
new
Date
());
vehicleDeviceService
.
insert
(
vehicleDevice
);
vehicleDeviceService
.
insert
(
vehicleDevice
);
...
@@ -300,22 +300,21 @@ public class VehicleService {
...
@@ -300,22 +300,21 @@ public class VehicleService {
for
(
String
sn
:
snArr
)
{
for
(
String
sn
:
snArr
)
{
checkSnBindDevice
(
driveVehicleoBo
,
sn
,
bindVehicleDevice
);
checkSnBindDevice
(
driveVehicleoBo
,
sn
,
bindVehicleDevice
);
}
}
}
}
/**
/**
* 现在绑定了的情况
* 现在绑定了的情况
*
*
* @param
driveVehicleo
Bo
* @param
vehicleEdit
Bo
* @param sn
* @param sn
* @param bindVehicleDevice
* @param bindVehicleDevice
*/
*/
private
void
checkSnBindDevice
(
TrialDriveVehicleEditBo
driveVehicleo
Bo
,
String
sn
,
List
<
VehicleDevice
>
bindVehicleDevice
)
{
private
void
checkSnBindDevice
(
TrialDriveVehicleEditBo
vehicleEdit
Bo
,
String
sn
,
List
<
VehicleDevice
>
bindVehicleDevice
)
{
//查询该设备是否绑定过其他车辆 绑定过 抛出异常
//查询该设备是否绑定过其他车辆 绑定过 抛出异常
VehicleDevice
vdBind
=
vehicleDeviceService
.
getVehicleDeviceBySnBind
(
sn
);
VehicleDevice
vdBind
=
vehicleDeviceService
.
getVehicleDeviceBySnBind
(
sn
);
if
(
vdBind
!=
null
&&
!
String
.
valueOf
(
vdBind
.
getVehicleId
()).
equals
(
driveVehicleo
Bo
.
getTempId
()))
{
if
(
vdBind
!=
null
&&
!
String
.
valueOf
(
vdBind
.
getVehicleId
()).
equals
(
vehicleEdit
Bo
.
getTempId
()))
{
throw
new
AdminException
(
ResultEnum
.
TRIAL_DRIVE_DEVICE_EXISTS
.
getCode
(),
throw
new
AdminException
(
ResultEnum
.
TRIAL_DRIVE_DEVICE_EXISTS
.
getCode
(),
String
.
format
(
ResultEnum
.
TRIAL_DRIVE_DEVICE_EXISTS
.
getMessage
(),
vdBind
.
getVehicleId
()));
String
.
format
(
ResultEnum
.
TRIAL_DRIVE_DEVICE_EXISTS
.
getMessage
(),
v
ehicleEditBo
.
getVin
(),
v
dBind
.
getVehicleId
()));
}
}
if
(
StringUtils
.
isNotBlank
(
sn
)
&&
!
deviceService
.
checkSnExist
(
sn
))
{
if
(
StringUtils
.
isNotBlank
(
sn
)
&&
!
deviceService
.
checkSnExist
(
sn
))
{
// 旧e盾不存在 抛出异常 存在则保存数据
// 旧e盾不存在 抛出异常 存在则保存数据
...
@@ -324,7 +323,7 @@ public class VehicleService {
...
@@ -324,7 +323,7 @@ public class VehicleService {
throw
new
AdminException
(
ResultEnum
.
DEVICE_NOT_EXIST
.
getCode
(),
throw
new
AdminException
(
ResultEnum
.
DEVICE_NOT_EXIST
.
getCode
(),
String
.
format
(
ResultEnum
.
DEVICE_NOT_EXIST
.
getMessage
(),
sn
));
String
.
format
(
ResultEnum
.
DEVICE_NOT_EXIST
.
getMessage
(),
sn
));
}
else
{
}
else
{
deviceService
.
saveTrackInfoBo
(
trackInfoBo
,
driveVehicleo
Bo
.
getShopNameId
());
deviceService
.
saveTrackInfoBo
(
trackInfoBo
,
vehicleEdit
Bo
.
getShopNameId
());
}
}
}
}
// 3. 现在绑定了 以前也绑定了
// 3. 现在绑定了 以前也绑定了
...
@@ -344,7 +343,7 @@ public class VehicleService {
...
@@ -344,7 +343,7 @@ public class VehicleService {
// 4. 现在绑定了 以前未绑定
// 4. 现在绑定了 以前未绑定
}
else
if
(
StringUtils
.
isNotBlank
(
sn
)
&&
CollectionUtils
.
isEmpty
(
bindVehicleDevice
))
{
}
else
if
(
StringUtils
.
isNotBlank
(
sn
)
&&
CollectionUtils
.
isEmpty
(
bindVehicleDevice
))
{
//绑定
//绑定
vehicleDeviceService
.
saveSnToVehicleId
(
sn
,
Long
.
valueOf
(
driveVehicleo
Bo
.
getTempId
()));
vehicleDeviceService
.
saveSnToVehicleId
(
sn
,
Long
.
valueOf
(
vehicleEdit
Bo
.
getTempId
()));
}
}
}
}
...
...
src/main/resources/mapper/VehicleMapper.xml
View file @
d695141
...
@@ -241,8 +241,11 @@
...
@@ -241,8 +241,11 @@
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
where tv.del_flag = 0
where tv.del_flag = 0
and tvd.bind_status = 1
and tvd.bind_status = 1
<if
test=
"userId != null"
>
<if
test=
"userIds != null and userIds.size() > 0"
>
and tv.created_by = #{userId}
and tv.created_by in
<foreach
collection=
"userIds"
separator=
","
open=
"("
close=
")"
item=
"item"
>
#{item}
</foreach>
</if>
</if>
<choose>
<choose>
<when
test=
"termType == 1"
>
<when
test=
"termType == 1"
>
...
...
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