Commit 74b67ff6 by levphon

车辆管理-车辆编辑的时候验证设备占用情况

1 parent 206a413b
......@@ -337,10 +337,17 @@ public class VehicleController {
FileIOUtil.download(inputStream, FileIOUtil.MimeType.EXCEL2007, fileName, response);
}
/**
* 验证试驾设备
*
* @param sn 校验设备号
* @param vehicleId 编辑车辆的车辆id
* @return
*/
@ApiOperation(value = "验证试驾设备")
@SysLog(module = "车辆管理", value = "验证试驾设备", action = OperateType.QUERY, saveLog = false)
@GetMapping("/vehicleinfo/verifydevice")
public R verifydevice(@RequestParam String sn) {
public R verifydevice(@RequestParam("sn") String sn, Long vehicleId) {
// 校验设备号是否存在
boolean snExist = deviceService.checkSnLocalAndRemote(sn);
if (!snExist) {
......@@ -348,7 +355,7 @@ public class VehicleController {
}
// 校验设备号是否已经绑定
boolean bindSn = deviceService.checkBindStatusBySn(sn);
boolean bindSn = deviceService.checkBindStatusBySn(sn, vehicleId);
if (!bindSn) {
return R.error(1001, sn + "设备已经绑定").data(false);
}
......@@ -378,7 +385,7 @@ public class VehicleController {
noExistSnList.add(deviceInfoDto.getSn());
}
// 校验设备号是否已经绑定
boolean bindSn = deviceService.checkBindStatusBySn(deviceInfoDto.getSn());
boolean bindSn = deviceService.checkBindStatusBySn(deviceInfoDto.getSn(), null);
if (!bindSn) {
bindSnList.add(deviceInfoDto.getSn());
}
......
......@@ -184,13 +184,18 @@ public class DeviceService {
*
* @param sn 设备号
*/
public boolean checkBindStatusBySn(String sn) {
public boolean checkBindStatusBySn(String sn, Long vehicleId) {
if (StringUtils.isEmpty(sn)) {
return false;
}
VehicleDevice vehicleDevice = vehicleDeviceMapper.selectBindDeviceBySn(sn);
if (vehicleDevice == null) {
return true;
} else {
if (vehicleDevice.getVehicleId().equals(vehicleId)) {
return true;
}
}
return false;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!