|
|
@@ -97,4 +97,55 @@ public class EditIotEquipmentService { |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 启用、禁用 |
|
|
|
* @param id |
|
|
|
* @param status |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public JsonResult isEnabled(String id, int status) { |
|
|
|
JsonResult result = this.check1(id, status); |
|
|
|
|
|
|
|
if (0 != result.getCode()) { |
|
|
|
log.info("物联设备状态:校验失败:{}", result.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
IotEquipment equipment = new IotEquipment(); |
|
|
|
equipment.setId(id); |
|
|
|
equipment.setStatus(status); |
|
|
|
int rowId = iotEquipmentMapper.updateById(equipment); |
|
|
|
if (rowId <= 0) { |
|
|
|
log.info("启用,禁用算法:失败:{}", result.getMsg()); |
|
|
|
return JsonResult.error("启用,禁用算法:失败"); |
|
|
|
} |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查启用/禁用参数 |
|
|
|
* @param id |
|
|
|
* @param status |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult check1(String id,int status) { |
|
|
|
if (StringUtils.isEmpty(id)) { |
|
|
|
throw new ServiceException("设备Id码为空"); |
|
|
|
} |
|
|
|
if(String.valueOf(status).equals("")){ |
|
|
|
throw new ServiceException("设备状态为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if(1 != status && 0 != status){ |
|
|
|
throw new ServiceException("无法修改状态,状态只有启用或者禁用两种!"); |
|
|
|
} |
|
|
|
|
|
|
|
IotEquipment iotEquipment = iotEquipmentMapper.selectOne(new LambdaQueryWrapper<IotEquipment>() |
|
|
|
.eq(IotEquipment::getId, id) |
|
|
|
.eq(IotEquipment::getMark, MarkEnum.VALID.getCode())); |
|
|
|
if (ObjectUtil.isEmpty(iotEquipment)) { |
|
|
|
throw new ServiceException("该设备不存在"); |
|
|
|
} |
|
|
|
return JsonResult.success(iotEquipment); |
|
|
|
} |
|
|
|
} |