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 a4f77c05
authored
May 26, 2021
by
黄小葱
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化 修改bug
1 parent
b2c3868f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
57 deletions
src/main/java/cn/com/glsx/admin/common/enums/ResultEnum.java
src/main/java/cn/com/glsx/admin/modules/controller/VehicleController.java
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
src/main/java/cn/com/glsx/admin/modules/model/param/TrialDriveVehicleBo.java
src/main/java/cn/com/glsx/admin/modules/model/param/TrialDriveVehicleEditBo.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 @
a4f77c0
...
@@ -28,6 +28,7 @@ public enum ResultEnum {
...
@@ -28,6 +28,7 @@ public enum ResultEnum {
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
,
"未找到失败的文件"
),
UN_BIND_DEVICE
(
12120005
,
"请先解绑设备"
),
/**
/**
* 拆除报警
* 拆除报警
...
...
src/main/java/cn/com/glsx/admin/modules/controller/VehicleController.java
View file @
a4f77c0
...
@@ -90,6 +90,7 @@ public class VehicleController {
...
@@ -90,6 +90,7 @@ public class VehicleController {
@ApiOperation
(
value
=
"删除试驾车辆数据"
)
@ApiOperation
(
value
=
"删除试驾车辆数据"
)
@GetMapping
(
"/drivevehicle/delete"
)
@GetMapping
(
"/drivevehicle/delete"
)
@SysLog
(
"删除试驾车辆数据"
)
public
R
deleteDriveVehicle
(
@RequestParam
(
required
=
true
)
String
tempId
)
{
public
R
deleteDriveVehicle
(
@RequestParam
(
required
=
true
)
String
tempId
)
{
if
(
StringUtils
.
isBlank
(
tempId
))
{
if
(
StringUtils
.
isBlank
(
tempId
))
{
return
R
.
error
(
"未选择数据"
);
return
R
.
error
(
"未选择数据"
);
...
@@ -122,18 +123,18 @@ public class VehicleController {
...
@@ -122,18 +123,18 @@ public class VehicleController {
*
*
* @throws Exception
* @throws Exception
*/
*/
@RequestMapping
(
value
=
"/drivevehicle/downloadtemplate"
)
@ApiOperation
(
value
=
"下载车辆管理导入模板"
)
@GetMapping
(
value
=
"/drivevehicle/downloadtemplate"
)
@ResponseBody
@ResponseBody
@SysLog
(
"下载车辆管理导入模板"
)
public
void
downloadTemplate
(
HttpServletResponse
response
)
throws
Exception
{
public
void
downloadTemplate
(
HttpServletResponse
response
)
throws
Exception
{
InputStream
inputStream
=
VehicleController
.
class
.
getResourceAsStream
(
"/templates/importVehicle.xlsx"
);
InputStream
inputStream
=
VehicleController
.
class
.
getResourceAsStream
(
"/templates/importVehicle.xlsx"
);
String
fileName
=
"车辆管理导入模板"
;
String
fileName
=
"车辆管理导入模板"
;
FileIOUtil
.
download
(
inputStream
,
FileIOUtil
.
MimeType
.
EXCEL2007
,
fileName
,
response
);
FileIOUtil
.
download
(
inputStream
,
FileIOUtil
.
MimeType
.
EXCEL2007
,
fileName
,
response
);
}
}
@RequestMapping
(
value
=
"/drivevehicle/downloadFailFile"
)
@ApiOperation
(
value
=
"下载导入失败的文件"
)
@GetMapping
(
value
=
"/drivevehicle/downloadFailFile"
)
@ResponseBody
@ResponseBody
@SysLog
(
"下载导入失败的文件"
)
public
void
downloadFailFile
(
HttpServletResponse
response
,
String
failSeqNoFile
)
throws
Exception
{
public
void
downloadFailFile
(
HttpServletResponse
response
,
String
failSeqNoFile
)
throws
Exception
{
InputStream
inputStream
=
vehicleService
.
downloadFailExcelFile
(
failSeqNoFile
);
InputStream
inputStream
=
vehicleService
.
downloadFailExcelFile
(
failSeqNoFile
);
String
fileName
=
"试驾车辆_"
+
DateUtils
.
formatSerial
(
new
Date
());
String
fileName
=
"试驾车辆_"
+
DateUtils
.
formatSerial
(
new
Date
());
...
...
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
View file @
a4f77c0
...
@@ -12,7 +12,6 @@ import cn.com.glsx.admin.modules.model.param.VehicleTreeSearch;
...
@@ -12,7 +12,6 @@ import cn.com.glsx.admin.modules.model.param.VehicleTreeSearch;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
import
java.util.List
;
...
@@ -57,4 +56,5 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
...
@@ -57,4 +56,5 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
List
<
OrgVehicleModel
>
selectVehicleSns
(
VehicleTreeSearch
search
);
List
<
OrgVehicleModel
>
selectVehicleSns
(
VehicleTreeSearch
search
);
Vehicle
selectById
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
Vehicle
selectById
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/model/param/TrialDriveVehicleBo.java
View file @
a4f77c0
...
@@ -4,6 +4,7 @@ import cn.com.glsx.admin.modules.model.ValidateGroups;
...
@@ -4,6 +4,7 @@ import cn.com.glsx.admin.modules.model.ValidateGroups;
import
lombok.Data
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
/**
* @Desc:新增试驾车辆车辆
* @Desc:新增试驾车辆车辆
...
@@ -11,50 +12,50 @@ import javax.validation.constraints.NotNull;
...
@@ -11,50 +12,50 @@ import javax.validation.constraints.NotNull;
* @Date 2021/5/20
* @Date 2021/5/20
*/
*/
@Data
@Data
public
class
TrialDriveVehicleBo
{
public
class
TrialDriveVehicleBo
implements
Serializable
{
@NotNull
(
message
=
"特约店名称不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"特约店名称不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
Long
shopNameId
;
private
Long
shopNameId
;
/**
/**
* 特约店名称
* 特约店名称
*/
*/
@NotNull
(
message
=
"特约店名称不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"特约店名称不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
shopName
;
private
String
shopName
;
/**
/**
* 车架号
* 车架号
*/
*/
@NotNull
(
message
=
"车架号不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"车架号不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
vin
;
private
String
vin
;
/**
/**
* 车辆型号id
* 车辆型号id
*/
*/
@NotNull
(
message
=
"车辆型号不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"车辆型号不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
Integer
modelId
;
private
Integer
modelId
;
/**
/**
* 车辆型号名称
* 车辆型号名称
*/
*/
@NotNull
(
message
=
"车辆型号不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"车辆型号不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
modelName
;
private
String
modelName
;
/**
/**
* 车辆配置id
* 车辆配置id
*/
*/
@NotNull
(
message
=
"车辆配置不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"车辆配置不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
configId
;
private
Integer
configId
;
/**
/**
* 车辆配置
* 车辆配置
*/
*/
@NotNull
(
message
=
"车辆配置不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"车辆配置不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
configDesc
;
private
String
configDesc
;
/**
/**
* 车辆外部颜色
* 车辆外部颜色
*/
*/
@NotNull
(
message
=
"外色不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"外色不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
color
;
private
String
color
;
/**
/**
* 车辆内饰颜色
* 车辆内饰颜色
*/
*/
@NotNull
(
message
=
"内色不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"内色不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
String
innerColor
;
private
String
innerColor
;
/**
/**
* 车牌
* 车牌
...
@@ -63,30 +64,11 @@ public class TrialDriveVehicleBo {
...
@@ -63,30 +64,11 @@ public class TrialDriveVehicleBo {
/**
/**
* 服役类型:0未上牌,1已上牌
* 服役类型:0未上牌,1已上牌
*/
*/
@NotNull
(
message
=
"服役类型不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Insert
.
class
})
@NotNull
(
message
=
"服役类型不能为空"
,
groups
=
{
ValidateGroups
.
Insert
.
class
})
private
Integer
serveType
;
private
Integer
serveType
;
/**
/**
* 设备号
* 设备号
*/
*/
private
String
sn
;
private
String
sn
;
/**
* 销售经理
*/
private
String
saleManager
;
/**
* 销售经理电话
*/
private
String
saleManagerPhone
;
/**
* 购置方式
*/
private
String
buyType
;
/**
* 购置方式
*/
private
String
remark
;
}
}
src/main/java/cn/com/glsx/admin/modules/model/param/TrialDriveVehicleEditBo.java
View file @
a4f77c0
...
@@ -18,5 +18,24 @@ public class TrialDriveVehicleEditBo extends TrialDriveVehicleBo {
...
@@ -18,5 +18,24 @@ public class TrialDriveVehicleEditBo extends TrialDriveVehicleBo {
@NotNull
(
message
=
"编辑id不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Delete
.
class
})
@NotNull
(
message
=
"编辑id不能为空"
,
groups
=
{
ValidateGroups
.
Update
.
class
,
ValidateGroups
.
Delete
.
class
})
private
String
tempId
;
private
String
tempId
;
/**
* 销售经理
*/
private
String
saleManager
;
/**
* 销售经理电话
*/
private
String
saleManagerPhone
;
/**
* 购置方式
*/
private
String
buyType
;
/**
* 备注
*/
private
String
remark
;
}
}
src/main/java/cn/com/glsx/admin/modules/service/VehicleService.java
View file @
a4f77c0
...
@@ -122,6 +122,44 @@ public class VehicleService {
...
@@ -122,6 +122,44 @@ public class VehicleService {
vehicle
.
setUpdatedBy
(
ShieldContextHolder
.
getUserId
());
vehicle
.
setUpdatedBy
(
ShieldContextHolder
.
getUserId
());
vehicle
.
setUpdatedDate
(
new
Date
());
vehicle
.
setUpdatedDate
(
new
Date
());
vehicleMapper
.
updateByPrimaryKey
(
vehicle
);
vehicleMapper
.
updateByPrimaryKey
(
vehicle
);
List
<
VehicleDevice
>
bindVehicleDevice
=
listVehicleDeviceByVehicleIdStatus
(
vehicle
.
getId
());
String
sn
=
driveVehicleoBo
.
getSn
();
if
(
StringUtils
.
isBlank
(
sn
)
&&
CollectionUtils
.
isEmpty
(
bindVehicleDevice
))
{
return
;
}
else
if
(
StringUtils
.
isBlank
(
sn
)
&&
CollectionUtils
.
isNotEmpty
(
bindVehicleDevice
))
{
throw
new
AdminException
(
ResultEnum
.
UN_BIND_DEVICE
);
}
else
if
(
StringUtils
.
isNotBlank
(
sn
)
&&
CollectionUtils
.
isNotEmpty
(
bindVehicleDevice
))
{
//绑定的设备和已存在的是否相同 全部不相同 提示先解绑 再重新绑定
boolean
bindFlag
=
false
;
for
(
VehicleDevice
vehicleDevice
:
bindVehicleDevice
)
{
if
(
vehicleDevice
.
getSn
().
equals
(
sn
))
{
bindFlag
=
true
;
}
}
// 不相同 提示
if
(!
bindFlag
)
{
throw
new
AdminException
(
ResultEnum
.
UN_BIND_DEVICE
);
}
}
else
if
(
StringUtils
.
isNotBlank
(
sn
)
&&
CollectionUtils
.
isEmpty
(
bindVehicleDevice
))
{
//绑定
saveVehicleDevice
(
sn
,
vehicle
.
getId
());
}
}
/**
* 保存车辆设备绑定关系
* @param sn
* @param vehicleId
*/
public
void
saveVehicleDevice
(
String
sn
,
Long
vehicleId
)
{
VehicleDevice
vehicleDevice
=
new
VehicleDevice
();
vehicleDevice
.
setSn
(
sn
);
vehicleDevice
.
setBindStatus
(
ConstantsDevice
.
BIND_VEHICLE_STATUS
);
vehicleDevice
.
setVehicleId
(
vehicleId
);
vehicleDevice
.
setCreatedBy
(
ShieldContextHolder
.
getUserId
());
vehicleDevice
.
setCreatedDate
(
new
Date
());
vehicleDeviceMapper
.
insert
(
vehicleDevice
);
}
}
/**
/**
...
@@ -133,14 +171,13 @@ public class VehicleService {
...
@@ -133,14 +171,13 @@ public class VehicleService {
public
TrialDriveVehicleEditDTO
findDriveVehicleById
(
String
tempId
)
{
public
TrialDriveVehicleEditDTO
findDriveVehicleById
(
String
tempId
)
{
TrialDriveVehicleEditDTO
editDTO
=
new
TrialDriveVehicleEditDTO
();
TrialDriveVehicleEditDTO
editDTO
=
new
TrialDriveVehicleEditDTO
();
Vehicle
vehicle
=
vehicleMapper
.
selectById
(
Long
.
parseLong
(
tempId
));
Vehicle
vehicle
=
vehicleMapper
.
selectById
(
Long
.
parseLong
(
tempId
));
if
(
vehicle
==
null
)
{
return
null
;
}
BeanUtils
.
copyProperties
(
vehicle
,
editDTO
);
BeanUtils
.
copyProperties
(
vehicle
,
editDTO
);
editDTO
.
setShopNameId
(
vehicle
.
getCreatedBy
());
editDTO
.
setShopNameId
(
vehicle
.
getCreatedBy
());
//
//
VehicleDevice
param
=
new
VehicleDevice
();
List
<
VehicleDevice
>
bindVehicleDevice
=
listVehicleDeviceByVehicleIdStatus
(
vehicle
.
getId
());
param
.
setBindStatus
(
ConstantsDevice
.
BIND_VEHICLE_STATUS
);
param
.
setVehicleId
(
vehicle
.
getId
());
//匹配设备
List
<
VehicleDevice
>
bindVehicleDevice
=
vehicleDeviceMapper
.
getVehicleDeviceByVehicleIdStatus
(
param
);
if
(
CollectionUtils
.
isEmpty
(
bindVehicleDevice
))
{
if
(
CollectionUtils
.
isEmpty
(
bindVehicleDevice
))
{
return
editDTO
;
return
editDTO
;
}
}
...
@@ -156,16 +193,27 @@ public class VehicleService {
...
@@ -156,16 +193,27 @@ public class VehicleService {
}
}
/**
/**
* 查询车辆绑定了哪些设备
* @param vehicleId
* @return
*/
public
List
<
VehicleDevice
>
listVehicleDeviceByVehicleIdStatus
(
Long
vehicleId
)
{
VehicleDevice
param
=
new
VehicleDevice
();
param
.
setBindStatus
(
ConstantsDevice
.
BIND_VEHICLE_STATUS
);
param
.
setVehicleId
(
vehicleId
);
//匹配设备
List
<
VehicleDevice
>
bindVehicleDevice
=
vehicleDeviceMapper
.
getVehicleDeviceByVehicleIdStatus
(
param
);
return
bindVehicleDevice
;
}
/**
* 解绑车辆设备
* 解绑车辆设备
*
*
* @param tempId
* @param tempId
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
unbindDriveVehicle
(
String
tempId
)
{
public
void
unbindDriveVehicle
(
String
tempId
)
{
VehicleDevice
param
=
new
VehicleDevice
();
List
<
VehicleDevice
>
vehicleDevices
=
listVehicleDeviceByVehicleIdStatus
(
Long
.
parseLong
(
tempId
));
param
.
setBindStatus
(
ConstantsDevice
.
BIND_VEHICLE_STATUS
);
param
.
setVehicleId
(
Long
.
parseLong
(
tempId
));
List
<
VehicleDevice
>
vehicleDevices
=
vehicleDeviceMapper
.
getVehicleDeviceByVehicleIdStatus
(
param
);
if
(
CollectionUtils
.
isEmpty
(
vehicleDevices
))
{
if
(
CollectionUtils
.
isEmpty
(
vehicleDevices
))
{
throw
new
AdminException
(
ResultEnum
.
PARAM_ERROR
);
throw
new
AdminException
(
ResultEnum
.
PARAM_ERROR
);
}
}
...
@@ -312,6 +360,7 @@ public class VehicleService {
...
@@ -312,6 +360,7 @@ public class VehicleService {
* 保存车辆、车辆和设备的绑定关系
* 保存车辆、车辆和设备的绑定关系
* @param vi
* @param vi
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
insertVehicleAndSn
(
TrialDriveVehicleImport
vi
)
{
public
void
insertVehicleAndSn
(
TrialDriveVehicleImport
vi
)
{
//保存车辆
//保存车辆
Vehicle
vehicle
=
new
Vehicle
();
Vehicle
vehicle
=
new
Vehicle
();
...
@@ -325,13 +374,7 @@ public class VehicleService {
...
@@ -325,13 +374,7 @@ public class VehicleService {
if
(
StringUtils
.
isBlank
(
sn
))
{
if
(
StringUtils
.
isBlank
(
sn
))
{
return
;
return
;
}
}
VehicleDevice
vehicleDevice
=
new
VehicleDevice
();
saveVehicleDevice
(
sn
,
vehicle
.
getId
());
vehicleDevice
.
setSn
(
sn
);
vehicleDevice
.
setBindStatus
(
ConstantsDevice
.
BIND_VEHICLE_STATUS
);
vehicleDevice
.
setVehicleId
(
vehicle
.
getId
());
vehicleDevice
.
setCreatedBy
(
ShieldContextHolder
.
getUserId
());
vehicleDevice
.
setCreatedDate
(
new
Date
());
vehicleDeviceMapper
.
insert
(
vehicleDevice
);
}
}
/**
/**
...
...
src/main/resources/mapper/VehicleMapper.xml
View file @
a4f77c0
...
@@ -65,11 +65,11 @@
...
@@ -65,11 +65,11 @@
<sql
id=
"search_sql_condition"
>
<sql
id=
"search_sql_condition"
>
<if
test=
"searchKey != null and searchKey != '' "
>
<if
test=
"searchKey != null and searchKey != '' "
>
and (
and (
ttds.shop_code like
'%'#{searchKey}'%'
ttds.shop_code like
concat('%',#{searchKey},'%')
or ttds.shop_name like
'%'#{searchKey}'%'
or ttds.shop_name like
concat('%',#{searchKey},'%')
or tv.vin like
'%'#{searchKey}'%'
or tv.vin like
concat('%',#{searchKey},'%')
or tvd.sn like
'%'#{searchKey}'%'
or tvd.sn like
concat('%',#{searchKey},'%')
or tv.model_name like
'%'#{searchKey}'%'
or tv.model_name like
concat('%',#{searchKey},'%')
)
)
</if>
</if>
</sql>
</sql>
...
...
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