Commit 74b67ff6 by levphon

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

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