/**
* redis服务
*/
@Autowired
private RedisService redisService;

 

 

//创建 Device  对象

Device no = new Device();

//设置属性

no.setDeviceNo("Ubibot1");
no.setCompanyId(10);
no.setGroupId(1);

// 创建异常设备集合
List<Device> deviceError = new ArrayList<Device>();

//在集合中放入no 对象

deviceError.add(no);

//如果集合有值

if(deviceError.size() > 0) {

  // 异常设备的json数组,把list转换成json数组
  JSONArray jsonArray = JSONObject.parseArray(JSON.toJSONString(deviceError));

  //把json数组转换成String类型
  String json = jsonArray.toJSONString();

  // 将错误装置JSON数组放入redis中
  redisService.set(RedisKey.CULTIVATION_RECORD_ERROR, json);

}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2021-11-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2021-06-26
  • 2022-12-23
  • 2021-10-29
  • 2022-01-17
相关资源
相似解决方案