diff --git a/ruoyi-admin/src/main/java/org/dromara/web/service/IotService.java b/ruoyi-admin/src/main/java/org/dromara/web/service/IotService.java index 13765377e..e36c0a738 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/service/IotService.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/service/IotService.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.benmanes.caffeine.cache.Cache; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.utils.MessageUtils; import org.dromara.web.config.CommonYmlConfig; import org.dromara.web.device.iot.DeviceCtlDto; @@ -26,6 +27,7 @@ import java.util.Map; * @Discription : iot相关服务 **/ @Service +@Slf4j public class IotService { @Resource private Cache tokenCache; @@ -102,8 +104,15 @@ public class IotService { map.put("entityId",deviceCode); map.put("scope","SERVER_SCOPE"); String send = getSend(CommonYmlConfig.URL_IOT_SCOPE_ATTRIBUTE + "?keys=active", map); - if (send.startsWith("{")) throw new RuntimeException("获取服务端属性信息失败"); - JSONArray jsonObject = JSON.parseArray(send); + log.info("设备信息获取成功,设备编号:{},IOT接口返回:{}", deviceCode, send); + if (send.startsWith("{")) throw new RuntimeException(MessageUtils.message("message.fault.device.notfound")); + JSONArray jsonObject = null; + try { + jsonObject = JSON.parseArray(send); + } catch (Exception e) { + log.error("设备信息获取失败,请检查设备编号是否正确,设备编号:{},IOT接口返回:{}", deviceCode, send); + throw new RuntimeException(MessageUtils.message("message.fault.device.notfound")); + } String resultString = JSON.toJSONString(jsonObject.get(0)); Object value = JSON.parseObject(resultString).get("value"); DeviceServerMsgDto result = new DeviceServerMsgDto();