Commit 0e06c7d6 by huangjy

fix:修复bug

parent 43228883
...@@ -47,6 +47,11 @@ public class IotCommonService { ...@@ -47,6 +47,11 @@ public class IotCommonService {
ResponseMessage responseMessage = getResponseMessage(url, response); ResponseMessage responseMessage = getResponseMessage(url, response);
return responseMessage; return responseMessage;
} }
public ResponseMessage sendPatch(String url, HttpRequest request) throws IOException {
Response response = request.patch();
ResponseMessage responseMessage = getResponseMessage(url, response);
return responseMessage;
}
public ResponseMessage sendGet(String url, HttpRequest request) throws IOException { public ResponseMessage sendGet(String url, HttpRequest request) throws IOException {
Response response = request.get(); Response response = request.get();
ResponseMessage responseMessage = getResponseMessage(url, response); ResponseMessage responseMessage = getResponseMessage(url, response);
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.makeit.module.iot.dto.IotQueryParam; import com.makeit.module.iot.dto.IotQueryParam;
import com.makeit.module.iot.dto.IotSort; import com.makeit.module.iot.dto.IotSort;
import com.makeit.module.iot.dto.Term; import com.makeit.module.iot.dto.Term;
...@@ -23,12 +24,14 @@ import com.makeit.utils.old.StringUtils; ...@@ -23,12 +24,14 @@ import com.makeit.utils.old.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* iot产品设备相关接口 * iot产品设备相关接口
...@@ -69,6 +72,28 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -69,6 +72,28 @@ public class IotProductDeviceService extends IotCommonService {
return Lists.newArrayList(); return Lists.newArrayList();
} }
@Async
public void syncUpdateDeviceInfo(String id,String name) {
String url = iotUrl + "/device-instance";
// 条件可以自己改
Map<String,Object> reqMap = Maps.newHashMap();
reqMap.put("id",id);
reqMap.put("name",name);
String body = JsonUtil.toJson(reqMap);
HttpRequest request = buildRequest(url, body);
try {
ResponseMessage responseMessage = sendPatch(url, request);
if (responseMessage.getStatus() == 200) {
log.info("修改设备名称成功:{}",id);
} else {
log.error("获取设备接口失败:{}", responseMessage.getMessage());
}
} catch (IOException e) {
log.error("调用:{}接口异常:{}", url, e.getMessage());
}
}
/** /**
* 获取最新一条设备日志 * 获取最新一条设备日志
* *
......
...@@ -26,6 +26,7 @@ import com.makeit.enums.CodeMessageEnum; ...@@ -26,6 +26,7 @@ import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.device.PlatDeviceMapper; import com.makeit.mapper.platform.device.PlatDeviceMapper;
import com.makeit.module.iot.service.IotDevicePropertiesOperateService; import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.DeviceProperties; import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.auth.PlatOrgService; import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.device.PlatDeviceOtherService; import com.makeit.service.platform.device.PlatDeviceOtherService;
...@@ -71,6 +72,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -71,6 +72,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private PlatTenantService platTenantService; private PlatTenantService platTenantService;
@Autowired @Autowired
private PlatRegionSettingService platRegionSettingService; private PlatRegionSettingService platRegionSettingService;
@Autowired
private IotProductDeviceService iotProductDeviceService;
@Override @Override
public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) { public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
...@@ -125,6 +128,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -125,6 +128,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
deviceCacheUtil.put(db); deviceCacheUtil.put(db);
iotProductDeviceService.syncUpdateDeviceInfo(db.getOriDeviceId(),dto.getName());
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment