|
@@ -11,6 +11,7 @@ import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.iot.domain.IotServerInfo;
|
|
import com.xunmei.common.core.domain.iot.domain.IotServerInfo;
|
|
|
import com.xunmei.common.core.enums.iot.IotServerConnectStatus;
|
|
import com.xunmei.common.core.enums.iot.IotServerConnectStatus;
|
|
|
import com.xunmei.common.core.exception.SystemException;
|
|
import com.xunmei.common.core.exception.SystemException;
|
|
|
|
|
+import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.iot.dto.serverInfo.IotServerInfoEditDto;
|
|
import com.xunmei.iot.dto.serverInfo.IotServerInfoEditDto;
|
|
@@ -18,6 +19,7 @@ import com.xunmei.iot.dto.serverInfo.IotServerInfoPageDto;
|
|
|
import com.xunmei.iot.mapper.IotServerInfoMapper;
|
|
import com.xunmei.iot.mapper.IotServerInfoMapper;
|
|
|
import com.xunmei.iot.service.IotServerInfoService;
|
|
import com.xunmei.iot.service.IotServerInfoService;
|
|
|
import com.xunmei.iot.vo.serverInfo.IotServerInfoPageVo;
|
|
import com.xunmei.iot.vo.serverInfo.IotServerInfoPageVo;
|
|
|
|
|
+import com.xunmei.system.api.RemoteMediatorService;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -29,6 +31,7 @@ import java.net.URLEncoder;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -44,6 +47,8 @@ public class IotServerInfoServiceImpl extends ServiceImpl<IotServerInfoMapper, I
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
RemoteOrgService orgService;
|
|
RemoteOrgService orgService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ RemoteMediatorService mediatorService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public TableDataInfo<IotServerInfoPageVo> serverPage(IotServerInfoPageDto request) {
|
|
public TableDataInfo<IotServerInfoPageVo> serverPage(IotServerInfoPageDto request) {
|
|
@@ -81,7 +86,7 @@ public class IotServerInfoServiceImpl extends ServiceImpl<IotServerInfoMapper, I
|
|
|
return baseMapper.insert(serverInfo);
|
|
return baseMapper.insert(serverInfo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private String getVerificationCode(List<String> usedCodeList){
|
|
|
|
|
|
|
+ private String getVerificationCode(List<String> usedCodeList) {
|
|
|
while (true) {
|
|
while (true) {
|
|
|
String numericCode = numericCode();
|
|
String numericCode = numericCode();
|
|
|
if (!usedCodeList.contains(numericCode)) {
|
|
if (!usedCodeList.contains(numericCode)) {
|
|
@@ -114,6 +119,20 @@ public class IotServerInfoServiceImpl extends ServiceImpl<IotServerInfoMapper, I
|
|
|
info.setIotName(req.getIotName());
|
|
info.setIotName(req.getIotName());
|
|
|
info.setEnable(req.getEnable());
|
|
info.setEnable(req.getEnable());
|
|
|
updateById(info);
|
|
updateById(info);
|
|
|
|
|
+ if (1 == req.getEnable()) {
|
|
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ final AjaxResult result = mediatorService.closeSession(info.getIotCode());
|
|
|
|
|
+ if (result.isSuccess()) {
|
|
|
|
|
+ info.setIotStatus(IotServerConnectStatus.OFFLINE.getIdx());
|
|
|
|
|
+ updateById(info);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|