Commit 5574cb33 by 111-PC\111

[+]pulsar消费服务

1 parent 79a32bda
...@@ -4,6 +4,7 @@ import cn.com.glsx.consumer.entity.DeviceVo; ...@@ -4,6 +4,7 @@ import cn.com.glsx.consumer.entity.DeviceVo;
import cn.com.glsx.consumer.utils.HttpUtil; import cn.com.glsx.consumer.utils.HttpUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -29,6 +30,9 @@ public class DeviceService { ...@@ -29,6 +30,9 @@ public class DeviceService {
@Value("${deleteUserDevUrl}") @Value("${deleteUserDevUrl}")
private String deleteUserDevUrl; private String deleteUserDevUrl;
@Value("${getDeviceNameUrl}")
private String getDeviceNameUrl;
/** /**
* 设备绑定 * 设备绑定
* *
...@@ -59,4 +63,19 @@ public class DeviceService { ...@@ -59,4 +63,19 @@ public class DeviceService {
} }
} }
public String getDeviceName(String devId) {
String name=null;
try {
JSONObject jsonObject = HttpUtil.sendGet(getDeviceNameUrl.replace("{device_id}", devId), null, new HashMap<>());
JSONObject message = jsonObject.getJSONObject("message");
if(message!=null){
name = message.getString("name");
}
log.info("设备id{}名称查询结果{}",devId, name);
} catch (Exception e) {
e.printStackTrace();
log.info("设备id{}名称查询结果{}", devId, e);
}
return name;
}
} }
...@@ -244,7 +244,8 @@ public class InfoService { ...@@ -244,7 +244,8 @@ public class InfoService {
private DeviceVo convervo(DeviceEvent deviceEvent) { private DeviceVo convervo(DeviceEvent deviceEvent) {
DeviceVo deviceVo = new DeviceVo(); DeviceVo deviceVo = new DeviceVo();
DeviceEventDetail bizData = deviceEvent.getBizData(); DeviceEventDetail bizData = deviceEvent.getBizData();
deviceVo.setDeviceName(bizData.getName()); String name=deviceService.getDeviceName(bizData.getDevId());
deviceVo.setDeviceName(name);
deviceVo.setUid(bizData.getUid()); deviceVo.setUid(bizData.getUid());
deviceVo.setPlatformProductId(deviceEvent.getProductKey()); deviceVo.setPlatformProductId(deviceEvent.getProductKey());
deviceVo.setChannel(1); deviceVo.setChannel(1);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!