分批次发送mqtt指令
This commit is contained in:
parent
fe033c805d
commit
1aba7557e0
|
|
@ -739,9 +739,24 @@ public class IotCommonP3ServiceImpl {
|
|||
try{
|
||||
log.error("===========预发送指令========={}============", variables.size());
|
||||
if (deploy != null && variables != null && !variables.isEmpty()) {
|
||||
QueryCmd queryCmd = LhIotUtil.ConstructCmd(variables);
|
||||
String cmdStr = JSONObject.toJSONString(queryCmd);
|
||||
mqttService.sendMessage(deploy.getDeviceIotUrl(), cmdStr);
|
||||
if(variables.size()>10){
|
||||
//如果超过十个分多次,十个一组
|
||||
int batchSize = 10;
|
||||
for (int i = 0; i < variables.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, variables.size());
|
||||
List<String> batch = variables.subList(i, end);
|
||||
|
||||
// 处理这一批数据
|
||||
QueryCmd queryCmd = LhIotUtil.ConstructCmd(batch);
|
||||
String cmdStr = JSONObject.toJSONString(queryCmd);
|
||||
mqttService.sendMessage(deploy.getDeviceIotUrl(), cmdStr);
|
||||
|
||||
log.error("===========当前批次指令========={}============", batch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
//抛出未注入时的报错
|
||||
|
|
|
|||
Loading…
Reference in New Issue