|
|
@@ -86,19 +86,28 @@ public class EditIotEquipmentService { |
|
|
|
if (ObjectUtil.isEmpty(iotEquipment)) { |
|
|
|
throw new ServiceException("该设备不存在"); |
|
|
|
} |
|
|
|
iotEquipment = iotEquipmentMapper.selectOne(new LambdaQueryWrapper<IotEquipment>() |
|
|
|
.eq(IotEquipment::getTenantId, tenantId) |
|
|
|
.eq(IotEquipment::getDeptId, request.getDeptId()) |
|
|
|
.eq(IotEquipment::getCode, request.getCode()) |
|
|
|
.eq(IotEquipment::getMark, MarkEnum.VALID.getCode())); |
|
|
|
if (ObjectUtil.isNotEmpty(iotEquipment)) { |
|
|
|
throw new ServiceException("该部门下已存在该编号设备"); |
|
|
|
|
|
|
|
String code = iotEquipment.getCode(); |
|
|
|
if (!StringUtils.isEmpty(code)) { |
|
|
|
if (!request.getCode().equals(code)) { //不相等 说明这次用户要修改设备编码 |
|
|
|
//在修改前判断 用户传来的设备编号在数据库中是否已经存在 |
|
|
|
IotEquipment equipment = iotEquipmentMapper.selectOne(new LambdaQueryWrapper<IotEquipment>() |
|
|
|
.eq(IotEquipment::getTenantId, tenantId) |
|
|
|
.eq(IotEquipment::getDeptId, request.getDeptId()) |
|
|
|
.eq(IotEquipment::getCode, request.getCode()) |
|
|
|
.eq(IotEquipment::getMark, MarkEnum.VALID.getCode())); |
|
|
|
if (ObjectUtil.isNotEmpty(equipment)) { |
|
|
|
throw new ServiceException("该部门下已存在该编号设备"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 启用、禁用 |
|
|
|
* |
|
|
|
* @param id |
|
|
|
* @param status |
|
|
|
* @return |
|
|
@@ -124,19 +133,20 @@ public class EditIotEquipmentService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查启用/禁用参数 |
|
|
|
* |
|
|
|
* @param id |
|
|
|
* @param status |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult check1(String id,int status) { |
|
|
|
private JsonResult check1(String id, int status) { |
|
|
|
if (StringUtils.isEmpty(id)) { |
|
|
|
throw new ServiceException("设备Id码为空"); |
|
|
|
} |
|
|
|
if(String.valueOf(status).equals("")){ |
|
|
|
if (String.valueOf(status).equals("")) { |
|
|
|
throw new ServiceException("设备状态为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if(1 != status && 0 != status){ |
|
|
|
if (1 != status && 0 != status) { |
|
|
|
throw new ServiceException("无法修改状态,状态只有启用或者禁用两种!"); |
|
|
|
} |
|
|
|
|