|
@@ -63,13 +63,12 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
|
|
|
public Map<String,Object> deviceControl(String productCode, String deviceUuid, String commandStr,Integer tenantId, Long userId, String userName){
|
|
|
Map<String,Object> rec_map = new HashMap<>();
|
|
|
|
|
|
+ JSONObject dataJson = JSONObject.parseObject(commandStr);
|
|
|
|
|
|
//存储下发设备控制命令到数据库表中
|
|
|
DmpDeviceCommand command = new DmpDeviceCommand();
|
|
|
command.setProductCode(productCode);
|
|
|
- if(StringUtils.isNotBlank(deviceUuid)){
|
|
|
- command.setDeviceUuid(deviceUuid);
|
|
|
- }
|
|
|
+ command.setDeviceUuid(dataJson.get("deviceUuid").toString());
|
|
|
|
|
|
command.setCommandContent(commandStr);
|
|
|
command.setCreatedTime(LocalDateTime.now());
|
|
@@ -83,14 +82,13 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
|
|
|
dmpDeviceCommandService.save(command);
|
|
|
int commandId = command.getId();
|
|
|
|
|
|
- JSONObject dataJson = JSONObject.parseObject(commandStr);
|
|
|
dataJson.put("id",commandId);
|
|
|
|
|
|
command.setCommandContent(dataJson.toJSONString());
|
|
|
dmpDeviceCommandService.updateById(command);
|
|
|
//推送下发设备控制mqtt
|
|
|
if(StringUtils.isNotBlank(commandStr)){
|
|
|
- String topic = "/"+deviceUuid+"/control";
|
|
|
+ String topic = "/usky/devices/"+deviceUuid+"/control";
|
|
|
mqttGateway.sendToMqtt(topic,dataJson.toJSONString());
|
|
|
}
|
|
|
|