public static Boolean isSelectRedis = false;//是否继续查询Redis
/*** 从Redis实时获取语音记录文本(党组会)
*@paramtopicId*/
public voidgetRecordTextNew_Redis(JedisPool jedisPool,String topicId) {
Jedis jedis= null;while(isSelectRedis) {try{
jedis= jedisPool.getResource(); //取出一个连接
Set results = jedis.zrange("asr:text:"+topicId,0,-1);for(String result: results) {//TODO消费result
if(StringUtils.isNotEmpty(result)) {
JSONObject resultMsg=JSONObject.parseObject(result);
String text= resultMsg.getString("result");
System.out.println("消息text:"+text);
String pgs= "1";
String micName= resultMsg.getString("roleName");
String micId= resultMsg.getString("role");
String uId= resultMsg.getString("uid");//段落ID
if(StringUtils.isNotEmpty(text)) {
String dataText= "" + micName + ":" +text;
String dataText2= "
textMap.put(uId, dataText2);
System.out.println("消息dataText:"+dataText);
JSONObject textObj = newJSONObject();
textObj.put("dataText", dataText);
textObj.put("dataPgs", pgs);
textObj.put("dataUId", uId);try{
Thread.sleep(400);
}catch(InterruptedException e) {//TODO 自动生成的 catch 块
e.printStackTrace();
}
ConfWebSocketService.sendMessage(textObj.toJSONString(),"2");//向页面发送消息
}}
}
String[] strResults= (String[])(results.toArray(newString[results.size()]));if (strResults.length > 0) {//TODO 移除消费掉的数据
jedis.zrem("asr:text:"+topicId, strResults);
}
Thread.sleep(300);
}catch(Exception e) {if (jedis != null) {
jedis.close();
}
e.printStackTrace();
}finally{if (jedis != null) {
jedis.close();
}
}
}
}